From: Roman Bazalevsky Date: Thu, 22 Oct 2015 10:12:28 +0000 (+0300) Subject: Обработка Unicode-листов, убрана отладочная печать. X-Git-Url: https://git.rvb.name/vpproxy.git/commitdiff_plain/1074f7e8729c2ff065d73960c5450c9356c2fd11 Обработка Unicode-листов, убрана отладочная печать. --- diff --git a/clientcounter.py b/clientcounter.py index bd86cbe..bcfd0b2 100644 --- a/clientcounter.py +++ b/clientcounter.py @@ -34,6 +34,5 @@ class ClientCounter(object): else: return False - print "Total:", self.total return self.clients[id][0] diff --git a/plugins/m3u_plugin.py b/plugins/m3u_plugin.py index fc4d3e3..00a6193 100644 --- a/plugins/m3u_plugin.py +++ b/plugins/m3u_plugin.py @@ -104,7 +104,6 @@ class M3u(VPProxyPlugin): elif self.splitted_path[1]=="play": channel=self.splitted_path[len(self.splitted_path)-1] channel=urllib.unquote(channel).decode('utf-8') - print channel if len(self.splitted_path)<=4: prefix="get" elif len(self.splitted_path)==5: @@ -117,10 +116,8 @@ class M3u(VPProxyPlugin): for record in playlist: if record.title.decode('utf-8').replace('/','')==channel: url=record.path.decode('utf-8') - print url if url: redirect='/'+prefix+'/'+url - print redirect connection.send_response(302) connection.send_header('Location', redirect) connection.end_headers() @@ -147,7 +144,8 @@ class M3u(VPProxyPlugin): exported = "" for record in playlist: - exported = exported + "" + record.title.decode('utf-8').replace('/','') + "\n" + if record.title: + exported = exported + "" + record.title.decode('utf-8').replace('/','') + "\n" else: @@ -160,8 +158,9 @@ class M3u(VPProxyPlugin): playlistgen.addItem(channel) exported = playlistgen.exportm3u(hostport,prefix) - + exported = exported.encode('utf-8') + connection.wfile.write(exported) def getparam(self, key): diff --git a/plugins/modules/M3uParser.py b/plugins/modules/M3uParser.py index 01dbcc9..9e2fce6 100644 --- a/plugins/modules/M3uParser.py +++ b/plugins/modules/M3uParser.py @@ -2,6 +2,8 @@ # http://n4k3d.com/the-m3u-file-format/ import sys +import hexdump +import codecs class track(): def __init__(self, length, title, path): @@ -23,6 +25,9 @@ def parseM3U(infile): #EXTM3U # this is not a valid M3U and we should stop.. line = inf.readline() + line = line.lstrip('\xef\xbb\xbf') + line = line.rstrip('\n') + line = line.strip() if not line.startswith('#EXTM3U'): return @@ -31,10 +36,13 @@ def parseM3U(infile): song=track(None,None,None) for line in inf: - line=line.strip() + line = line.lstrip('\xef\xbb\xbf') + line = line.rstrip('\n') + line = line.strip() if line.startswith('#EXTINF:'): # pull length and title from #EXTINF line length,title=line.split('#EXTINF:')[1].split(',',1) + title=title.decode('string_escape') song=track(length,title,None) elif (len(line) != 0): # pull song path from all other, non-blank lines diff --git a/vlcclient/vlcclient.py b/vlcclient/vlcclient.py index 048fd2f..dbe6f3f 100644 --- a/vlcclient/vlcclient.py +++ b/vlcclient/vlcclient.py @@ -98,13 +98,16 @@ class VlcClient(object): pass def _write(self, message): + + logger = logging.getLogger("VlcClient_write") + # Return if in the middle of destroying if self._shuttingDown.isSet(): return try: # Write message - print 'VLC command:',message + logger.debug('VLC command:',message) self._socket.write(message + "\r\n") except EOFError as e: raise VlcException("Vlc Write error! ERROR: " + repr(e)) @@ -150,7 +153,7 @@ class VlcClient(object): logger.debug("Broadcast stopped") def startBroadcast(self, stream_name, input, muxer='ts', pre_access='', qtype='default'): - print "Starting broadcast......" + logger.debig("Starting broadcast......") return self._broadcast(True, stream_name, input, muxer, pre_access, qtype) def stopBroadcast(self, stream_name): diff --git a/vphttp.py b/vphttp.py index d5f9018..bda3485 100644 --- a/vphttp.py +++ b/vphttp.py @@ -187,7 +187,6 @@ class HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler): def handleRequest(self, headers_only): # Limit concurrent connections - print VPStuff.clientcounter.total if 0 < VPConfig.maxconns <= VPStuff.clientcounter.total: logger.debug("Maximum connections reached, can't serve this") self.dieWithError(503) # 503 Service Unavailable