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.

63 lines
2.3 KiB

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