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