diff --git a/pandora/item/models.py b/pandora/item/models.py index 797e437..fabe950 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 23a0062..1e4b777 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: