From 4fc84b02b7141e9d4c412a70e9016eef7b909e90 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 16 Aug 2011 12:11:07 +0200 Subject: [PATCH] poster frame resolutions --- pandora/item/models.py | 2 +- pandora/item/urls.py | 2 +- pandora/item/views.py | 10 ++++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index 4eafa25bb..769027319 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -400,7 +400,7 @@ class Item(models.Model): stream['baseUrl'] = '/%s' % self.itemId else: stream['baseUrl'] = os.path.dirname(s.video.url) - stream['profiles'] = sorted(list(set(map(lambda s: int(os.path.splitext(s['profile'])[0][:-1]), self.streams.all().values('profile'))))) + stream['resolutions'] = sorted(list(set(map(lambda s: int(os.path.splitext(s['profile'])[0][:-1]), self.streams.all().values('profile'))))) stream['formats'] = list(set(map(lambda s: os.path.splitext(s['profile'])[1][1:], self.streams.all().values('profile')))) return stream diff --git a/pandora/item/urls.py b/pandora/item/urls.py index 6cc1484e4..942a9e4ab 100644 --- a/pandora/item/urls.py +++ b/pandora/item/urls.py @@ -6,7 +6,7 @@ from django.conf.urls.defaults import * urlpatterns = patterns("item.views", #frames - (r'^(?P[A-Z0-9].+)/(?P\d+)p(?P[\d\.]+)\.jpg$', 'frame'), + (r'^(?P[A-Z0-9].+)/(?P\d+)p(?P[\d\.]*)\.jpg$', 'frame'), #timelines (r'^(?P[A-Z0-9].+)/timeline(?P\d+)p(?P\d+)\.png$', 'timeline'), diff --git a/pandora/item/views.py b/pandora/item/views.py index ab18014ec..4d833b845 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -548,9 +548,15 @@ actions.register(getImdbId) ''' media delivery ''' -def frame(request, id, position, size): +def frame(request, id, size, position=None): item = get_object_or_404(models.Item, itemId=id) - position = float(position.replace(',', '.')) + if not position: + if item.poster_frame == -1 and item.sort.duration: + position = item.sort.duration/2 + else: + position = item.poster_frame + else: + position = float(position.replace(',', '.')) frame = item.frame(position, int(size)) if not frame: raise Http404