From f2329d79e065accc44c69f2ec8daeceb4f43fa4d Mon Sep 17 00:00:00 2001 From: alexvanin Date: Fri, 27 Mar 2020 23:45:01 +0300 Subject: [PATCH] api: Use 80% threshold on data get in twitch api v6 --- main.py | 3 +-- twitch.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 356fd26..35d9be7 100755 --- a/main.py +++ b/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, diff --git a/twitch.py b/twitch.py index eb14ae2..aa01f51 100644 --- a/twitch.py +++ b/twitch.py @@ -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'])