From fd59f680fb8fd02844117ea0a78a86f6c7cf7d08 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sun, 24 Feb 2013 08:26:59 +0000 Subject: [PATCH] add api.getMetadata --- pandora/item/views.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/pandora/item/views.py b/pandora/item/views.py index de3673c40..145fbf225 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -390,6 +390,40 @@ def findId(request): return render_to_json_response(response) actions.register(findId) + +def getMetadata(request): + ''' + param data { + id: string, + keys: array + } + + returns { + key: value, + .. + } + + ''' + data = json.loads(request.POST['data']) + response = json_response({}) + if settings.DATA_SERVICE: + ''' + info = {} + for c in data['query']['conditions']: + info[c['key']] = c['value'] + r = models.external_data('getId', info) + ''' + r = models.external_data('getData', {'id': data['id']}) + if r['status']['code'] == 200: + if 'keys' in data and data['keys']: + for key in data['keys']: + if key in r['data']: + response['data'][key] = r['data'][key] + else: + response['data'] = r['data'] + return render_to_json_response(response) +actions.register(getMetadata) + def get(request): ''' param data { @@ -628,6 +662,7 @@ def getImdbId(request): return render_to_json_response(response) actions.register(getImdbId) + ''' media delivery '''