Fixed bug with VOD-streams

This commit is contained in:
2017-11-03 13:40:49 +03:00
parent 77cd74f7e2
commit a8d512faae
5 changed files with 16 additions and 11 deletions

View file

@ -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

View file

@ -7,7 +7,7 @@ import json
import cherrypy
from cherrypy.process.plugins import Daemonizer
ver = '1.02'
ver = '1.03'
repl = {'"':'&quot;', '&':'&amp;', '<':'&lt;', '>':'&gt;' }
@ -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<br>Tell me more at <a href="https://twitter.com/alexvanin">https://twitter.com/alexvanin</a>'

View file

@ -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

View file

@ -1,5 +1,5 @@
<!doctype html>
<html lang="en" class="no-js">
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
@ -7,7 +7,6 @@
<title>FLeast</title>
<link rel="stylesheet" href="/fleast/style.css">
<link rel="shortcut icon" href="/flaest/favicon.ico" type="image/png">
</head>
<body>

View file

@ -1,5 +1,5 @@
<!doctype html>
<html lang="en" class="no-js">
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">