add api.getMetadata

This commit is contained in:
j 2013-02-24 08:26:59 +00:00
parent b7f417c29d
commit fd59f680fb

View file

@ -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
'''