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.

45 lines
1.6 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. _TEST = {
  7. u'url': u'http://www.spiegel.de/video/vulkan-tungurahua-in-ecuador-ist-wieder-aktiv-video-1259285.html',
  8. u'file': u'1259285.mp4',
  9. u'md5': u'2c2754212136f35fb4b19767d242f66e',
  10. u'info_dict': {
  11. u"title": u"Vulkanausbruch in Ecuador: Der \"Feuerschlund\" ist wieder aktiv"
  12. }
  13. }
  14. def _real_extract(self, url):
  15. m = re.match(self._VALID_URL, url)
  16. video_id = m.group('videoID')
  17. webpage = self._download_webpage(url, video_id)
  18. video_title = self._html_search_regex(r'<div class="module-title">(.*?)</div>',
  19. webpage, u'title')
  20. xml_url = u'http://video2.spiegel.de/flash/' + video_id + u'.xml'
  21. xml_code = self._download_webpage(xml_url, video_id,
  22. note=u'Downloading XML', errnote=u'Failed to download XML')
  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. video_url = 'http://video2.spiegel.de/flash/' + filename
  28. video_ext = filename.rpartition('.')[2]
  29. info = {
  30. 'id': video_id,
  31. 'url': video_url,
  32. 'ext': video_ext,
  33. 'title': video_title,
  34. 'duration': duration,
  35. }
  36. return [info]