myspass.py 3.6 KB

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