projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[nba] Fix duration extraction (fixes #5777)
[youtube-dl]
/
youtube_dl
/
utils.py
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index ed9ed9ed63ec9b40d929f83cb2e56ee4d63f9e7f..52d198fa3c2eb36a1a3d41620cd645b90d52f854 100644
(file)
--- a/
youtube_dl/utils.py
+++ b/
youtube_dl/utils.py
@@
-1665,6
+1665,7
@@
def mimetype2ext(mt):
return {
'x-ms-wmv': 'wmv',
'x-mp4-fragmented': 'mp4',
return {
'x-ms-wmv': 'wmv',
'x-mp4-fragmented': 'mp4',
+ 'ttml+xml': 'ttml',
}.get(res, res)
}.get(res, res)
@@
-1848,9
+1849,9
@@
def dfxp2srt(dfxp_data):
out = str_or_empty(node.text)
for child in node:
out = str_or_empty(node.text)
for child in node:
- if child.tag
== _x('ttml:
br'):
+ if child.tag
in (_x('ttml:br'), '
br'):
out += '\n' + str_or_empty(child.tail)
out += '\n' + str_or_empty(child.tail)
- elif child.tag
== _x('ttml:
span'):
+ elif child.tag
in (_x('ttml:span'), '
span'):
out += str_or_empty(parse_node(child))
else:
out += str_or_empty(xml.etree.ElementTree.tostring(child))
out += str_or_empty(parse_node(child))
else:
out += str_or_empty(xml.etree.ElementTree.tostring(child))
@@
-1859,7
+1860,10
@@
def dfxp2srt(dfxp_data):
dfxp = xml.etree.ElementTree.fromstring(dfxp_data.encode('utf-8'))
out = []
dfxp = xml.etree.ElementTree.fromstring(dfxp_data.encode('utf-8'))
out = []
- paras = dfxp.findall(_x('.//ttml:p'))
+ paras = dfxp.findall(_x('.//ttml:p')) or dfxp.findall('.//p')
+
+ if not paras:
+ raise ValueError('Invalid dfxp/TTML subtitle')
for para, index in zip(paras, itertools.count(1)):
begin_time = parse_dfxp_time_expr(para.attrib['begin'])
for para, index in zip(paras, itertools.count(1)):
begin_time = parse_dfxp_time_expr(para.attrib['begin'])