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