From f3431fa0005aef2205065519873af8a0fccacdbb Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 19 Aug 2011 14:20:30 +0200 Subject: [PATCH] ratio --- pandora/item/models.py | 20 ++++++++------------ pandora/item/views.py | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index 797e437d9..fabe9504b 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -238,7 +238,8 @@ class Item(models.Model): t = re.sub('(.*?)', fix_titles, t) return t data['trivia'] = [fix_links(t) for t in data['trivia']] - + if 'aspectratio' in data: + data['aspectRatio'] = data.pop('aspectratio') #filter reviews self.external_data = data self.save() @@ -318,13 +319,6 @@ class Item(models.Model): other.save() #FIXME: update poster, stills and streams after this - def get_poster(self): - poster = {} - poster['width'] = self.poster_width - poster['height'] = self.poster_height - poster['url'] = '/%s/poster.jpg' % self.itemId - return poster - def get_posters(self): url = self.prefered_poster_url() index = [] @@ -433,12 +427,14 @@ class Item(models.Model): if 'cast' in i and isinstance(i['cast'][0], list): i['cast'] = map(lambda x: {'actor': x[0], 'character': x[1]}, i['cast']) - if not keys or 'poster' in keys: - i['poster'] = self.get_poster() + if not keys or 'posterRatio' in keys: + i['posterRatio'] = self.poster_width / self.poster_height - i['durations'] = [s.duration for s in self.streams()] + streams = self.streams() + i['durations'] = [s.duration for s in streams] i['duration'] = sum(i['durations']) - i['apsectRatio'] = i.get('aspectratio') + if streams: + i['videoRatio'] = streams[0].aspect_ratio #only needed by admins if keys and 'posters' in keys: diff --git a/pandora/item/views.py b/pandora/item/views.py index 23a006214..1e4b77724 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -484,7 +484,7 @@ def setPoster(request): #parse path and return info item.save() tasks.update_poster(item.itemId) response = json_response() - response['data']['poster'] = item.get_poster() + response['data']['posterAspect'] = item.poster_width/item.poster_height else: response = json_response(status=403, text='invalid poster url') else: