]>
Commit | Line | Data |
---|---|---|
a517bb4b | 1 | from .common import InfoExtractor |
a517bb4b PH |
2 | from ..utils import ( |
3 | int_or_none, | |
0c9ff240 | 4 | find_xpath_attr, |
a517bb4b | 5 | xpath_text, |
cf6cd073 | 6 | update_url_query, |
a517bb4b | 7 | ) |
f8271158 | 8 | from ..compat import compat_urllib_parse_unquote |
a517bb4b PH |
9 | |
10 | ||
11 | class NozIE(InfoExtractor): | |
12 | _VALID_URL = r'https?://(?:www\.)?noz\.de/video/(?P<id>[0-9]+)/' | |
13 | _TESTS = [{ | |
14 | 'url': 'http://www.noz.de/video/25151/32-Deutschland-gewinnt-Badminton-Lnderspiel-in-Melle', | |
15 | 'info_dict': { | |
16 | 'id': '25151', | |
17 | 'ext': 'mp4', | |
18 | 'duration': 215, | |
19 | 'title': '3:2 - Deutschland gewinnt Badminton-Länderspiel in Melle', | |
20 | 'description': 'Vor rund 370 Zuschauern gewinnt die deutsche Badminton-Nationalmannschaft am Donnerstag ein EM-Vorbereitungsspiel gegen Frankreich in Melle. Video Moritz Frankenberg.', | |
ec85ded8 | 21 | 'thumbnail': r're:^http://.*\.jpg', |
a517bb4b PH |
22 | }, |
23 | }] | |
24 | ||
25 | def _real_extract(self, url): | |
26 | video_id = self._match_id(url) | |
27 | webpage = self._download_webpage(url, video_id) | |
28 | description = self._og_search_description(webpage) | |
29 | ||
30 | edge_url = self._html_search_regex( | |
31 | r'<script\s+(?:type="text/javascript"\s+)?src="(.*?/videojs_.*?)"', | |
32 | webpage, 'edge URL') | |
33 | edge_content = self._download_webpage(edge_url, 'meta configuration') | |
34 | ||
35 | config_url_encoded = self._search_regex( | |
36 | r'so\.addVariable\("config_url","[^,]*,(.*?)"', | |
37 | edge_content, 'config URL' | |
38 | ) | |
39 | config_url = compat_urllib_parse_unquote(config_url_encoded) | |
40 | ||
41 | doc = self._download_xml(config_url, 'video configuration') | |
42 | title = xpath_text(doc, './/title') | |
43 | thumbnail = xpath_text(doc, './/article/thumbnail/url') | |
44 | duration = int_or_none(xpath_text( | |
45 | doc, './/article/movie/file/duration')) | |
46 | formats = [] | |
f9934b96 | 47 | for qnode in doc.findall('.//article/movie/file/qualities/qual'): |
0c9ff240 | 48 | http_url_ele = find_xpath_attr( |
49 | qnode, './html_urls/video_url', 'format', 'video/mp4') | |
50 | http_url = http_url_ele.text if http_url_ele is not None else None | |
cf6cd073 | 51 | if http_url: |
52 | formats.append({ | |
53 | 'url': http_url, | |
54 | 'format_name': xpath_text(qnode, './name'), | |
55 | 'format_id': '%s-%s' % ('http', xpath_text(qnode, './id')), | |
56 | 'height': int_or_none(xpath_text(qnode, './height')), | |
57 | 'width': int_or_none(xpath_text(qnode, './width')), | |
58 | 'tbr': int_or_none(xpath_text(qnode, './bitrate'), scale=1000), | |
59 | }) | |
60 | else: | |
61 | f4m_url = xpath_text(qnode, 'url_hd2') | |
62 | if f4m_url: | |
63 | formats.extend(self._extract_f4m_formats( | |
64 | update_url_query(f4m_url, {'hdcore': '3.4.0'}), | |
65 | video_id, f4m_id='hds', fatal=False)) | |
0c9ff240 | 66 | m3u8_url_ele = find_xpath_attr( |
67 | qnode, './html_urls/video_url', | |
68 | 'format', 'application/vnd.apple.mpegurl') | |
69 | m3u8_url = m3u8_url_ele.text if m3u8_url_ele is not None else None | |
cf6cd073 | 70 | if m3u8_url: |
71 | formats.extend(self._extract_m3u8_formats( | |
72 | m3u8_url, video_id, 'mp4', 'm3u8_native', | |
73 | m3u8_id='hls', fatal=False)) | |
a517bb4b PH |
74 | self._sort_formats(formats) |
75 | ||
76 | return { | |
77 | 'id': video_id, | |
78 | 'formats': formats, | |
79 | 'title': title, | |
80 | 'duration': duration, | |
81 | 'description': description, | |
82 | 'thumbnail': thumbnail, | |
83 | } |