From d39c237b04e45d974d585336ff1d88d104c80c3e Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Sat, 25 Apr 2015 19:18:32 +0200 Subject: [PATCH] ignore subtitles that are longer than the video. --- pandora/item/models.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pandora/item/models.py b/pandora/item/models.py index d42e3efe7..025a6e4a9 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1569,15 +1569,18 @@ class Item(models.Model): for data in s.srt(offset): subtitles_added = True value = data['value'].replace('\n', '
\n').replace('

\n', '
\n') - annotation = Annotation( - item=self, - layer=layer, - start=float('%0.03f'%data['in']), - end=float('%0.03f'%data['out']), - value=value, - user=user - ) - annotation.save() + if data['in'] < self.json['duration'] and data['out'] > self.json['duration']: + data['out'] = self.json['duration'] + if data['in'] < self.json['duration']: + annotation = Annotation( + item=self, + layer=layer, + start=float('%0.03f'%data['in']), + end=float('%0.03f'%data['out']), + value=value, + user=user + ) + annotation.save() #otherwise add empty 5 seconds annotation every minute if not subtitles_added: start = offset and int (offset / 60) * 60 + 60 or 0