summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'app.py')
-rwxr-xr-xapp.py12
1 files changed, 8 insertions, 4 deletions
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))