api: Fix bug when "unique_streams" returned incorrect dict
This commit is contained in:
parent
e53f7f02c5
commit
b37827b91d
2 changed files with 5 additions and 9 deletions
9
main.py
9
main.py
|
@ -84,21 +84,16 @@ class FleastServer(object):
|
||||||
_version_=ver)
|
_version_=ver)
|
||||||
|
|
||||||
cherrypy.log('Found %d streams' % data['_total'])
|
cherrypy.log('Found %d streams' % data['_total'])
|
||||||
|
|
||||||
uniq_streams = []
|
|
||||||
streams = sorted(data['streams'], key=lambda k: k['viewer_count'])
|
|
||||||
result_str = ''
|
result_str = ''
|
||||||
irl_url = 'https://twitch.tv/{}'
|
irl_url = 'https://twitch.tv/{}'
|
||||||
for s in streams:
|
for s in data['streams']:
|
||||||
if s['user_name'] not in uniq_streams:
|
|
||||||
uniq_streams.append(s['user_name'])
|
|
||||||
result_str += self.templ_stream.format(irl_url.format(s['user_name']),
|
result_str += self.templ_stream.format(irl_url.format(s['user_name']),
|
||||||
s['thumbnail_url'].format(width=320, height=180),
|
s['thumbnail_url'].format(width=320, height=180),
|
||||||
self.to_html(s['title']),
|
self.to_html(s['title']),
|
||||||
s['user_name'],
|
s['user_name'],
|
||||||
s['viewer_count']) + '\n'
|
s['viewer_count']) + '\n'
|
||||||
|
|
||||||
return self.templ_main.format(_stream_num_=len(streams),
|
return self.templ_main.format(_stream_num_=len(data['streams']),
|
||||||
_game_name_=game,
|
_game_name_=game,
|
||||||
_opt_langs_=self.set_templ_lang(lang),
|
_opt_langs_=self.set_templ_lang(lang),
|
||||||
_stream_list_=result_str,
|
_stream_list_=result_str,
|
||||||
|
|
|
@ -188,9 +188,10 @@ class TwitchClient:
|
||||||
def unique_streams_v6(self, result):
|
def unique_streams_v6(self, result):
|
||||||
uniq_streams = []
|
uniq_streams = []
|
||||||
streams = sorted(result['streams'], key=lambda k: k['viewer_count'])
|
streams = sorted(result['streams'], key=lambda k: k['viewer_count'])
|
||||||
|
result['streams']=[]
|
||||||
for s in streams:
|
for s in streams:
|
||||||
if s['user_name'] not in uniq_streams:
|
if s['user_name'] not in uniq_streams:
|
||||||
uniq_streams.append(s['user_name'])
|
uniq_streams.append(s['user_name'])
|
||||||
result['streams'] = uniq_streams
|
result['streams'].append(s)
|
||||||
result['_total'] = len(result['streams'])
|
result['_total'] = len(result['streams'])
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in a new issue