You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.2 KiB

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