mirror of
https://github.com/l1ving/youtube-dl
synced 2025-03-14 07:37:25 +08:00
Merge branch 'ttmlfix'
This commit is contained in:
commit
24775c395d
@ -1196,18 +1196,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>
|
||||
|
@ -2859,6 +2859,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'))
|
||||
@ -2869,12 +2873,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…
x
Reference in New Issue
Block a user