moviepilot.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. from .dailymotion import DailymotionIE
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. parse_iso8601,
  5. try_get,
  6. )
  7. import re
  8. class MoviepilotIE(InfoExtractor):
  9. _IE_NAME = 'moviepilot'
  10. _IE_DESC = 'Moviepilot trailer'
  11. _VALID_URL = r'https?://(?:www\.)?moviepilot\.de/movies/(?P<id>[^/]+)'
  12. _TESTS = [{
  13. 'url': 'https://www.moviepilot.de/movies/interstellar-2/',
  14. 'info_dict': {
  15. 'id': 'x7xdut5',
  16. 'display_id': 'interstellar-2',
  17. 'ext': 'mp4',
  18. 'title': 'Interstellar',
  19. 'thumbnail': r're:https://\w+\.dmcdn\.net/v/SaXev1VvzitVZMFsR/x720',
  20. 'timestamp': 1400491705,
  21. 'description': 'md5:7dfc5c1758e7322a7346934f1f0c489c',
  22. 'uploader': 'Moviepilot',
  23. 'like_count': int,
  24. 'view_count': int,
  25. 'uploader_id': 'x6nd9k',
  26. 'upload_date': '20140519',
  27. 'duration': 140,
  28. 'age_limit': 0,
  29. 'tags': ['Alle Trailer', 'Movie', 'Third Party'],
  30. },
  31. }, {
  32. 'url': 'https://www.moviepilot.de/movies/interstellar-2/trailer',
  33. 'only_matching': True,
  34. }, {
  35. 'url': 'https://www.moviepilot.de/movies/interstellar-2/kinoprogramm/berlin',
  36. 'only_matching': True,
  37. }, {
  38. 'url': 'https://www.moviepilot.de/movies/queen-slim/trailer',
  39. 'info_dict': {
  40. 'id': 'x7xj6o7',
  41. 'display_id': 'queen-slim',
  42. 'title': 'Queen & Slim',
  43. 'ext': 'mp4',
  44. 'thumbnail': r're:https://\w+\.dmcdn\.net/v/SbUM71WtomSjVmI_q/x720',
  45. 'timestamp': 1571838685,
  46. 'description': 'md5:73058bcd030aa12d991e4280d65fbebe',
  47. 'uploader': 'Moviepilot',
  48. 'like_count': int,
  49. 'view_count': int,
  50. 'uploader_id': 'x6nd9k',
  51. 'upload_date': '20191023',
  52. 'duration': 138,
  53. 'age_limit': 0,
  54. 'tags': ['Movie', 'Verleih', 'Neue Trailer'],
  55. },
  56. }, {
  57. 'url': 'https://www.moviepilot.de/movies/der-geiger-von-florenz/trailer',
  58. 'info_dict': {
  59. 'id': 'der-geiger-von-florenz',
  60. 'title': 'Der Geiger von Florenz',
  61. 'ext': 'mp4',
  62. },
  63. 'skip': 'No trailer for this movie.',
  64. }, {
  65. 'url': 'https://www.moviepilot.de/movies/muellers-buero/',
  66. 'info_dict': {
  67. 'id': 'x7xcw1i',
  68. 'display_id': 'muellers-buero',
  69. 'title': 'Müllers Büro',
  70. 'ext': 'mp4',
  71. 'description': 'md5:57501251c05cdc61ca314b7633e0312e',
  72. 'timestamp': 1287584475,
  73. 'age_limit': 0,
  74. 'duration': 82,
  75. 'upload_date': '20101020',
  76. 'thumbnail': r're:https://\w+\.dmcdn\.net/v/SaMes1WfAm1d6maq_/x720',
  77. 'uploader': 'Moviepilot',
  78. 'like_count': int,
  79. 'view_count': int,
  80. 'tags': ['Alle Trailer', 'Movie', 'Verleih'],
  81. 'uploader_id': 'x6nd9k',
  82. },
  83. }]
  84. def _real_extract(self, url):
  85. video_id = self._match_id(url)
  86. webpage = self._download_webpage(f'https://www.moviepilot.de/movies/{video_id}/trailer', video_id)
  87. duration = try_get(
  88. re.match(r'P(?P<hours>\d+)H(?P<mins>\d+)M(?P<secs>\d+)S',
  89. self._html_search_meta('duration', webpage, fatal=False) or ''),
  90. lambda mobj: sum(float(x) * y for x, y in zip(mobj.groups(), (3600, 60, 1))))
  91. # _html_search_meta is not used since we don't want name=description to match
  92. description = self._html_search_regex(
  93. '<meta[^>]+itemprop="description"[^>]+content="([^>"]+)"', webpage, 'description', fatal=False)
  94. return {
  95. '_type': 'url_transparent',
  96. 'ie_key': DailymotionIE.ie_key(),
  97. 'display_id': video_id,
  98. 'title': self._og_search_title(webpage),
  99. 'url': self._html_search_meta('embedURL', webpage),
  100. 'thumbnail': self._html_search_meta('thumbnailURL', webpage),
  101. 'description': description,
  102. 'duration': duration,
  103. 'timestamp': parse_iso8601(self._html_search_meta('uploadDate', webpage), delimiter=' ')
  104. }