mirror of
https://github.com/l1ving/youtube-dl
synced 2024-11-23 16:15:36 +08:00
[arte] Add support for multiple formats
This commit is contained in:
parent
515bbe4b5b
commit
878d11ec29
@ -21,7 +21,7 @@ from ..utils import (
|
|||||||
|
|
||||||
|
|
||||||
class ArteTvIE(InfoExtractor):
|
class ArteTvIE(InfoExtractor):
|
||||||
_VALID_URL = r'(?:http://)?videos\.arte\.tv/(?P<lang>fr|de)/.*-(?P<id>.*?)\.html'
|
_VALID_URL = r'http://videos\.arte\.tv/(?P<lang>fr|de)/.*-(?P<id>.*?)\.html'
|
||||||
IE_NAME = 'arte.tv'
|
IE_NAME = 'arte.tv'
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
@ -31,28 +31,24 @@ class ArteTvIE(InfoExtractor):
|
|||||||
ref_xml_url, video_id, note='Downloading metadata')
|
ref_xml_url, video_id, note='Downloading metadata')
|
||||||
config_node = find_xpath_attr(ref_xml_doc, './/video', 'lang', lang)
|
config_node = find_xpath_attr(ref_xml_doc, './/video', 'lang', lang)
|
||||||
config_xml_url = config_node.attrib['ref']
|
config_xml_url = config_node.attrib['ref']
|
||||||
config_xml = self._download_webpage(
|
config = self._download_xml(
|
||||||
config_xml_url, video_id, note='Downloading configuration')
|
config_xml_url, video_id, note='Downloading configuration')
|
||||||
|
|
||||||
video_urls = list(re.finditer(r'<url quality="(?P<quality>.*?)">(?P<url>.*?)</url>', config_xml))
|
formats = [{
|
||||||
def _key(m):
|
'forma_id': q.attrib['quality'],
|
||||||
quality = m.group('quality')
|
'url': q.text,
|
||||||
if quality == 'hd':
|
'quality': 2 if q.attrib['quality'] == 'hd' else 1,
|
||||||
return 2
|
} for q in config.findall('.//quality')]
|
||||||
else:
|
self._sort_formats(formats)
|
||||||
return 1
|
|
||||||
# We pick the best quality
|
title = config.find('.//name').text
|
||||||
video_urls = sorted(video_urls, key=_key)
|
thumbnail = config.find('.//firstThumbnailUrl').text
|
||||||
video_url = list(video_urls)[-1].group('url')
|
return {
|
||||||
|
'id': video_id,
|
||||||
title = self._html_search_regex(r'<name>(.*?)</name>', config_xml, 'title')
|
'title': title,
|
||||||
thumbnail = self._html_search_regex(r'<firstThumbnailUrl>(.*?)</firstThumbnailUrl>',
|
'thumbnail': thumbnail,
|
||||||
config_xml, 'thumbnail')
|
'url': video_url,
|
||||||
return {'id': video_id,
|
'ext': 'flv',
|
||||||
'title': title,
|
|
||||||
'thumbnail': thumbnail,
|
|
||||||
'url': video_url,
|
|
||||||
'ext': 'flv',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user