forked from 0x2620/pandora
load subtitles in sync with creating timeline, use stream duration for files
This commit is contained in:
parent
6ab2ae3c54
commit
f5cd0cf2ca
4 changed files with 17 additions and 9 deletions
|
@ -203,9 +203,11 @@ class File(models.Model):
|
|||
|
||||
if self.type not in ('audio', 'video'):
|
||||
self.duration = None
|
||||
elif self.duration <= 0:
|
||||
self.duration = sum([s.info.get('duration',0)
|
||||
else:
|
||||
duration = sum([s.info.get('duration', 0)
|
||||
for s in self.streams.filter(source=None)])
|
||||
if duration:
|
||||
self.duration = duration
|
||||
|
||||
if self.is_subtitle:
|
||||
self.available = self.data and True or False
|
||||
|
|
|
@ -170,7 +170,8 @@ def addFile(request):
|
|||
'''
|
||||
takes {
|
||||
id: oshash
|
||||
title:
|
||||
filename: string,
|
||||
item: string
|
||||
info: {}
|
||||
}
|
||||
returns {
|
||||
|
|
|
@ -1000,7 +1000,8 @@ class Item(models.Model):
|
|||
update = True
|
||||
if update:
|
||||
self.rendered = False
|
||||
self.update_timeline()
|
||||
self.save()
|
||||
tasks.update_timeline.delay(self.itemId)
|
||||
break
|
||||
|
||||
def get_torrent(self, request):
|
||||
|
@ -1074,7 +1075,7 @@ class Item(models.Model):
|
|||
Q(file__is_audio=True)|Q(file__is_video=True)
|
||||
).order_by('file__part', 'file__sort_path')
|
||||
|
||||
def update_timeline(self, force=False):
|
||||
def update_timeline(self, force=False, async=True):
|
||||
streams = self.streams()
|
||||
self.make_timeline()
|
||||
if streams.count() == 1:
|
||||
|
@ -1104,8 +1105,12 @@ class Item(models.Model):
|
|||
self.make_torrent()
|
||||
self.rendered = streams.count() > 0
|
||||
self.save()
|
||||
if async:
|
||||
tasks.load_subtitles.delay(self.itemId)
|
||||
get_sequences.delay(self.itemId)
|
||||
else:
|
||||
tasks.load_subtitles(self.itemId)
|
||||
get_sequences(self.itemId)
|
||||
|
||||
def save_poster(self, data):
|
||||
self.poster.name = self.path('poster.jpg')
|
||||
|
|
|
@ -68,10 +68,10 @@ def update_external(itemId):
|
|||
item = models.Item.objects.get(itemId=itemId)
|
||||
item.update_external()
|
||||
|
||||
@task(queue="default")
|
||||
@task(queue="encoding")
|
||||
def update_timeline(itemId):
|
||||
item = models.Item.objects.get(itemId=itemId)
|
||||
item.update_timeline()
|
||||
item.update_timeline(async=False)
|
||||
|
||||
@task(queue="encoding")
|
||||
def rebuild_timeline(itemId):
|
||||
|
|
Loading…
Reference in a new issue