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.

71 lines
2.6 KiB

  1. import os.path
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. compat_urllib_parse_urlparse,
  5. ExtractorError,
  6. )
  7. class MySpassIE(InfoExtractor):
  8. _VALID_URL = r'http://www.myspass.de/.*'
  9. _TEST = {
  10. u'url': u'http://www.myspass.de/myspass/shows/tvshows/absolute-mehrheit/Absolute-Mehrheit-vom-17022013-Die-Highlights-Teil-2--/11741/',
  11. u'file': u'11741.mp4',
  12. u'md5': u'0b49f4844a068f8b33f4b7c88405862b',
  13. u'info_dict': {
  14. u"description": u"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?",
  15. u"title": u"Absolute Mehrheit vom 17.02.2013 - Die Highlights, Teil 2"
  16. }
  17. }
  18. def _real_extract(self, url):
  19. META_DATA_URL_TEMPLATE = 'http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=%s'
  20. # video id is the last path element of the URL
  21. # usually there is a trailing slash, so also try the second but last
  22. url_path = compat_urllib_parse_urlparse(url).path
  23. url_parent_path, video_id = os.path.split(url_path)
  24. if not video_id:
  25. _, video_id = os.path.split(url_parent_path)
  26. # get metadata
  27. metadata_url = META_DATA_URL_TEMPLATE % video_id
  28. metadata = self._download_xml(metadata_url, video_id)
  29. # extract values from metadata
  30. url_flv_el = metadata.find('url_flv')
  31. if url_flv_el is None:
  32. raise ExtractorError(u'Unable to extract download url')
  33. video_url = url_flv_el.text
  34. extension = os.path.splitext(video_url)[1][1:]
  35. title_el = metadata.find('title')
  36. if title_el is None:
  37. raise ExtractorError(u'Unable to extract title')
  38. title = title_el.text
  39. format_id_el = metadata.find('format_id')
  40. if format_id_el is None:
  41. format = 'mp4'
  42. else:
  43. format = format_id_el.text
  44. description_el = metadata.find('description')
  45. if description_el is not None:
  46. description = description_el.text
  47. else:
  48. description = None
  49. imagePreview_el = metadata.find('imagePreview')
  50. if imagePreview_el is not None:
  51. thumbnail = imagePreview_el.text
  52. else:
  53. thumbnail = None
  54. info = {
  55. 'id': video_id,
  56. 'url': video_url,
  57. 'title': title,
  58. 'ext': extension,
  59. 'format': format,
  60. 'thumbnail': thumbnail,
  61. 'description': description
  62. }
  63. return [info]