Is There Any Way To Check if a Twitch Stream Is Live Using Python?

后端 未结 7 474
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 18:44

I\'m just wondering if there is any way to write a python script to check to see if a twitch.tv stream is live?

I\'m not sure why my app engine tag was removed, but this

7条回答
  •  生来不讨喜
    2021-02-04 19:38

    It looks like Twitch provides an API (documentation here) that provides a way to get that info. A very simple example of getting the feed would be:

    import urllib2
    
    url = 'http://api.justin.tv/api/stream/list.json?channel=FollowGrubby'
    contents = urllib2.urlopen(url)
    
    print contents.read()
    

    This will dump all of the info, which you can then parse with a JSON library (XML looks to be available too). Looks like the value returns empty if the stream isn't live (haven't tested this much at all, nor have I read anything :) ). Hope this helps!

提交回复
热议问题