From d6d768b9170fea426d0066885076120b46a0749a Mon Sep 17 00:00:00 2001 From: j Date: Fri, 18 Apr 2008 12:27:59 +0200 Subject: [PATCH] allow any delimiter for time values in srt files xx.yy.zz.zzz normalize to xx:yy:zz,zzz which is the most common --- oxdbarchive/subtitles.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/oxdbarchive/subtitles.py b/oxdbarchive/subtitles.py index 9a156ed..da08032 100644 --- a/oxdbarchive/subtitles.py +++ b/oxdbarchive/subtitles.py @@ -33,9 +33,8 @@ def srt2dict(srt, encoding = "utf-8"): start_stop = subtitle[1].split(' --> ') start_stop[0] = start_stop[0].split(' ')[0] start_stop[1] = start_stop[1].split(' ')[0] - if start_stop[0][-4] == '.': - start_stop[0][:-4] + ',' + start_stop[0][-3:] - start_stop[1][:-4] + ',' + start_stop[1][-3:] + start_stop[0] = re.sub('(\d{2}).(\d{2}).(\d{2}).(\d{3})', '\\1:\\2:\\3,\\4', start_stop[0]) + start_stop[1] = re.sub('(\d{2}).(\d{2}).(\d{2}).(\d{3})', '\\1:\\2:\\3,\\4', start_stop[1]) subtitle[0] ="%s" % int(subtitle[0]) subdict[subtitle[0]] = { 'start': start_stop[0], @@ -178,4 +177,4 @@ def loadSrt(fname): if udata.startswith(u'\ufeff'): udata = udata[1:] return udata - \ No newline at end of file +