]>
Commit | Line | Data |
---|---|---|
0155549d | 1 | from .common import InfoExtractor |
6202f08e | 2 | from .kaltura import KalturaIE |
4d8c4b46 | 3 | from .youtube import YoutubeIE |
0155549d | 4 | from ..utils import ( |
711ede6e | 5 | determine_ext, |
ecfe6234 | 6 | int_or_none, |
8e70c1bf | 7 | NO_DEFAULT, |
0155549d | 8 | parse_iso8601, |
6202f08e | 9 | smuggle_url, |
bad4ccdb | 10 | xpath_text, |
0155549d M |
11 | ) |
12 | ||
13 | ||
14 | class HeiseIE(InfoExtractor): | |
bad4ccdb S |
15 | _VALID_URL = r'https?://(?:www\.)?heise\.de/(?:[^/]+/)+[^/]+-(?P<id>[0-9]+)\.html' |
16 | _TESTS = [{ | |
8e70c1bf | 17 | # kaltura embed |
bad4ccdb | 18 | 'url': 'http://www.heise.de/video/artikel/Podcast-c-t-uplink-3-3-Owncloud-Tastaturen-Peilsender-Smartphone-2404147.html', |
bad4ccdb | 19 | 'info_dict': { |
8e70c1bf | 20 | 'id': '1_kkrq94sm', |
bad4ccdb S |
21 | 'ext': 'mp4', |
22 | 'title': "Podcast: c't uplink 3.3 – Owncloud / Tastaturen / Peilsender Smartphone", | |
8e70c1bf S |
23 | 'timestamp': 1512734959, |
24 | 'upload_date': '20171208', | |
bad4ccdb | 25 | 'description': 'md5:c934cbfb326c669c2bcabcbe3d3fcd20', |
8e70c1bf S |
26 | }, |
27 | 'params': { | |
28 | 'skip_download': True, | |
29 | }, | |
4d8c4b46 | 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 | }, | |
6202f08e | 46 | }, { |
47 | 'url': 'https://www.heise.de/video/artikel/nachgehakt-Wie-sichert-das-c-t-Tool-Restric-tor-Windows-10-ab-3700244.html', | |
6202f08e | 48 | 'info_dict': { |
49 | 'id': '1_ntrmio2s', | |
8e70c1bf S |
50 | 'ext': 'mp4', |
51 | 'title': "nachgehakt: Wie sichert das c't-Tool Restric'tor Windows 10 ab?", | |
52 | 'description': 'md5:47e8ffb6c46d85c92c310a512d6db271', | |
6202f08e | 53 | 'timestamp': 1512470717, |
54 | 'upload_date': '20171205', | |
8e70c1bf S |
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', | |
6202f08e | 63 | 'ext': 'mp4', |
8e70c1bf S |
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', | |
6202f08e | 68 | }, |
69 | 'params': { | |
70 | 'skip_download': True, | |
71 | }, | |
bad4ccdb S |
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 | }] | |
0155549d | 82 | |
0155549d | 83 | def _real_extract(self, url): |
5a8b7755 | 84 | video_id = self._match_id(url) |
5a8b7755 | 85 | webpage = self._download_webpage(url, video_id) |
ecfe6234 | 86 | |
8e70c1bf S |
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 | |
4d8c4b46 | 99 | |
8e70c1bf S |
100 | title = extract_title(default=None) |
101 | description = self._og_search_description( | |
102 | webpage, default=None) or self._html_search_meta( | |
103 | 'description', webpage) | |
4d8c4b46 | 104 | |
cb3e4a29 | 105 | def _make_kaltura_result(kaltura_url): |
8e70c1bf S |
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 | ||
cb3e4a29 S |
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 | ||
43aebb7d | 124 | yt_urls = tuple(YoutubeIE._extract_embed_urls(url, webpage)) |
8e70c1bf S |
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() | |
6202f08e | 130 | |
ecfe6234 | 131 | container_id = self._search_regex( |
bad4ccdb | 132 | r'<div class="videoplayerjw"[^>]+data-container="([0-9]+)"', |
ecfe6234 | 133 | webpage, 'container ID') |
6202f08e | 134 | |
ecfe6234 | 135 | sequenz_id = self._search_regex( |
bad4ccdb | 136 | r'<div class="videoplayerjw"[^>]+data-sequenz="([0-9]+)"', |
ecfe6234 | 137 | webpage, 'sequenz ID') |
0155549d | 138 | |
bad4ccdb S |
139 | doc = self._download_xml( |
140 | 'http://www.heise.de/videout/feed', video_id, query={ | |
141 | 'container': container_id, | |
142 | 'sequenz': sequenz_id, | |
143 | }) | |
0155549d M |
144 | |
145 | formats = [] | |
ecfe6234 PH |
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)) | |
711ede6e PH |
150 | video_url = source_node.attrib['file'] |
151 | ext = determine_ext(video_url, '') | |
ecfe6234 | 152 | formats.append({ |
711ede6e | 153 | 'url': video_url, |
ecfe6234 | 154 | 'format_note': label, |
711ede6e | 155 | 'format_id': '%s_%s' % (ext, label), |
ecfe6234 PH |
156 | 'height': height, |
157 | }) | |
0155549d | 158 | self._sort_formats(formats) |
0155549d | 159 | |
bad4ccdb S |
160 | return { |
161 | 'id': video_id, | |
162 | 'title': title, | |
163 | 'description': description, | |
3089bc74 S |
164 | 'thumbnail': (xpath_text(doc, './/{http://rss.jwpcdn.com/}image') |
165 | or self._og_search_thumbnail(webpage)), | |
bad4ccdb S |
166 | 'timestamp': parse_iso8601( |
167 | self._html_search_meta('date', webpage)), | |
168 | 'formats': formats, | |
169 | } |