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