I would like to get a script that every x minutes check if a list of streamer is live or not. [Python 3.6]
I’m focusing on the request to the twitch servers and I come up with this snippet.
link = 'https://api.twitch.tv/kraken/streams/?channel=' + temp + '&stream_type=live'
accept = 'application/vnd.twitchtv.v5+json'
client_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
r = requests.get(link, headers={'Client-ID':client_id, 'Accept': accept})
In there the temp variable stay for a string with a few streamer ids separated by ,(commas).
ex. temp = '21167655,132817946,406599498,222337332'
As you can see I’ve added the stream_type as live, that’s because I would like to get only live streamers, why is the get call returning a streamer that is offline but is “streaming” an old VOD.
In the top right corner of the streaming I can see a “RERUN” title. But the streamer seems to be live since on the top left corner near the streamer name there is the “live” white on red rectangle.
So basically I’ve to use the same request, and then checking the data['streams'][x][broadcast_platform] looking for the only ones that have live as value?
Filtering streams by type in the Helix API was temporarily removed a while back until they have time to address the issues plagued by that parameter. Even though you’re using Kraken, it wouldn’t surprise me if the problem persists across both APIs since they would both most likely be pulling their data from the same source. Filtering by stream type was unreliable at best, and flat out didn’t work in some instances.