make subtitles in/out/value unique before importing

This commit is contained in:
j 2015-02-04 15:56:37 +05:30
parent 8a2408ff7e
commit 9273d7b3ba

View file

@ -279,7 +279,13 @@ class File(models.Model):
return None return None
def srt(self, offset=0): def srt(self, offset=0):
srt = ox.srt.load(self.data.path) srt = []
subtitles = []
for s in ox.srt.load(self.data.path):
key = '%s --> %s\n%s' % (s['in'], s['out'], s['value'])
if key not in subtitles:
subtitles.append(key)
srt.append(s)
#subtitles should not overlap #subtitles should not overlap
for i in range(1, len(srt)): for i in range(1, len(srt)):
if srt[i-1]['out'] > srt[i]['in']: if srt[i-1]['out'] > srt[i]['in']: