2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..compat import compat_urllib_parse_unquote
14 class NozIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?noz\.de/video/(?P<id>[0-9]+)/'
17 'url': 'http://www.noz.de/video/25151/32-Deutschland-gewinnt-Badminton-Lnderspiel-in-Melle',
22 'title': '3:2 - Deutschland gewinnt Badminton-Länderspiel in Melle',
23 'description': 'Vor rund 370 Zuschauern gewinnt die deutsche Badminton-Nationalmannschaft am Donnerstag ein EM-Vorbereitungsspiel gegen Frankreich in Melle. Video Moritz Frankenberg.',
24 'thumbnail': 're:^http://.*\.jpg',
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
30 webpage = self._download_webpage(url, video_id)
31 description = self._og_search_description(webpage)
33 edge_url = self._html_search_regex(
34 r'<script\s+(?:type="text/javascript"\s+)?src="(.*?/videojs_.*?)"',
36 edge_content = self._download_webpage(edge_url, 'meta configuration')
38 config_url_encoded = self._search_regex(
39 r'so\.addVariable\("config_url","[^,]*,(.*?)"',
40 edge_content, 'config URL'
42 config_url = compat_urllib_parse_unquote(config_url_encoded)
44 doc = self._download_xml(config_url, 'video configuration')
45 title = xpath_text(doc, './/title')
46 thumbnail = xpath_text(doc, './/article/thumbnail/url')
47 duration = int_or_none(xpath_text(
48 doc, './/article/movie/file/duration'))
50 for qnode in doc.findall('.//article/movie/file/qualities/qual'):
51 http_url_ele = find_xpath_attr(
52 qnode, './html_urls/video_url', 'format', 'video/mp4')
53 http_url = http_url_ele.text if http_url_ele is not None else None
57 'format_name': xpath_text(qnode, './name'),
58 'format_id': '%s-%s' % ('http', xpath_text(qnode, './id')),
59 'height': int_or_none(xpath_text(qnode, './height')),
60 'width': int_or_none(xpath_text(qnode, './width')),
61 'tbr': int_or_none(xpath_text(qnode, './bitrate'), scale=1000),
64 f4m_url = xpath_text(qnode, 'url_hd2')
66 formats.extend(self._extract_f4m_formats(
67 update_url_query(f4m_url, {'hdcore': '3.4.0'}),
68 video_id, f4m_id='hds', fatal=False))
69 m3u8_url_ele = find_xpath_attr(
70 qnode, './html_urls/video_url',
71 'format', 'application/vnd.apple.mpegurl')
72 m3u8_url = m3u8_url_ele.text if m3u8_url_ele is not None else None
74 formats.extend(self._extract_m3u8_formats(
75 m3u8_url, video_id, 'mp4', 'm3u8_native',
76 m3u8_id='hls', fatal=False))
77 self._sort_formats(formats)
84 'description': description,
85 'thumbnail': thumbnail,