pythontwitch

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


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 would be using app engine.


Solution

  • 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!