]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from .kaltura import KalturaIE | |
3 | from .youtube import YoutubeIE | |
4 | from ..utils import ( | |
5 | determine_ext, | |
6 | int_or_none, | |
7 | NO_DEFAULT, | |
8 | parse_iso8601, | |
9 | smuggle_url, | |
10 | xpath_text, | |
11 | ) | |
12 | ||
13 | ||
14 | class HeiseIE(InfoExtractor): | |
15 | _VALID_URL = r'https?://(?:www\.)?heise\.de/(?:[^/]+/)+[^/]+-(?P<id>[0-9]+)\.html' | |
16 | _TESTS = [{ | |
17 | # kaltura embed | |
18 | 'url': 'http://www.heise.de/video/artikel/Podcast-c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2404147.html', | |
19 | 'info_dict': { | |
20 | 'id': '1_kkrq94sm', | |
21 | 'ext': 'mp4', | |
22 | 'title': "Podcast: c't uplink 3.3 – Owncloud / Tastaturen / Peilsender Smartphone", | |
23 | 'timestamp': 1512734959, | |
24 | 'upload_date': '20171208', | |
25 | 'description': 'md5:c934cbfb326c669c2bcabcbe3d3fcd20', | |
26 | }, | |
27 | 'params': { | |
28 | 'skip_download': True, | |
29 | }, | |
30 | }, { | |
31 | # YouTube embed | |
32 | 'url': 'http://www.heise.de/newsticker/meldung/Netflix-In-20-Jahren-vom-Videoverleih-zum-TV-Revolutionaer-3814130.html', | |
33 | 'md5': 'e403d2b43fea8e405e88e3f8623909f1', | |
34 | 'info_dict': { | |
35 | 'id': '6kmWbXleKW4', | |
36 | 'ext': 'mp4', | |
37 | 'title': 'NEU IM SEPTEMBER | Netflix', | |
38 | 'description': 'md5:2131f3c7525e540d5fd841de938bd452', | |
39 | 'upload_date': '20170830', | |
40 | 'uploader': 'Netflix Deutschland, Österreich und Schweiz', | |
41 | 'uploader_id': 'netflixdach', | |
42 | }, | |
43 | 'params': { | |
44 | 'skip_download': True, | |
45 | }, | |
46 | }, { | |
47 | 'url': 'https://www.heise.de/video/artikel/nachgehakt-Wie-sichert-das-c-t-Tool-Restric-tor-Windows-10-ab-3700244.html', | |
48 | 'info_dict': { | |
49 | 'id': '1_ntrmio2s', | |
50 | 'ext': 'mp4', | |
51 | 'title': "nachgehakt: Wie sichert das c't-Tool Restric'tor Windows 10 ab?", | |
52 | 'description': 'md5:47e8ffb6c46d85c92c310a512d6db271', | |
53 | 'timestamp': 1512470717, | |
54 | 'upload_date': '20171205', | |
55 | }, | |
56 | 'params': { | |
57 | 'skip_download': True, | |
58 | }, | |
59 | }, { | |
60 | 'url': 'https://www.heise.de/ct/artikel/c-t-uplink-20-8-Staubsaugerroboter-Xiaomi-Vacuum-2-AR-Brille-Meta-2-und-Android-rooten-3959893.html', | |
61 | 'info_dict': { | |
62 | 'id': '1_59mk80sf', | |
63 | 'ext': 'mp4', | |
64 | 'title': "c't uplink 20.8: Staubsaugerroboter Xiaomi Vacuum 2, AR-Brille Meta 2 und Android rooten", | |
65 | 'description': 'md5:f50fe044d3371ec73a8f79fcebd74afc', | |
66 | 'timestamp': 1517567237, | |
67 | 'upload_date': '20180202', | |
68 | }, | |
69 | 'params': { | |
70 | 'skip_download': True, | |
71 | }, | |
72 | }, { | |
73 | 'url': 'http://www.heise.de/ct/artikel/c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2403911.html', | |
74 | 'only_matching': True, | |
75 | }, { | |
76 | 'url': 'http://www.heise.de/newsticker/meldung/c-t-uplink-Owncloud-Tastaturen-Peilsender-Smartphone-2404251.html?wt_mc=rss.ho.beitrag.atom', | |
77 | 'only_matching': True, | |
78 | }, { | |
79 | 'url': 'http://www.heise.de/ct/ausgabe/2016-12-Spiele-3214137.html', | |
80 | 'only_matching': True, | |
81 | }] | |
82 | ||
83 | def _real_extract(self, url): | |
84 | video_id = self._match_id(url) | |
85 | webpage = self._download_webpage(url, video_id) | |
86 | ||
87 | def extract_title(default=NO_DEFAULT): | |
88 | title = self._html_search_meta( | |
89 | ('fulltitle', 'title'), webpage, default=None) | |
90 | if not title or title == "c't": | |
91 | title = self._search_regex( | |
92 | r'<div[^>]+class="videoplayerjw"[^>]+data-title="([^"]+)"', | |
93 | webpage, 'title', default=None) | |
94 | if not title: | |
95 | title = self._html_search_regex( | |
96 | r'<h1[^>]+\bclass=["\']article_page_title[^>]+>(.+?)<', | |
97 | webpage, 'title', default=default) | |
98 | return title | |
99 | ||
100 | title = extract_title(default=None) | |
101 | description = self._og_search_description( | |
102 | webpage, default=None) or self._html_search_meta( | |
103 | 'description', webpage) | |
104 | ||
105 | def _make_kaltura_result(kaltura_url): | |
106 | return { | |
107 | '_type': 'url_transparent', | |
108 | 'url': smuggle_url(kaltura_url, {'source_url': url}), | |
109 | 'ie_key': KalturaIE.ie_key(), | |
110 | 'title': title, | |
111 | 'description': description, | |
112 | } | |
113 | ||
114 | kaltura_url = KalturaIE._extract_url(webpage) | |
115 | if kaltura_url: | |
116 | return _make_kaltura_result(kaltura_url) | |
117 | ||
118 | kaltura_id = self._search_regex( | |
119 | r'entry-id=(["\'])(?P<id>(?:(?!\1).)+)\1', webpage, 'kaltura id', | |
120 | default=None, group='id') | |
121 | if kaltura_id: | |
122 | return _make_kaltura_result('kaltura:2238431:%s' % kaltura_id) | |
123 | ||
124 | yt_urls = YoutubeIE._extract_urls(webpage) | |
125 | if yt_urls: | |
126 | return self.playlist_from_matches( | |
127 | yt_urls, video_id, title, ie=YoutubeIE.ie_key()) | |
128 | ||
129 | title = extract_title() | |
130 | ||
131 | container_id = self._search_regex( | |
132 | r'<div class="videoplayerjw"[^>]+data-container="([0-9]+)"', | |
133 | webpage, 'container ID') | |
134 | ||
135 | sequenz_id = self._search_regex( | |
136 | r'<div class="videoplayerjw"[^>]+data-sequenz="([0-9]+)"', | |
137 | webpage, 'sequenz ID') | |
138 | ||
139 | doc = self._download_xml( | |
140 | 'http://www.heise.de/videout/feed', video_id, query={ | |
141 | 'container': container_id, | |
142 | 'sequenz': sequenz_id, | |
143 | }) | |
144 | ||
145 | formats = [] | |
146 | for source_node in doc.findall('.//{http://rss.jwpcdn.com/}source'): | |
147 | label = source_node.attrib['label'] | |
148 | height = int_or_none(self._search_regex( | |
149 | r'^(.*?_)?([0-9]+)p$', label, 'height', default=None)) | |
150 | video_url = source_node.attrib['file'] | |
151 | ext = determine_ext(video_url, '') | |
152 | formats.append({ | |
153 | 'url': video_url, | |
154 | 'format_note': label, | |
155 | 'format_id': '%s_%s' % (ext, label), | |
156 | 'height': height, | |
157 | }) | |
158 | self._sort_formats(formats) | |
159 | ||
160 | return { | |
161 | 'id': video_id, | |
162 | 'title': title, | |
163 | 'description': description, | |
164 | 'thumbnail': (xpath_text(doc, './/{http://rss.jwpcdn.com/}image') | |
165 | or self._og_search_thumbnail(webpage)), | |
166 | 'timestamp': parse_iso8601( | |
167 | self._html_search_meta('date', webpage)), | |
168 | 'formats': formats, | |
169 | } |