use item.poster_frame if set
This commit is contained in:
parent
5a844b0a14
commit
67630fa9ed
3 changed files with 24 additions and 9 deletions
|
@ -736,6 +736,12 @@ class Item(models.Model):
|
|||
def local_posters(self):
|
||||
part = 1
|
||||
posters = {}
|
||||
self.poster_frame >= 0:
|
||||
frame = self.get_poster_frame_path()
|
||||
path = self.path('poster.pandora.%s.%s.jpg'%(part, self.poster_frame))
|
||||
path = os.path.abspath(os.path.join(settings.MEDIA_ROOT, path))
|
||||
posters[path] = frame
|
||||
else:
|
||||
for f in self.main_videos():
|
||||
for frame in f.frames.all():
|
||||
path = self.path('poster.pandora.%s.%s.jpg'%(part, frame.position))
|
||||
|
@ -766,13 +772,20 @@ class Item(models.Model):
|
|||
p.wait()
|
||||
return posters.keys()
|
||||
|
||||
def make_icon(self):
|
||||
#FIXME: should take middle or selected frame or som
|
||||
def get_poster_frame_path(self):
|
||||
if self.poster_frame >= 0:
|
||||
size = int(settings.VIDEO_PROFILE[:-1])
|
||||
return self.frame(self.poster_frame, size)
|
||||
|
||||
frames = []
|
||||
for f in self.main_videos():
|
||||
for ff in f.frames.all():
|
||||
frames.append(ff.frame.path)
|
||||
if frames:
|
||||
return frames[int(len(frames)/2)]
|
||||
|
||||
def make_icon(self):
|
||||
frame = self.get_poster_frame_path()
|
||||
if frame:
|
||||
icon = self.path('icon.jpg')
|
||||
self.icon.name = icon
|
||||
frame = frames[int(len(frames)/2)]
|
||||
|
|
|
@ -16,6 +16,7 @@ def cronjob(**kwargs):
|
|||
def update_poster(itemId):
|
||||
item = models.Item.objects.get(itemId=itemId)
|
||||
item.make_poster(True)
|
||||
item.make_icon()
|
||||
|
||||
|
||||
@task(ignore_resulsts=True, queue='default')
|
||||
|
|
|
@ -373,6 +373,7 @@ def setPosterFrame(request): #parse path and return info
|
|||
#FIXME: some things need to be updated after changing this
|
||||
item.poster_frame = data['position']
|
||||
item.save()
|
||||
tasks.update_poster.delay(item.itemId)
|
||||
response = json_response()
|
||||
else:
|
||||
response = json_response(status=403, text='permissino denied')
|
||||
|
|
Loading…
Reference in a new issue