2 from __future__ import unicode_literals
6 from .common import InfoExtractor
11 from .spiegeltv import SpiegeltvIE
12 from ..compat import compat_urlparse
20 class SpiegelIE(InfoExtractor):
21 _VALID_URL = r'https?://(?:www\.)?spiegel\.de/video/[^/]*-(?P<id>[0-9]+)(?:-embed|-iframe)?(?:\.html)?(?:#.*)?$'
23 'url': 'http://www.spiegel.de/video/vulkan-tungurahua-in-ecuador-ist-wieder-aktiv-video-1259285.html',
24 'md5': 'b57399839d055fccfeb9a0455c439868',
28 'title': 'Vulkanausbruch in Ecuador: Der "Feuerschlund" ist wieder aktiv',
29 'description': 'md5:8029d8310232196eb235d27575a8b9f4',
31 'upload_date': '20130311',
32 'timestamp': 1362994320,
35 'url': 'http://www.spiegel.de/video/schach-wm-videoanalyse-des-fuenften-spiels-video-1309159.html',
36 'md5': '5b6c2f4add9d62912ed5fc78a1faed80',
40 'title': 'Schach-WM in der Videoanalyse: Carlsen nutzt die Fehlgriffe des Titelverteidigers',
41 'description': 'md5:c2322b65e58f385a820c10fa03b2d088',
43 'upload_date': '20131115',
44 'timestamp': 1384546642,
47 'url': 'http://www.spiegel.de/video/astronaut-alexander-gerst-von-der-iss-station-beantwortet-fragen-video-1519126-embed.html',
48 'md5': '97b91083a672d72976faa8433430afb9',
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?"',
54 'upload_date': '20140904',
55 'timestamp': 1409834160,
58 'url': 'http://www.spiegel.de/video/astronaut-alexander-gerst-von-der-iss-station-beantwortet-fragen-video-1519126-iframe.html',
59 'only_matching': True,
62 'url': 'http://www.spiegel.de/video/spiegel-tv-magazin-ueber-guellekrise-in-schleswig-holstein-video-99012776.html',
63 'only_matching': True,
66 def _real_extract(self, url):
67 video_id = self._match_id(url)
68 metadata_url = 'http://www.spiegel.de/video/metadata/video-%s.json' % video_id
69 handle = self._request_webpage(metadata_url, video_id)
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')
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'
82 '_type': 'url_transparent',
84 'url': 'nexx:%s:%s' % (domain_id, nexx_id),
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(),
93 class SpiegelArticleIE(InfoExtractor):
94 _VALID_URL = r'https?://(?:www\.)?spiegel\.de/(?!video/)[^?#]*?-(?P<id>[0-9]+)\.html'
95 IE_NAME = 'Spiegel:Article'
96 IE_DESC = 'Articles on spiegel.de'
98 'url': 'http://www.spiegel.de/sport/sonst/badminton-wm-die-randsportart-soll-populaerer-werden-a-987092.html',
102 'title': 'Faszination Badminton: Nennt es bloß nicht Federball',
103 'description': 're:^Patrick Kämnitz gehört.{100,}',
104 'upload_date': '20140825',
107 'url': 'http://www.spiegel.de/wissenschaft/weltall/astronaut-alexander-gerst-antwortet-spiegel-online-lesern-a-989876.html',
114 'url': 'http://www.spiegel.de/sptv/spiegeltv/spiegel-tv-ueber-schnellste-katapult-achterbahn-der-welt-taron-a-1137884.html',
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$',
125 'timestamp': 1394021479,
126 'upload_date': '20140305',
129 'format': 'bestvideo',
130 'skip_download': True,
134 def _real_extract(self, url):
135 video_id = self._match_id(url)
136 webpage = self._download_webpage(url, video_id)
138 # Single video on top of the page
139 video_link = self._search_regex(
140 r'<a href="([^"]+)" onclick="return spOpenVideo\(this,', webpage,
141 'video page URL', default=None)
143 video_url = compat_urlparse.urljoin(
144 self.http_scheme() + '//spiegel.de/', video_link)
145 return self.url_result(video_url)
147 # Multiple embedded videos
149 r'<div class="vid_holder[0-9]+.*?</div>\s*.*?url\s*=\s*"([^"]+)"',
152 self.url_result(compat_urlparse.urljoin(
153 self.http_scheme() + '//spiegel.de/', embed_path))
154 for embed_path in embeds]
156 return self.playlist_result(entries)
158 return self.playlist_from_matches(
159 NexxEmbedIE._extract_urls(webpage), ie=NexxEmbedIE.ie_key())