cleanup imdb data

This commit is contained in:
j 2011-10-15 17:05:59 +02:00
parent ecfd0cd82b
commit a465654353

View file

@ -40,25 +40,7 @@ def getData(request):
i, created = models.Imdb.objects.get_or_create(imdb=id)
if created:
i.update()
#FIXME: all this should be in ox.web.imdb.Imdb
for key in ('directors', 'writers', 'editors', 'producers',
'cinematographers', 'languages', 'genres', 'keywords',
'episode_directors'):
if key in data:
data[key[:-1]] = data.pop(key)
if 'countries' in data:
data['country'] = data.pop('countries')
if 'release date' in data:
data['releasedate'] = data.pop('release date')
if isinstance(data['releasedate'], list):
data['releasedate'] = min(data['releasedate'])
if 'plot' in data:
data['summary'] = data.pop('plot')
if 'cast' in data:
if isinstance(data['cast'][0], basestring):
data['cast'] = [data['cast']]
data['actor'] = [c[0] for c in data['cast']]
data['cast'] = map(lambda x: {'actor': x[0], 'character': x[1]}, data['cast'])
def fix_links(t):
def fix_names(m):
return '<a href="/name=%s">%s</a>' % (
@ -73,10 +55,9 @@ def getData(request):
return t
if 'trivia' in data:
data['trivia'] = [fix_links(t) for t in data['trivia']]
if 'summary' in data:
data['summary'] = fix_links(data['summary'])
if 'aspectratio' in data:
data['aspectRatio'] = data.pop('aspectratio')
if 'reviews' in data:
reviews = []
@ -92,9 +73,16 @@ def getData(request):
del data['reviews']
data['posters'] = posters(request, id)
response['data'] = data
else:
response['status'] = {'text':'not found', 'code': 404}
return render_to_json_response(response)
actions.register(getData)
def parsePath(request):
path = json.loads(request.POST['data'])['path']
response = json_response(ox.parse_movie_path(path))
return render_to_json_response(response)
actions.register(parsePath)