From a8d512faaeffd0cdd68bd39e095e1cb800045e30 Mon Sep 17 00:00:00 2001 From: Date: Fri, 3 Nov 2017 13:40:49 +0300 Subject: [PATCH] Fixed bug with VOD-streams --- README.md | 13 ++++++++----- src/main.py | 4 ++-- src/twitch.py | 5 ++++- src/web/fl.html | 3 +-- src/web/fl_template_main.html | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 78f18a9..c2a5a11 100644 --- a/README.md +++ b/README.md @@ -3,14 +3,17 @@ Least-favourite twitch streamers here ## Change-log -### 1.00 -- Initial release - -### 1.01 -- Form data now saved between querries +### 1.03 +- Fixed bug when VOD-streams appear in list of live streams ### 1.02 - Fixed some typos in text - Fixed bug with chinese language streams - Fixed bug when 0 streams are found if game name contains whitespaces in the end - Fixed bug with stream list if stream name contains '<' and '>' symbols + +### 1.01 +- Form data now saved between querries + +### 1.00 +- Initial release diff --git a/src/main.py b/src/main.py index 1f36102..563954c 100755 --- a/src/main.py +++ b/src/main.py @@ -7,7 +7,7 @@ import json import cherrypy from cherrypy.process.plugins import Daemonizer -ver = '1.02' +ver = '1.03' repl = {'"':'"', '&':'&', '<':'<', '>':'>' } @@ -59,7 +59,7 @@ class FleastServer(object): game = game.rstrip() cherrypy.log('Getting game:"%s" language:%s' % (game, lang)) - data = self.client.get_streams(game, lang) + data = self.client.get_live_streams(game, lang) if data is None: return 'Internal Error
Tell me more at https://twitter.com/alexvanin' diff --git a/src/twitch.py b/src/twitch.py index 8dac1a2..d134426 100644 --- a/src/twitch.py +++ b/src/twitch.py @@ -57,7 +57,7 @@ class TwitchClient: if r and r.get('games'): return (r['games'][0]['_id'], r['games'][0]['name']) return None - def get_streams(self, name, lang): + def get_live_streams(self, name, lang): header, base = self.get_base('v5') data = self.do_q('%s/streams/?game=%s&language=%s&limit=%s&stream_type=live' % (base, name, lang, 100), header) if data is None: return None @@ -69,6 +69,9 @@ class TwitchClient: data['streams'].extend(r['streams']) total = r['_total']; streams = len(data['streams']) + # Tweak for getting only live sterams + data['streams'] = [x for x in data['streams'] if x['stream_type'] == 'live'] + data['_total'] = len(data['streams']) return data diff --git a/src/web/fl.html b/src/web/fl.html index 310e17e..3aa5000 100644 --- a/src/web/fl.html +++ b/src/web/fl.html @@ -1,5 +1,5 @@ - + @@ -7,7 +7,6 @@ FLeast - diff --git a/src/web/fl_template_main.html b/src/web/fl_template_main.html index c196943..5baee03 100644 --- a/src/web/fl_template_main.html +++ b/src/web/fl_template_main.html @@ -1,5 +1,5 @@ - +