From 6c6eb1c6038c9e4b347c3d4685df3ee070c7a8d1 Mon Sep 17 00:00:00 2001 From: Alban Date: Sat, 1 Dec 2012 20:12:35 +0100 Subject: [PATCH] Implemented getSong.view --- api/browse.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/api/browse.py b/api/browse.py index b7ce40d..d137095 100755 --- a/api/browse.py +++ b/api/browse.py @@ -107,3 +107,19 @@ def show_directory(): return request.formatter({ 'directory': directory }) +@app.route('/rest/getSong.view', methods = [ 'GET', 'POST' ]) +def track_info(): + id = request.args.get('id') + if not id: + return request.error_formatter(10, 'Missing media id') + + try: + tid = uuid.UUID(id) + except: + return request.error_formatter(0, 'Invalid media id') + + track = Track.query.get(tid) + if not track: + return request.error_formatter(70, 'Media not found'), 404 + + return request.formatter({ 'song': track.as_subsonic_child() })