2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from .nexx import NexxEmbedIE
8 from .spiegeltv import SpiegeltvIE
9 from ..compat import compat_urlparse
13 get_element_by_attribute,
17 class SpiegelIE(InfoExtractor):
18 _VALID_URL = r'https?://(?:www\.)?spiegel\.de/video/[^/]*-(?P<id>[0-9]+)(?:-embed|-iframe)?(?:\.html)?(?:#.*)?$'
20 'url': 'http://www.spiegel.de/video/vulkan-tungurahua-in-ecuador-ist-wieder-aktiv-video-1259285.html',
21 'md5': '2c2754212136f35fb4b19767d242f66e',
25 'title': 'Vulkanausbruch in Ecuador: Der "Feuerschlund" ist wieder aktiv',
26 'description': 'md5:8029d8310232196eb235d27575a8b9f4',
28 'upload_date': '20130311',
31 'url': 'http://www.spiegel.de/video/schach-wm-videoanalyse-des-fuenften-spiels-video-1309159.html',
32 'md5': 'f2cdf638d7aa47654e251e1aee360af1',
36 'title': 'Schach-WM in der Videoanalyse: Carlsen nutzt die Fehlgriffe des Titelverteidigers',
37 'description': 'md5:c2322b65e58f385a820c10fa03b2d088',
39 'upload_date': '20131115',
42 'url': 'http://www.spiegel.de/video/astronaut-alexander-gerst-von-der-iss-station-beantwortet-fragen-video-1519126-embed.html',
43 'md5': 'd8eeca6bfc8f1cd6f490eb1f44695d51',
47 '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.',
48 'title': 'Fragen an Astronaut Alexander Gerst: "Bekommen Sie die Tageszeiten mit?"',
49 'upload_date': '20140904',
52 'url': 'http://www.spiegel.de/video/astronaut-alexander-gerst-von-der-iss-station-beantwortet-fragen-video-1519126-iframe.html',
53 'only_matching': True,
56 def _real_extract(self, url):
57 video_id = self._match_id(url)
58 webpage, handle = self._download_webpage_handle(url, video_id)
60 # 302 to spiegel.tv, like http://www.spiegel.de/video/der-film-zum-wochenende-die-wahrheit-ueber-maenner-video-99003272.html
61 if SpiegeltvIE.suitable(handle.geturl()):
62 return self.url_result(handle.geturl(), 'Spiegeltv')
64 video_data = extract_attributes(self._search_regex(r'(<div[^>]+id="spVideoElements"[^>]+>)', webpage, 'video element', default=''))
66 title = video_data.get('data-video-title') or get_element_by_attribute('class', 'module-title', webpage)
67 description = video_data.get('data-video-teaser') or self._html_search_meta('description', webpage, 'description')
69 base_url = self._search_regex(
70 [r'server\s*:\s*(["\'])(?P<url>.+?)\1', r'var\s+server\s*=\s*"(?P<url>[^"]+)\"'],
71 webpage, 'server URL', group='url')
73 xml_url = base_url + video_id + '.xml'
74 idoc = self._download_xml(xml_url, video_id)
78 if n.tag.startswith('type') and n.tag != 'type6':
79 format_id = n.tag.rpartition('type')[2]
80 video_url = base_url + n.find('./filename').text
82 'format_id': format_id,
84 'width': int(n.find('./width').text),
85 'height': int(n.find('./height').text),
86 'abr': int(n.find('./audiobitrate').text),
87 'vbr': int(n.find('./videobitrate').text),
88 'vcodec': n.find('./codec').text,
91 duration = float(idoc[0].findall('./duration')[0].text)
93 self._check_formats(formats, video_id)
94 self._sort_formats(formats)
99 'description': description.strip() if description else None,
100 'duration': duration,
101 'upload_date': unified_strdate(video_data.get('data-video-date')),
106 class SpiegelArticleIE(InfoExtractor):
107 _VALID_URL = r'https?://(?:www\.)?spiegel\.de/(?!video/)[^?#]*?-(?P<id>[0-9]+)\.html'
108 IE_NAME = 'Spiegel:Article'
109 IE_DESC = 'Articles on spiegel.de'
111 'url': 'http://www.spiegel.de/sport/sonst/badminton-wm-die-randsportart-soll-populaerer-werden-a-987092.html',
115 'title': 'Faszination Badminton: Nennt es bloß nicht Federball',
116 'description': 're:^Patrick Kämnitz gehört.{100,}',
117 'upload_date': '20140825',
120 'url': 'http://www.spiegel.de/wissenschaft/weltall/astronaut-alexander-gerst-antwortet-spiegel-online-lesern-a-989876.html',
127 'url': 'http://www.spiegel.de/sptv/spiegeltv/spiegel-tv-ueber-schnellste-katapult-achterbahn-der-welt-taron-a-1137884.html',
131 'title': 'Nervenkitzel Achterbahn',
132 'alt_title': 'Karussellbauer in Deutschland',
133 'description': 'md5:ffe7b1cc59a01f585e0569949aef73cc',
134 'release_year': 2005,
135 'creator': 'SPIEGEL TV',
136 'thumbnail': r're:^https?://.*\.jpg$',
138 'timestamp': 1394021479,
139 'upload_date': '20140305',
142 'format': 'bestvideo',
143 'skip_download': True,
147 def _real_extract(self, url):
148 video_id = self._match_id(url)
149 webpage = self._download_webpage(url, video_id)
151 # Single video on top of the page
152 video_link = self._search_regex(
153 r'<a href="([^"]+)" onclick="return spOpenVideo\(this,', webpage,
154 'video page URL', default=None)
156 video_url = compat_urlparse.urljoin(
157 self.http_scheme() + '//spiegel.de/', video_link)
158 return self.url_result(video_url)
160 # Multiple embedded videos
162 r'<div class="vid_holder[0-9]+.*?</div>\s*.*?url\s*=\s*"([^"]+)"',
165 self.url_result(compat_urlparse.urljoin(
166 self.http_scheme() + '//spiegel.de/', embed_path))
167 for embed_path in embeds]
169 return self.playlist_result(entries)
171 return self.playlist_from_matches(
172 NexxEmbedIE._extract_urls(webpage), ie=NexxEmbedIE.ie_key())