mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-01-21 02:40:10 +09:00
[atresplayer] fix subtitles URL lookup for some videos
This commit is contained in:
parent
4a47be85cd
commit
265b7ec6e9
@ -11,6 +11,7 @@ from ..utils import (
|
|||||||
int_or_none,
|
int_or_none,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
urljoin,
|
urljoin,
|
||||||
|
xpath_element,
|
||||||
xpath_text,
|
xpath_text,
|
||||||
xpath_with_ns,
|
xpath_with_ns,
|
||||||
)
|
)
|
||||||
@ -87,16 +88,19 @@ class AtresPlayerIE(InfoExtractor):
|
|||||||
'mpd': 'urn:mpeg:dash:schema:mpd:2011'
|
'mpd': 'urn:mpeg:dash:schema:mpd:2011'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def _is_mime_type(node, mime_type):
|
||||||
|
return node.attrib.get('mimeType') == mime_type
|
||||||
|
|
||||||
text_nodes = mpd_xml.findall(
|
text_nodes = mpd_xml.findall(
|
||||||
_add_ns('./mpd:Period/mpd:AdaptationSet[@contentType="text"]'))
|
_add_ns('mpd:Period/mpd:AdaptationSet[@contentType="text"]'))
|
||||||
for node in text_nodes:
|
for adaptation_set in text_nodes:
|
||||||
lang = node.attrib['lang']
|
lang = adaptation_set.attrib['lang']
|
||||||
url = xpath_text(
|
representation = xpath_element(adaptation_set, _add_ns('mpd:Representation'))
|
||||||
node, _add_ns('./mpd:Representation[@mimeType="text/vtt"]/mpd:BaseURL'))
|
subs_url = xpath_text(representation, _add_ns('mpd:BaseURL'))
|
||||||
if url:
|
if subs_url and (_is_mime_type(adaptation_set, 'text/vtt') or _is_mime_type(representation, 'text/vtt')):
|
||||||
subs.update({lang: [{
|
subs.update({lang: [{
|
||||||
'ext': 'vtt',
|
'ext': 'vtt',
|
||||||
'url': urljoin(mpd_url, url),
|
'url': urljoin(mpd_url, subs_url),
|
||||||
}]})
|
}]})
|
||||||
return subs
|
return subs
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user