forked from 0x2620/pandora
poster frame position
This commit is contained in:
parent
2381ddb9ca
commit
8df20cbc72
1 changed files with 12 additions and 2 deletions
|
@ -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(',', '.'))
|
||||||
|
|
||||||
|
if not frame:
|
||||||
frame = item.frame(position, int(size))
|
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')
|
||||||
|
|
Loading…
Reference in a new issue