i am trying to make some python code detect the start and end of a stream. here is what i got so far:
def streamStart():
print("stream Start")
def streamStop():
print("stream Stop")
def streamCheck():
global status,info
while True:
info = json.loads(urlopen("https://api.twitch.tv/kraken/streams/%s?client_id=<my id>"%channel, timeout = 15).read().decode('utf-8'))
if info.get("stream") == None:
if status == True:
streamStop()
status = False
else:
if status == False:
streamStart()
status = True
status = False
streamCheck()
the problem im having is that when i do start streaming it takes it about two minutes to detect it (including delay) and when it does detect it i get this output:
stream Start
stream Stop
stream Start
and when i stop streaming i get the same type of bounce but this time 11 times and 5 minutes after i stopped:
stream Stop
stream Start
stream Stop
stream Start
stream Stop
stream Start
stream Stop
stream Start
stream Stop
stream Start
stream Stop
stream Start
stream Stop
stream Start
stream Stop
stream Start
stream Stop
stream Start
stream Stop
stream Start
stream Stop
this is really ennoying and i dont want to deal with it. i can confirm that this is not a bug in my code as if i refresh my browser with the api link i can also see it changing from refresh to refresh.
im wondering if anybody else has this problem and if there is anything i can do to fix it.