summaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'app.py')
-rwxr-xr-xapp.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/app.py b/app.py
index 7d88ebe..6ea7082 100755
--- a/app.py
+++ b/app.py
@@ -38,8 +38,25 @@ class JSONApplication(object):
start_response('200 OK', [('Content-Type', 'application/json'), ('Content-Length', str(len(contents)))])
return [contents]
+ def hint(self, environ, start_response, path):
+ track_id = int(path[1])
+ session = db.Session()
+ try:
+ track = db.Track.get_by_id(session, track_id)
+ cached = self.cache_check(track)
+ finally:
+ session.close()
+
+ if not cached:
+ r = codec.Recoder(track.get_path(), config.get('encoder'), track.file_index, os.path.join(config.get('cache_dir'), str(track.id)))
+ r.recode()
+
+ start_response('200 OK', [('Content-Type', 'application/json')])
+ return [json.dumps({'recoded': not cached})]
+
handlers = {
'list': list,
+ 'hint': hint,
}
def __call__(self, environ, start_response, path):