forked from 0x2620/pandora
insert default clisp
This commit is contained in:
parent
743a01181c
commit
ced5d06f89
1 changed files with 18 additions and 1 deletions
|
@ -1005,14 +1005,17 @@ class Item(models.Model):
|
||||||
#loop over all videos
|
#loop over all videos
|
||||||
for f in self.files.filter(Q(is_audio=True)|Q(is_video=True)) \
|
for f in self.files.filter(Q(is_audio=True)|Q(is_video=True)) \
|
||||||
.filter(selected=True).order_by('part'):
|
.filter(selected=True).order_by('part'):
|
||||||
|
subtitles_added = False
|
||||||
prefix = os.path.splitext(f.path)[0]
|
prefix = os.path.splitext(f.path)[0]
|
||||||
|
user = f.instances.all()[0].volume.user
|
||||||
|
|
||||||
#if there is a subtitle with the same prefix, import
|
#if there is a subtitle with the same prefix, import
|
||||||
q = subtitles.filter(path__startswith=prefix,
|
q = subtitles.filter(path__startswith=prefix,
|
||||||
language=language)
|
language=language)
|
||||||
if q.count() == 1:
|
if q.count() == 1:
|
||||||
s = q[0]
|
s = q[0]
|
||||||
user = s.instances.all()[0].volume.user
|
|
||||||
for data in s.srt(offset):
|
for data in s.srt(offset):
|
||||||
|
subtitles_added = True
|
||||||
annotation = Annotation(
|
annotation = Annotation(
|
||||||
item=self,
|
item=self,
|
||||||
layer=layer,
|
layer=layer,
|
||||||
|
@ -1022,6 +1025,20 @@ class Item(models.Model):
|
||||||
user=user
|
user=user
|
||||||
)
|
)
|
||||||
annotation.save()
|
annotation.save()
|
||||||
|
#otherwise add empty 5 seconds annotation every minute
|
||||||
|
if not subtitles_added:
|
||||||
|
i = offset
|
||||||
|
while i < offset + f.duration - 5:
|
||||||
|
annotation = Annotation(
|
||||||
|
item=self,
|
||||||
|
layer=layer,
|
||||||
|
start=i,
|
||||||
|
end=i + 5,
|
||||||
|
value='',
|
||||||
|
user=user
|
||||||
|
)
|
||||||
|
annotation.save()
|
||||||
|
i += 60
|
||||||
offset += f.duration
|
offset += f.duration
|
||||||
self.update_find()
|
self.update_find()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue