]>
Commit | Line | Data |
---|---|---|
dcdb292f | 1 | # coding: utf-8 |
4baff4a4 JMF |
2 | from __future__ import unicode_literals |
3 | ||
49f5f315 | 4 | import re |
49f5f315 PH |
5 | |
6 | from .common import InfoExtractor | |
4471affc S |
7 | from .nexx import ( |
8 | NexxIE, | |
9 | NexxEmbedIE, | |
10 | ) | |
2707b50f | 11 | from .spiegeltv import SpiegeltvIE |
252a1f75 RA |
12 | from ..compat import compat_urlparse |
13 | from ..utils import ( | |
a07879d6 RA |
14 | parse_duration, |
15 | strip_or_none, | |
16 | unified_timestamp, | |
252a1f75 | 17 | ) |
49f5f315 PH |
18 | |
19 | ||
20 | class SpiegelIE(InfoExtractor): | |
aeb7b41d | 21 | _VALID_URL = r'https?://(?:www\.)?spiegel\.de/video/[^/]*-(?P<id>[0-9]+)(?:-embed|-iframe)?(?:\.html)?(?:#.*)?$' |
7150858d | 22 | _TESTS = [{ |
4baff4a4 | 23 | 'url': 'http://www.spiegel.de/video/vulkan-tungurahua-in-ecuador-ist-wieder-aktiv-video-1259285.html', |
a07879d6 | 24 | 'md5': 'b57399839d055fccfeb9a0455c439868', |
4baff4a4 | 25 | 'info_dict': { |
a07879d6 | 26 | 'id': '563747', |
55c97a03 | 27 | 'ext': 'mp4', |
4baff4a4 | 28 | 'title': 'Vulkanausbruch in Ecuador: Der "Feuerschlund" ist wieder aktiv', |
55c97a03 S |
29 | 'description': 'md5:8029d8310232196eb235d27575a8b9f4', |
30 | 'duration': 49, | |
252a1f75 | 31 | 'upload_date': '20130311', |
a07879d6 | 32 | 'timestamp': 1362994320, |
4baff4a4 | 33 | }, |
55c97a03 | 34 | }, { |
4baff4a4 | 35 | 'url': 'http://www.spiegel.de/video/schach-wm-videoanalyse-des-fuenften-spiels-video-1309159.html', |
a07879d6 | 36 | 'md5': '5b6c2f4add9d62912ed5fc78a1faed80', |
4baff4a4 | 37 | 'info_dict': { |
a07879d6 | 38 | 'id': '580988', |
55c97a03 | 39 | 'ext': 'mp4', |
4baff4a4 | 40 | 'title': 'Schach-WM in der Videoanalyse: Carlsen nutzt die Fehlgriffe des Titelverteidigers', |
55c97a03 S |
41 | 'description': 'md5:c2322b65e58f385a820c10fa03b2d088', |
42 | 'duration': 983, | |
252a1f75 | 43 | 'upload_date': '20131115', |
a07879d6 | 44 | 'timestamp': 1384546642, |
55c97a03 | 45 | }, |
e4bdb37e PH |
46 | }, { |
47 | 'url': 'http://www.spiegel.de/video/astronaut-alexander-gerst-von-der-iss-station-beantwortet-fragen-video-1519126-embed.html', | |
a07879d6 | 48 | 'md5': '97b91083a672d72976faa8433430afb9', |
e4bdb37e | 49 | 'info_dict': { |
a07879d6 | 50 | 'id': '601883', |
e4bdb37e PH |
51 | 'ext': 'mp4', |
52 | 'description': 'SPIEGEL ONLINE-Nutzer durften den deutschen Astronauten Alexander Gerst über sein Leben auf der ISS-Station befragen. Hier kommen seine Antworten auf die besten sechs Fragen.', | |
53 | 'title': 'Fragen an Astronaut Alexander Gerst: "Bekommen Sie die Tageszeiten mit?"', | |
252a1f75 | 54 | 'upload_date': '20140904', |
a07879d6 | 55 | 'timestamp': 1409834160, |
e4bdb37e | 56 | } |
aeb7b41d | 57 | }, { |
58 | 'url': 'http://www.spiegel.de/video/astronaut-alexander-gerst-von-der-iss-station-beantwortet-fragen-video-1519126-iframe.html', | |
59 | 'only_matching': True, | |
4471affc S |
60 | }, { |
61 | # nexx video | |
62 | 'url': 'http://www.spiegel.de/video/spiegel-tv-magazin-ueber-guellekrise-in-schleswig-holstein-video-99012776.html', | |
63 | 'only_matching': True, | |
7150858d | 64 | }] |
49f5f315 PH |
65 | |
66 | def _real_extract(self, url): | |
0e15e725 | 67 | video_id = self._match_id(url) |
a07879d6 RA |
68 | metadata_url = 'http://www.spiegel.de/video/metadata/video-%s.json' % video_id |
69 | handle = self._request_webpage(metadata_url, video_id) | |
2707b50f PH |
70 | |
71 | # 302 to spiegel.tv, like http://www.spiegel.de/video/der-film-zum-wochenende-die-wahrheit-ueber-maenner-video-99003272.html | |
72 | if SpiegeltvIE.suitable(handle.geturl()): | |
73 | return self.url_result(handle.geturl(), 'Spiegeltv') | |
49f5f315 | 74 | |
a07879d6 RA |
75 | video_data = self._parse_json(self._webpage_read_content( |
76 | handle, metadata_url, video_id), video_id) | |
77 | title = video_data['title'] | |
78 | nexx_id = video_data['nexxOmniaId'] | |
79 | domain_id = video_data.get('nexxOmniaDomain') or '748' | |
e6812ac9 | 80 | |
4baff4a4 | 81 | return { |
a07879d6 | 82 | '_type': 'url_transparent', |
49f5f315 | 83 | 'id': video_id, |
a07879d6 | 84 | 'url': 'nexx:%s:%s' % (domain_id, nexx_id), |
55c97a03 | 85 | 'title': title, |
a07879d6 RA |
86 | 'description': strip_or_none(video_data.get('teaser')), |
87 | 'duration': parse_duration(video_data.get('duration')), | |
88 | 'timestamp': unified_timestamp(video_data.get('datum')), | |
89 | 'ie_key': NexxIE.ie_key(), | |
49f5f315 | 90 | } |
89fb6a97 PH |
91 | |
92 | ||
93 | class SpiegelArticleIE(InfoExtractor): | |
92519402 | 94 | _VALID_URL = r'https?://(?:www\.)?spiegel\.de/(?!video/)[^?#]*?-(?P<id>[0-9]+)\.html' |
89fb6a97 PH |
95 | IE_NAME = 'Spiegel:Article' |
96 | IE_DESC = 'Articles on spiegel.de' | |
e4bdb37e | 97 | _TESTS = [{ |
89fb6a97 PH |
98 | 'url': 'http://www.spiegel.de/sport/sonst/badminton-wm-die-randsportart-soll-populaerer-werden-a-987092.html', |
99 | 'info_dict': { | |
100 | 'id': '1516455', | |
101 | 'ext': 'mp4', | |
102 | 'title': 'Faszination Badminton: Nennt es bloß nicht Federball', | |
103 | 'description': 're:^Patrick Kämnitz gehört.{100,}', | |
001fffd0 | 104 | 'upload_date': '20140825', |
89fb6a97 | 105 | }, |
e4bdb37e PH |
106 | }, { |
107 | 'url': 'http://www.spiegel.de/wissenschaft/weltall/astronaut-alexander-gerst-antwortet-spiegel-online-lesern-a-989876.html', | |
108 | 'info_dict': { | |
109 | ||
110 | }, | |
111 | 'playlist_count': 6, | |
bb176df3 S |
112 | }, { |
113 | # Nexx iFrame embed | |
114 | 'url': 'http://www.spiegel.de/sptv/spiegeltv/spiegel-tv-ueber-schnellste-katapult-achterbahn-der-welt-taron-a-1137884.html', | |
115 | 'info_dict': { | |
116 | 'id': '161464', | |
117 | 'ext': 'mp4', | |
118 | 'title': 'Nervenkitzel Achterbahn', | |
119 | 'alt_title': 'Karussellbauer in Deutschland', | |
120 | 'description': 'md5:ffe7b1cc59a01f585e0569949aef73cc', | |
121 | 'release_year': 2005, | |
122 | 'creator': 'SPIEGEL TV', | |
123 | 'thumbnail': r're:^https?://.*\.jpg$', | |
124 | 'duration': 2761, | |
125 | 'timestamp': 1394021479, | |
126 | 'upload_date': '20140305', | |
127 | }, | |
128 | 'params': { | |
129 | 'format': 'bestvideo', | |
130 | 'skip_download': True, | |
131 | }, | |
e4bdb37e | 132 | }] |
89fb6a97 PH |
133 | |
134 | def _real_extract(self, url): | |
0e15e725 | 135 | video_id = self._match_id(url) |
89fb6a97 | 136 | webpage = self._download_webpage(url, video_id) |
e4bdb37e PH |
137 | |
138 | # Single video on top of the page | |
89fb6a97 PH |
139 | video_link = self._search_regex( |
140 | r'<a href="([^"]+)" onclick="return spOpenVideo\(this,', webpage, | |
e4bdb37e PH |
141 | 'video page URL', default=None) |
142 | if video_link: | |
143 | video_url = compat_urlparse.urljoin( | |
144 | self.http_scheme() + '//spiegel.de/', video_link) | |
145 | return self.url_result(video_url) | |
146 | ||
147 | # Multiple embedded videos | |
148 | embeds = re.findall( | |
149 | r'<div class="vid_holder[0-9]+.*?</div>\s*.*?url\s*=\s*"([^"]+)"', | |
150 | webpage) | |
151 | entries = [ | |
152 | self.url_result(compat_urlparse.urljoin( | |
153 | self.http_scheme() + '//spiegel.de/', embed_path)) | |
00d06e3c S |
154 | for embed_path in embeds] |
155 | if embeds: | |
156 | return self.playlist_result(entries) | |
157 | ||
158 | return self.playlist_from_matches( | |
159 | NexxEmbedIE._extract_urls(webpage), ie=NexxEmbedIE.ie_key()) |