deal with funny srt mosters
This commit is contained in:
parent
28b6fb3cb5
commit
80cab8e4bb
1 changed files with 8 additions and 3 deletions
|
@ -31,10 +31,15 @@ def srt2dict(srt, encoding = "utf-8"):
|
|||
subtitle = subtitle.strip().split('\n')
|
||||
if len(subtitle) > 2:
|
||||
start_stop = subtitle[1].split(' --> ')
|
||||
subtitle[0] =u"%s" % int(subtitle[0])
|
||||
start_stop[0] = start_stop[0].split(' ')[-1]
|
||||
start_stop[1] = start_stop[1].split(' ')[-1]
|
||||
if start_stop[0][-4] == '.':
|
||||
start_stop[0][:-4] + ',' + start_stop[0][-3:]
|
||||
start_stop[1][:-4] + ',' + start_stop[1][-3:]
|
||||
subtitle[0] ="%s" % int(subtitle[0])
|
||||
subdict[subtitle[0]] = {
|
||||
'start': start_stop[0].replace('.', ','),
|
||||
'stop': start_stop[1].replace('.', ','),
|
||||
'start': start_stop[0],
|
||||
'stop': start_stop[1],
|
||||
'text': u'\n'.join(subtitle[2:]),
|
||||
}
|
||||
return subdict
|
||||
|
|
Loading…
Reference in a new issue