]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/spiegel.py
Fix description of the modularization.
[youtubedl] / youtube_dl / extractor / spiegel.py
1 import re
2 import xml.etree.ElementTree
3
4 from .common import InfoExtractor
5
6
7 class SpiegelIE(InfoExtractor):
8 _VALID_URL = r'https?://(?:www\.)?spiegel\.de/video/[^/]*-(?P<videoID>[0-9]+)(?:\.html)?(?:#.*)?$'
9
10 def _real_extract(self, url):
11 m = re.match(self._VALID_URL, url)
12 video_id = m.group('videoID')
13
14 webpage = self._download_webpage(url, video_id)
15
16 video_title = self._html_search_regex(r'<div class="module-title">(.*?)</div>',
17 webpage, u'title')
18
19 xml_url = u'http://video2.spiegel.de/flash/' + video_id + u'.xml'
20 xml_code = self._download_webpage(xml_url, video_id,
21 note=u'Downloading XML', errnote=u'Failed to download XML')
22
23 idoc = xml.etree.ElementTree.fromstring(xml_code)
24 last_type = idoc[-1]
25 filename = last_type.findall('./filename')[0].text
26 duration = float(last_type.findall('./duration')[0].text)
27
28 video_url = 'http://video2.spiegel.de/flash/' + filename
29 video_ext = filename.rpartition('.')[2]
30 info = {
31 'id': video_id,
32 'url': video_url,
33 'ext': video_ext,
34 'title': video_title,
35 'duration': duration,
36 }
37 return [info]