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.

65 lines
2.3 KiB

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