poster frame resolutions

This commit is contained in:
j 2011-08-16 12:11:07 +02:00
parent 97c15882db
commit 4fc84b02b7
3 changed files with 10 additions and 4 deletions

View file

@ -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

View file

@ -6,7 +6,7 @@ from django.conf.urls.defaults import *
urlpatterns = patterns("item.views",
#frames
(r'^(?P<id>[A-Z0-9].+)/(?P<size>\d+)p(?P<position>[\d\.]+)\.jpg$', 'frame'),
(r'^(?P<id>[A-Z0-9].+)/(?P<size>\d+)p(?P<position>[\d\.]*)\.jpg$', 'frame'),
#timelines
(r'^(?P<id>[A-Z0-9].+)/timeline(?P<size>\d+)p(?P<position>\d+)\.png$', 'timeline'),

View file

@ -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