else:
return False
- print "Total:", self.total
return self.clients[id][0]
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:
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()
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:
playlistgen.addItem(channel)
exported = playlistgen.exportm3u(hostport,prefix)
-
+
exported = exported.encode('utf-8')
+
connection.wfile.write(exported)
def getparam(self, key):
# http://n4k3d.com/the-m3u-file-format/
import sys
+import hexdump
+import codecs
class track():
def __init__(self, length, title, path):
#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
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
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))
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):
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