myspass.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. from .common import InfoExtractor
  2. from ..compat import compat_str
  3. from ..utils import (
  4. int_or_none,
  5. parse_duration,
  6. xpath_text,
  7. )
  8. class MySpassIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?myspass\.de/(?:[^/]+/)*(?P<id>\d+)/?[^/]*$'
  10. _TESTS = [{
  11. 'url': 'http://www.myspass.de/myspass/shows/tvshows/absolute-mehrheit/Absolute-Mehrheit-vom-17022013-Die-Highlights-Teil-2--/11741/',
  12. 'md5': '0b49f4844a068f8b33f4b7c88405862b',
  13. 'info_dict': {
  14. 'id': '11741',
  15. 'ext': 'mp4',
  16. 'description': 'md5:9f0db5044c8fe73f528a390498f7ce9b',
  17. 'title': '17.02.2013 - Die Highlights, Teil 2',
  18. 'thumbnail': r're:.*\.jpg',
  19. 'duration': 323.0,
  20. 'episode': '17.02.2013 - Die Highlights, Teil 2',
  21. 'season_id': '544',
  22. 'episode_number': 1,
  23. 'series': 'Absolute Mehrheit',
  24. 'season_number': 2,
  25. 'season': 'Season 2',
  26. },
  27. },
  28. {
  29. 'url': 'https://www.myspass.de/shows/tvshows/tv-total/Novak-Puffovic-bei-bester-Laune--/44996/',
  30. 'md5': 'eb28b7c5e254192046e86ebaf7deac8f',
  31. 'info_dict': {
  32. 'id': '44996',
  33. 'ext': 'mp4',
  34. 'description': 'md5:74c7f886e00834417f1e427ab0da6121',
  35. 'title': 'Novak Puffovic bei bester Laune',
  36. 'thumbnail': r're:.*\.jpg',
  37. 'episode_number': 8,
  38. 'episode': 'Novak Puffovic bei bester Laune',
  39. 'series': 'TV total',
  40. 'season': 'Season 19',
  41. 'season_id': '987',
  42. 'duration': 2941.0,
  43. 'season_number': 19,
  44. },
  45. },
  46. {
  47. 'url': 'https://www.myspass.de/channels/tv-total-raabigramm/17033/20831/',
  48. 'md5': '7b293a6b9f3a7acdd29304c8d0dbb7cc',
  49. 'info_dict': {
  50. 'id': '20831',
  51. 'ext': 'mp4',
  52. 'description': 'Gefühle pur: Schaut euch die ungeschnittene Version von Stefans Liebesbeweis an die Moderationsgrazie von Welt, Verona Feldbusch, an.',
  53. 'title': 'Raabigramm Verona Feldbusch',
  54. 'thumbnail': r're:.*\.jpg',
  55. 'episode_number': 6,
  56. 'episode': 'Raabigramm Verona Feldbusch',
  57. 'series': 'TV total',
  58. 'season': 'Season 1',
  59. 'season_id': '34',
  60. 'duration': 105.0,
  61. 'season_number': 1,
  62. },
  63. }]
  64. def _real_extract(self, url):
  65. video_id = self._match_id(url)
  66. metadata = self._download_xml('http://www.myspass.de/myspass/includes/apps/video/getvideometadataxml.php?id=' + video_id, video_id)
  67. title = xpath_text(metadata, 'title', fatal=True)
  68. video_url = xpath_text(metadata, 'url_flv', 'download url', True)
  69. video_id_int = int(video_id)
  70. for group in self._search_regex(r'/myspass2009/\d+/(\d+)/(\d+)/(\d+)/', video_url, 'myspass', group=(1, 2, 3), default=[]):
  71. group_int = int(group)
  72. if group_int > video_id_int:
  73. video_url = video_url.replace(group, compat_str(group_int // video_id_int))
  74. return {
  75. 'id': video_id,
  76. 'url': video_url,
  77. 'title': title,
  78. 'thumbnail': xpath_text(metadata, 'imagePreview'),
  79. 'description': xpath_text(metadata, 'description'),
  80. 'duration': parse_duration(xpath_text(metadata, 'duration')),
  81. 'series': xpath_text(metadata, 'format'),
  82. 'season_number': int_or_none(xpath_text(metadata, 'season')),
  83. 'season_id': xpath_text(metadata, 'season_id'),
  84. 'episode': title,
  85. 'episode_number': int_or_none(xpath_text(metadata, 'episode')),
  86. }