Decided to work with APIv5 later
This commit is contained in:
parent
350d2b8c3e
commit
9b992cce9d
2 changed files with 8 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from twitch import TwitchClient
|
from twitch import TwitchClient
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -9,9 +10,8 @@ def main():
|
||||||
twitch_token = reader.read().strip()
|
twitch_token = reader.read().strip()
|
||||||
|
|
||||||
client = TwitchClient(twitch_token)
|
client = TwitchClient(twitch_token)
|
||||||
streams = client.raw_query_v6('streams?game_id=%s&first=100&language=ru&type=live' % client.get_game_id('IRL')[0])
|
r = client.raw_query_v5('streams/?game=IRL&language=ru&limit=2')
|
||||||
for i in streams['data']:
|
print(json.dumps(r, indent=4))
|
||||||
print(i['title'])
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -32,10 +32,14 @@ class TwitchClient:
|
||||||
header, base = self.get_base('v6')
|
header, base = self.get_base('v6')
|
||||||
return self.do_q(base+q, header)
|
return self.do_q(base+q, header)
|
||||||
|
|
||||||
|
def raw_query_v5(self, q):
|
||||||
|
header, base = self.get_base('v5')
|
||||||
|
return self.do_q(base+q, header)
|
||||||
|
|
||||||
# Returns (ID, GAMENAME) or None
|
# Returns (ID, GAMENAME) or None
|
||||||
def get_game_id(self, name):
|
def get_game_id(self, name):
|
||||||
header, base = self.get_base('v5')
|
header, base = self.get_base('v5')
|
||||||
r = self.do_q('%s/search/games?query=%s' % (base, name), header)
|
r = self.do_q('%s/search/games?query=%s' % (base, name), header)
|
||||||
if r.get('games', None): return (r['games'][0]['_id'], r['games'][0]['name'])
|
if r.get('games', None): return (r['games'][0]['_id'], r['games'][0]['name'])
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue