diff --git a/README.md b/README.md index 7a18a15..04d7205 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ Least-favourite twitch streamers here ## Change Log +### 1.6 +- Fixed bug, when IRL query could contain several copies of one stream + ### 1.5 - IRL section is back with IRL query - Fixed bug when games with `&` symbol could not found correctly. diff --git a/main.py b/main.py index 0a7e2db..b53e25a 100755 --- a/main.py +++ b/main.py @@ -5,7 +5,7 @@ import cherrypy from cherrypy.process.plugins import Daemonizer from twitch import TwitchClient -ver = '1.5' +ver = '1.6' class FleastServer(object): @@ -83,16 +83,20 @@ class FleastServer(object): cherrypy.log('Found %d streams' % data['_total']) if game == "IRL": + uniq_streams = [] streams = sorted(data['streams'], key=lambda k: k['viewer_count']) result_str = '' irl_url = 'https://twitch.tv/{}' for s in streams: - result_str += self.templ_stream.format(irl_url.format(s['user_name']), - s['thumbnail_url'].format(width=320, height=180), - self.to_html(s['title']), - s['user_name'], - s['viewer_count']) + '\n' + 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']), + s['thumbnail_url'].format(width=320, height=180), + self.to_html(s['title']), + s['user_name'], + s['viewer_count']) + '\n' else: + streams = sorted(data['streams'], key=lambda k: k['viewers']) result_str = '' for s in streams: @@ -111,7 +115,7 @@ class FleastServer(object): def main(): server = FleastServer() - d = Daemonizer(cherrypy.engine).subscribe() + # d = Daemonizer(cherrypy.engine).subscribe() cherrypy.quickstart(server, '/', './server.conf')