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.

73 lines
2.7 KiB

  1. from __future__ import unicode_literals
  2. import os.path
  3. from .common import InfoExtractor
  4. from ..compat import (
  5. compat_urllib_parse_urlparse,
  6. )
  7. from ..utils import (
  8. ExtractorError,
  9. )
  10. class MySpassIE(InfoExtractor):
  11. _VALID_URL = r'https?://www\.myspass\.de/.*'
  12. _TEST = {
  13. 'url': 'http://www.myspass.de/myspass/shows/tvshows/absolute-mehrheit/Absolute-Mehrheit-vom-17022013-Die-Highlights-Teil-2--/11741/',
  14. 'md5': '0b49f4844a068f8b33f4b7c88405862b',
  15. 'info_dict': {
  16. 'id': '11741',
  17. 'ext': 'mp4',
  18. 'description': 'Wer kann in die Fu\u00dfstapfen von Wolfgang Kubicki treten und die Mehrheit der Zuschauer hinter sich versammeln? Wird vielleicht sogar die Absolute Mehrheit geknackt und der Jackpot von 200.000 Euro mit nach Hause genommen?',
  19. 'title': 'Absolute Mehrheit vom 17.02.2013 - Die Highlights, Teil 2',
  20. },
  21. }
  22. def _real_extract(self, url):
  23. META_DATA_URL_TEMPLATE = 'http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=%s'
  24. # video id is the last path element of the URL
  25. # usually there is a trailing slash, so also try the second but last
  26. url_path = compat_urllib_parse_urlparse(url).path
  27. url_parent_path, video_id = os.path.split(url_path)
  28. if not video_id:
  29. _, video_id = os.path.split(url_parent_path)
  30. # get metadata
  31. metadata_url = META_DATA_URL_TEMPLATE % video_id
  32. metadata = self._download_xml(
  33. metadata_url, video_id, transform_source=lambda s: s.strip())
  34. # extract values from metadata
  35. url_flv_el = metadata.find('url_flv')
  36. if url_flv_el is None:
  37. raise ExtractorError('Unable to extract download url')
  38. video_url = url_flv_el.text
  39. title_el = metadata.find('title')
  40. if title_el is None:
  41. raise ExtractorError('Unable to extract title')
  42. title = title_el.text
  43. format_id_el = metadata.find('format_id')
  44. if format_id_el is None:
  45. format = 'mp4'
  46. else:
  47. format = format_id_el.text
  48. description_el = metadata.find('description')
  49. if description_el is not None:
  50. description = description_el.text
  51. else:
  52. description = None
  53. imagePreview_el = metadata.find('imagePreview')
  54. if imagePreview_el is not None:
  55. thumbnail = imagePreview_el.text
  56. else:
  57. thumbnail = None
  58. return {
  59. 'id': video_id,
  60. 'url': video_url,
  61. 'title': title,
  62. 'format': format,
  63. 'thumbnail': thumbnail,
  64. 'description': description,
  65. }