-class ArteTvIE(InfoExtractor):
- _VALID_URL = r'http://videos\.arte\.tv/(?P<lang>fr|de)/.*-(?P<id>.*?)\.html'
- IE_NAME = 'arte.tv'
-
- def _real_extract(self, url):
- mobj = re.match(self._VALID_URL, url)
- lang = mobj.group('lang')
- video_id = mobj.group('id')
-
- ref_xml_url = url.replace('/videos/', '/do_delegate/videos/')
- ref_xml_url = ref_xml_url.replace('.html', ',view,asPlayerXml.xml')
- ref_xml_doc = self._download_xml(
- ref_xml_url, video_id, note='Downloading metadata')
- config_node = find_xpath_attr(ref_xml_doc, './/video', 'lang', lang)
- config_xml_url = config_node.attrib['ref']
- config = self._download_xml(
- config_xml_url, video_id, note='Downloading configuration')
-
- formats = [{
- 'format_id': q.attrib['quality'],
- # The playpath starts at 'mp4:', if we don't manually
- # split the url, rtmpdump will incorrectly parse them
- 'url': q.text.split('mp4:', 1)[0],
- 'play_path': 'mp4:' + q.text.split('mp4:', 1)[1],
- 'ext': 'flv',
- 'quality': 2 if q.attrib['quality'] == 'hd' else 1,
- } for q in config.findall('./urls/url')]
- self._sort_formats(formats)
-
- title = config.find('.//name').text
- thumbnail = config.find('.//firstThumbnailUrl').text
- return {
- 'id': video_id,
- 'title': title,
- 'thumbnail': thumbnail,
- 'formats': formats,
- }
-
-
-class ArteTVPlus7IE(InfoExtractor):
- IE_NAME = 'arte.tv:+7'
- _VALID_URL = r'https?://(?:www\.)?arte\.tv/guide/(?P<lang>fr|de)/(?:(?:sendungen|emissions)/)?(?P<id>.*?)/(?P<name>.*?)(\?.*)?'
-
- @classmethod
- def _extract_url_info(cls, url):
- mobj = re.match(cls._VALID_URL, url)
- lang = mobj.group('lang')
- # This is not a real id, it can be for example AJT for the news
- # http://www.arte.tv/guide/fr/emissions/AJT/arte-journal
- video_id = mobj.group('id')
- return video_id, lang
-
- def _real_extract(self, url):
- video_id, lang = self._extract_url_info(url)
- webpage = self._download_webpage(url, video_id)
- return self._extract_from_webpage(webpage, video_id, lang)
-
- def _extract_from_webpage(self, webpage, video_id, lang):
- json_url = self._html_search_regex(
- [r'arte_vp_url=["\'](.*?)["\']', r'data-url=["\']([^"]+)["\']'],
- webpage, 'json vp url', default=None)
- if not json_url:
- iframe_url = self._html_search_regex(
- r'<iframe[^>]+src=(["\'])(?P<url>.+\bjson_url=.+?)\1',
- webpage, 'iframe url', group='url')
- json_url = compat_parse_qs(
- compat_urllib_parse_urlparse(iframe_url).query)['json_url'][0]
- return self._extract_from_json_url(json_url, video_id, lang)
-
- def _extract_from_json_url(self, json_url, video_id, lang):