Fixed bug when there could be copies in IRL query answer
This commit is contained in:
parent
a49e0aed68
commit
95ccc3766b
2 changed files with 14 additions and 7 deletions
|
@ -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.
|
||||
|
|
8
main.py
8
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:
|
||||
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')
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue