merging changes

This commit is contained in:
rlx 2011-08-16 13:55:55 +00:00
commit 3e4a978738

View file

@ -550,14 +550,24 @@ actions.register(getImdbId)
''' '''
def frame(request, id, size, position=None): def frame(request, id, size, position=None):
item = get_object_or_404(models.Item, itemId=id) item = get_object_or_404(models.Item, itemId=id)
frame = None
if not position: if not position:
if item.poster_frame == -1 and item.sort.duration: frames = item.poster_frames()
if frames:
position = item.poster_frame
if position == -1:
position = int(len(frames)/2)
position = frames[int(position)]['position']
elif item.poster_frame == -1 and item.sort.duration:
position = item.sort.duration/2 position = item.sort.duration/2
else: else:
position = item.poster_frame position = item.poster_frame
else: else:
position = float(position.replace(',', '.')) position = float(position.replace(',', '.'))
frame = item.frame(position, int(size))
if not frame:
frame = item.frame(position, int(size))
if not frame: if not frame:
raise Http404 raise Http404
return HttpFileResponse(frame, content_type='image/jpeg') return HttpFileResponse(frame, content_type='image/jpeg')