diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2015-05-12 12:47:37 +0800 |
---|---|---|
committer | Yen Chi Hsuan <yan12125@gmail.com> | 2015-05-12 12:47:37 +0800 |
commit | 7dff03636a843a6990e52200edb3ecca1246b3df (patch) | |
tree | 92f9fc995b4b806f0ad580da7f6fbd101d99d6f5 /youtube_dl/utils.py | |
parent | 5332fd91bf16867b6777bd6cfd0b5086f84112c5 (diff) |
[utils] Support 'dur' field in TTML
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index d73efcf25..5439fcb35 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1866,10 +1866,14 @@ def dfxp2srt(dfxp_data): paras = dfxp.findall(_x('.//ttml:p')) 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' % ( index, - format_srt_time(parse_dfxp_time_expr(para.attrib.get('begin'))), - format_srt_time(parse_dfxp_time_expr(para.attrib.get('end'))), + format_srt_time(begin_time), + format_srt_time(end_time), parse_node(para))) return ''.join(out) |