and those without space

This commit is contained in:
j 2008-04-21 10:16:46 +02:00
parent 6f7f07e690
commit 33518260ee

View file

@ -30,9 +30,9 @@ def srt2dict(srt, encoding = "utf-8"):
if subtitle.strip():
subtitle = subtitle.strip().split('\n')
if len(subtitle) > 2:
start_stop = subtitle[1].split(' --> ')
start_stop[0] = start_stop[0].split(' ')[0]
start_stop[1] = start_stop[1].split(' ')[0]
start_stop = subtitle[1].split('-->')
start_stop[0] = start_stop[0].strip().split(' ')[0]
start_stop[1] = start_stop[1].strip().split(' ')[0]
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])