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