[utils] Support TTML without default namespace
In a strict sense such TTML is invalid, but Yahoo uses it.
This commit is contained in:
parent
2aa64b89b3
commit
1b0427e6c4
2 changed files with 21 additions and 3 deletions
|
@ -1848,9 +1848,9 @@ def dfxp2srt(dfxp_data):
|
|||
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)
|
||||
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))
|
||||
|
@ -1859,7 +1859,10 @@ def dfxp2srt(dfxp_data):
|
|||
|
||||
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'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue