From a4656543538266dc8ca9b9646100c9e66c1b8837 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 15 Oct 2011 17:05:59 +0200 Subject: [PATCH] cleanup imdb data --- oxdata/movie/views.py | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/oxdata/movie/views.py b/oxdata/movie/views.py index 49d03c6..7c235ae 100644 --- a/oxdata/movie/views.py +++ b/oxdata/movie/views.py @@ -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 '%s' % ( @@ -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)