Merge branch 'ttmlfix'
This commit is contained in:
commit
24775c395d
@ -1196,18 +1196,15 @@ The first line
|
|||||||
srt_data = '''1
|
srt_data = '''1
|
||||||
00:00:02,080 --> 00:00:05,839
|
00:00:02,080 --> 00:00:05,839
|
||||||
<font color="white" face="sansSerif" size="16">default style<font color="red">custom style</font></font>
|
<font color="white" face="sansSerif" size="16">default style<font color="red">custom style</font></font>
|
||||||
|
|
||||||
2
|
|
||||||
00:00:02,080 --> 00:00:05,839
|
|
||||||
<b><font color="cyan" face="sansSerif" size="16"><font color="lime">part 1
|
<b><font color="cyan" face="sansSerif" size="16"><font color="lime">part 1
|
||||||
</font>part 2</font></b>
|
</font>part 2</font></b>
|
||||||
|
|
||||||
3
|
2
|
||||||
00:00:05,839 --> 00:00:09,560
|
00:00:05,839 --> 00:00:09,560
|
||||||
<u><font color="lime">line 3
|
<u><font color="lime">line 3
|
||||||
part 3</font></u>
|
part 3</font></u>
|
||||||
|
|
||||||
4
|
3
|
||||||
00:00:09,560 --> 00:00:12,359
|
00:00:09,560 --> 00:00:12,359
|
||||||
<i><u><font color="yellow"><font color="lime">inner
|
<i><u><font color="yellow"><font color="lime">inner
|
||||||
</font>style</font></u></i>
|
</font>style</font></u></i>
|
||||||
|
@ -2859,6 +2859,10 @@ def dfxp2srt(dfxp_data):
|
|||||||
continue
|
continue
|
||||||
default_style.update(style)
|
default_style.update(style)
|
||||||
|
|
||||||
|
last_begin_time = None
|
||||||
|
last_end_time = None
|
||||||
|
index_offset = 0
|
||||||
|
|
||||||
for para, index in zip(paras, itertools.count(1)):
|
for para, index in zip(paras, itertools.count(1)):
|
||||||
begin_time = parse_dfxp_time_expr(para.attrib.get('begin'))
|
begin_time = parse_dfxp_time_expr(para.attrib.get('begin'))
|
||||||
end_time = parse_dfxp_time_expr(para.attrib.get('end'))
|
end_time = parse_dfxp_time_expr(para.attrib.get('end'))
|
||||||
@ -2869,12 +2873,23 @@ def dfxp2srt(dfxp_data):
|
|||||||
if not dur:
|
if not dur:
|
||||||
continue
|
continue
|
||||||
end_time = begin_time + dur
|
end_time = begin_time + dur
|
||||||
out.append('%d\n%s --> %s\n%s\n\n' % (
|
|
||||||
index,
|
|
||||||
srt_subtitles_timecode(begin_time),
|
|
||||||
srt_subtitles_timecode(end_time),
|
|
||||||
parse_node(para)))
|
|
||||||
|
|
||||||
|
if begin_time == last_begin_time and end_time == last_end_time:
|
||||||
|
index_offset += 1
|
||||||
|
out.append('%s\n' % (parse_node(para)))
|
||||||
|
else:
|
||||||
|
if out:
|
||||||
|
out.append('\n')
|
||||||
|
out.append('%d\n%s --> %s\n%s\n' % (
|
||||||
|
index - index_offset,
|
||||||
|
srt_subtitles_timecode(begin_time),
|
||||||
|
srt_subtitles_timecode(end_time),
|
||||||
|
parse_node(para)))
|
||||||
|
|
||||||
|
last_begin_time = begin_time
|
||||||
|
last_end_time = end_time
|
||||||
|
|
||||||
|
out.append('\n')
|
||||||
return ''.join(out)
|
return ''.join(out)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user