From a3e86f3be768c8fa1fc2af12d5e5d66d9d9b82e8 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 16 Aug 2011 14:49:40 +0200 Subject: Implemented basic cuesheet support, some playlist fixes. --- app.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'app.py') diff --git a/app.py b/app.py index c2ef0a3..3b887d8 100755 --- a/app.py +++ b/app.py @@ -35,8 +35,10 @@ class Application(object): return open(filename, 'rb') def cache(self, environ, start_response, path): + args = cgi.FieldStorage(environ = environ) path = os.path.join(*path[1:]) - cache_path = File(path).get_cache_path() + track = args.getvalue('track') if 'track' in args else None + cache_path = File(path, track = track).get_cache_path() if not os.path.exists(cache_path) or '..' in path: start_response('404 Not Found', []) @@ -61,8 +63,9 @@ class Application(object): def json_recode(self, environ, start_response, path): args = cgi.FieldStorage(environ = environ) path = args.getvalue('path') if 'path' in args else None + track = args.getvalue('track') if 'track' in args else None - f = File(path) + f = File(path, track = track) # see json_play() if not os.path.splitext(path)[1] in ('.mp3', '.ogg'): decoder = 'ffmpeg' @@ -76,8 +79,9 @@ class Application(object): args = cgi.FieldStorage(environ = environ) path = args.getvalue('path') + track = args.getvalue('track') if 'track' in args else None - f = File(path) + f = File(path, track = track) # TODO: replace this with some sane logic if not os.path.splitext(path)[1] in ('.mp3', '.ogg'): cache_path = f.get_cache_path() @@ -86,7 +90,7 @@ class Application(object): if not os.path.exists(cache_path): f.start_recode(decoder, encoder, environ['sessionid']) else: - events.event_pub.play(environ['sessionid'], '/cache/{0}'.format(path)) + events.event_pub.play(environ['sessionid'], '/cache/{0}{1}'.format(path, ('?track=' + track if track else ''))) else: events.event_pub.play(environ['sessionid'], '/files/{0}'.format(path)) -- cgit v1.2.3