From ced5d06f89f914c3ebd909c5b0b145dba67b82a3 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 19 Oct 2011 16:56:53 +0200 Subject: [PATCH] insert default clisp --- pandora/item/models.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index e125a159..a5c05d12 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1005,14 +1005,17 @@ class Item(models.Model): #loop over all videos for f in self.files.filter(Q(is_audio=True)|Q(is_video=True)) \ .filter(selected=True).order_by('part'): + subtitles_added = False prefix = os.path.splitext(f.path)[0] + user = f.instances.all()[0].volume.user + #if there is a subtitle with the same prefix, import q = subtitles.filter(path__startswith=prefix, language=language) if q.count() == 1: s = q[0] - user = s.instances.all()[0].volume.user for data in s.srt(offset): + subtitles_added = True annotation = Annotation( item=self, layer=layer, @@ -1022,6 +1025,20 @@ class Item(models.Model): user=user ) 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 self.update_find()