api: Use 80% threshold on data get in twitch api v6
This commit is contained in:
parent
ffd1719c53
commit
f2329d79e0
2 changed files with 2 additions and 3 deletions
3
main.py
3
main.py
|
@ -97,7 +97,6 @@ class FleastServer(object):
|
|||
s['user_name'],
|
||||
s['viewer_count']) + '\n'
|
||||
else:
|
||||
|
||||
streams = sorted(data['streams'], key=lambda k: k['viewers'])
|
||||
result_str = ''
|
||||
for s in streams:
|
||||
|
@ -107,7 +106,7 @@ class FleastServer(object):
|
|||
s['channel']['display_name'],
|
||||
s['viewers']) + '\n'
|
||||
|
||||
return self.templ_main.format(_stream_num_=data['_total'],
|
||||
return self.templ_main.format(_stream_num_=len(streams),
|
||||
_game_name_=game,
|
||||
_opt_langs_=self.set_templ_lang(lang),
|
||||
_stream_list_=result_str,
|
||||
|
|
|
@ -147,7 +147,7 @@ class TwitchClient:
|
|||
|
||||
result = {'_total': 0, 'streams': []}
|
||||
data = self.do_q(init_q_template.format(base, lang, 100, game_id), header)
|
||||
while len(data.get('data', [])) != 0:
|
||||
while len(data.get('data', [])) > 0.8*100:
|
||||
result['streams'].extend(data['data'])
|
||||
data = self.do_q(q_template.format(base, lang, 100, data['pagination']['cursor'], game_id), header)
|
||||
result['_total'] = len(result['streams'])
|
||||
|
|
Loading…
Reference in a new issue