mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 14:14:54 +01:00
[utils] Support 'dur' field in TTML
This commit is contained in:
parent
5332fd91bf
commit
7dff03636a
|
@ -600,7 +600,7 @@ def test_dfxp2srt(self):
|
||||||
<div xml:lang="en">
|
<div xml:lang="en">
|
||||||
<p begin="0" end="1">The following line contains Chinese characters and special symbols</p>
|
<p begin="0" end="1">The following line contains Chinese characters and special symbols</p>
|
||||||
<p begin="1" end="2">第二行<br/>♪♪</p>
|
<p begin="1" end="2">第二行<br/>♪♪</p>
|
||||||
<p begin="2" end="3"><span>Third<br/>Line</span></p>
|
<p begin="2" dur="1"><span>Third<br/>Line</span></p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</tt>'''
|
</tt>'''
|
||||||
|
|
|
@ -1866,10 +1866,14 @@ def parse_node(node):
|
||||||
paras = dfxp.findall(_x('.//ttml:p'))
|
paras = dfxp.findall(_x('.//ttml:p'))
|
||||||
|
|
||||||
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['begin'])
|
||||||
|
end_time = parse_dfxp_time_expr(para.attrib.get('end'))
|
||||||
|
if not end_time:
|
||||||
|
end_time = begin_time + parse_dfxp_time_expr(para.attrib['dur'])
|
||||||
out.append('%d\n%s --> %s\n%s\n\n' % (
|
out.append('%d\n%s --> %s\n%s\n\n' % (
|
||||||
index,
|
index,
|
||||||
format_srt_time(parse_dfxp_time_expr(para.attrib.get('begin'))),
|
format_srt_time(begin_time),
|
||||||
format_srt_time(parse_dfxp_time_expr(para.attrib.get('end'))),
|
format_srt_time(end_time),
|
||||||
parse_node(para)))
|
parse_node(para)))
|
||||||
|
|
||||||
return ''.join(out)
|
return ''.join(out)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user