2 import xml.etree.ElementTree
4 from .common import InfoExtractor
7 class SpiegelIE(InfoExtractor):
8 _VALID_URL = r'https?://(?:www\.)?spiegel\.de/video/[^/]*-(?P<videoID>[0-9]+)(?:\.html)?(?:#.*)?$'
10 u'url': u'http://www.spiegel.de/video/vulkan-tungurahua-in-ecuador-ist-wieder-aktiv-video-1259285.html',
11 u'file': u'1259285.mp4',
12 u'md5': u'2c2754212136f35fb4b19767d242f66e',
14 u"title": u"Vulkanausbruch in Ecuador: Der \"Feuerschlund\" ist wieder aktiv"
18 u'url': u'http://www.spiegel.de/video/schach-wm-videoanalyse-des-fuenften-spiels-video-1309159.html',
19 u'file': u'1309159.mp4',
20 u'md5': u'f2cdf638d7aa47654e251e1aee360af1',
22 u'title': u'Schach-WM in der Videoanalyse: Carlsen nutzt die Fehlgriffe des Titelverteidigers'
26 def _real_extract(self, url):
27 m = re.match(self._VALID_URL, url)
28 video_id = m.group('videoID')
30 webpage = self._download_webpage(url, video_id)
32 video_title = self._html_search_regex(
33 r'<div class="module-title">(.*?)</div>', webpage, u'title')
35 xml_url = u'http://video2.spiegel.de/flash/' + video_id + u'.xml'
36 xml_code = self._download_webpage(
38 note=u'Downloading XML', errnote=u'Failed to download XML')
40 idoc = xml.etree.ElementTree.fromstring(xml_code)
44 'format_id': n.tag.rpartition('type')[2],
45 'url': u'http://video2.spiegel.de/flash/' + n.find('./filename').text,
46 'width': int(n.find('./width').text),
47 'height': int(n.find('./height').text),
48 'abr': int(n.find('./audiobitrate').text),
49 'vbr': int(n.find('./videobitrate').text),
50 'vcodec': n.find('./codec').text,
54 # Blacklist type 6, it's extremely LQ and not available on the same server
55 if n.tag.startswith('type') and n.tag != 'type6'
57 formats.sort(key=lambda f: f['vbr'])
58 duration = float(idoc[0].findall('./duration')[0].text)