Merge 582e1d10e7
into d65d89183f
This commit is contained in:
commit
3081a00e93
|
@ -1263,18 +1263,15 @@ The first line
|
|||
srt_data = '''1
|
||||
00:00:02,080 --> 00:00:05,839
|
||||
<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
|
||||
</font>part 2</font></b>
|
||||
|
||||
3
|
||||
2
|
||||
00:00:05,839 --> 00:00:09,560
|
||||
<u><font color="lime">line 3
|
||||
part 3</font></u>
|
||||
|
||||
4
|
||||
3
|
||||
00:00:09,560 --> 00:00:12,359
|
||||
<i><u><font color="yellow"><font color="lime">inner
|
||||
</font>style</font></u></i>
|
||||
|
|
|
@ -4560,6 +4560,10 @@ def dfxp2srt(dfxp_data):
|
|||
continue
|
||||
default_style.update(style)
|
||||
|
||||
last_begin_time = None
|
||||
last_end_time = None
|
||||
index_offset = 0
|
||||
|
||||
for para, index in zip(paras, itertools.count(1)):
|
||||
begin_time = parse_dfxp_time_expr(para.attrib.get('begin'))
|
||||
end_time = parse_dfxp_time_expr(para.attrib.get('end'))
|
||||
|
@ -4570,12 +4574,23 @@ def dfxp2srt(dfxp_data):
|
|||
if not dur:
|
||||
continue
|
||||
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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue