File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -93,11 +93,19 @@ def twitch_lookup(location):
9393 views = views + "s" if not views [0 :2 ] == "1 " else views
9494 return html .unescape (fmt .format (title , channel , playing , views ))
9595 else :
96- data = http .get_json ("https://api.twitch.tv/kraken/channels/" + channel )
97- if data and len (data ) >= 1 :
96+ data = http .get_json ("https://api.twitch.tv/kraken/streams?channel=" + channel )
97+ if data ["streams" ]:
98+ title = data ["streams" ][0 ]["channel" ]["status" ]
99+ playing = data ["streams" ][0 ]["game" ]
100+ v = data ["streams" ][0 ]["viewers" ]
101+ viewers = "\x03 3\x02 Online now!\x02 \x0f " + str (v ) + " viewer" + ("s" if v != 1 else "" )
102+ return html .unescape (fmt .format (title , channel , playing , viewers ))
103+ else :
104+ try :
105+ data = http .get_json ("https://api.twitch.tv/kraken/channels/" + channel )
106+ except :
107+ return "Unable to get channel data. Maybe channel is on justin.tv instead of twitch.tv?"
98108 title = data ['status' ]
99109 playing = data ['game' ]
100110 viewers = "\x03 4\x02 Offline\x02 \x0f "
101111 return html .unescape (fmt .format (title , channel , playing , viewers ))
102- else :
103- return
You can’t perform that action at this time.
0 commit comments