Fixes for 1.02 version
This commit is contained in:
parent
212cd8652a
commit
f378d3fa17
2 changed files with 13 additions and 5 deletions
16
src/main.py
16
src/main.py
|
@ -7,9 +7,11 @@ import json
|
||||||
import cherrypy
|
import cherrypy
|
||||||
from cherrypy.process.plugins import Daemonizer
|
from cherrypy.process.plugins import Daemonizer
|
||||||
|
|
||||||
ver = '1.01'
|
ver = '1.02'
|
||||||
|
|
||||||
|
|
||||||
|
repl = {'"':'"', '&':'&', '<':'<', '>':'>' }
|
||||||
|
|
||||||
class FleastServer(object):
|
class FleastServer(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
try:
|
try:
|
||||||
|
@ -39,6 +41,12 @@ class FleastServer(object):
|
||||||
templ += l.format(' ') + '\n'
|
templ += l.format(' ') + '\n'
|
||||||
return templ.rstrip()
|
return templ.rstrip()
|
||||||
|
|
||||||
|
def to_html(self, text):
|
||||||
|
#return ''.join(repl.get(s,s) for s in text)
|
||||||
|
for i in repl:
|
||||||
|
text = text.replace(i, repl[i])
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def index(self, game=None, lang=None):
|
def index(self, game=None, lang=None):
|
||||||
|
@ -46,6 +54,7 @@ class FleastServer(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def fleast(self, game=None, lang=None):
|
def fleast(self, game=None, lang=None):
|
||||||
|
game = game.rstrip()
|
||||||
if game is None or game == '':
|
if game is None or game == '':
|
||||||
return self.index_page.format(_version_ = ver, _opt_langs_ = self.set_templ_lang('ru'))
|
return self.index_page.format(_version_ = ver, _opt_langs_ = self.set_templ_lang('ru'))
|
||||||
|
|
||||||
|
@ -65,7 +74,7 @@ class FleastServer(object):
|
||||||
streams = sorted(data['streams'], key=lambda k: k['viewers'])
|
streams = sorted(data['streams'], key=lambda k: k['viewers'])
|
||||||
result_str = ''
|
result_str = ''
|
||||||
for s in streams:
|
for s in streams:
|
||||||
result_str += self.templ_stream.format(s['channel']['url'], s['preview']['medium'],s['channel']['status'], \
|
result_str += self.templ_stream.format(s['channel']['url'], s['preview']['medium'], self.to_html(s['channel']['status']), \
|
||||||
s['channel']['display_name'], s['viewers']) +'\n'
|
s['channel']['display_name'], s['viewers']) +'\n'
|
||||||
|
|
||||||
return self.templ_main.format(_stream_num_ = data['_total'], _game_name_ = game, \
|
return self.templ_main.format(_stream_num_ = data['_total'], _game_name_ = game, \
|
||||||
|
@ -75,8 +84,7 @@ class FleastServer(object):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
server = FleastServer()
|
server = FleastServer()
|
||||||
d = Daemonizer(cherrypy.engine)
|
d = Daemonizer(cherrypy.engine).subscribe()
|
||||||
d.subscribe()
|
|
||||||
cherrypy.quickstart(server, '/', './server.conf')
|
cherrypy.quickstart(server, '/', './server.conf')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<option value="ru" {}>russian</option>
|
<option value="ru" {}>russian</option>
|
||||||
<option value="en" {}>english</option>
|
<option value="en" {}>english</option>
|
||||||
<option value="de" {}>german</option>
|
<option value="de" {}>german</option>
|
||||||
<option value="zh" {}>chinese</option>
|
<option value="zh-tw" {}>chinese (TW)</option>
|
||||||
<option value="fi" {}>finnish</option>
|
<option value="fi" {}>finnish</option>
|
||||||
<option value="fr" {}>french</option>
|
<option value="fr" {}>french</option>
|
||||||
<option value="it" {}>italian</option>
|
<option value="it" {}>italian</option>
|
||||||
|
|
Loading…
Reference in a new issue