]>
Commit | Line | Data |
---|---|---|
79fec976 | 1 | import base64 |
eb9c9c74 | 2 | import functools |
b3d14cbf | 3 | import re |
caeefc29 | 4 | import itertools |
b3d14cbf PH |
5 | |
6 | from .common import InfoExtractor | |
3d2623a8 | 7 | from ..compat import compat_str, compat_urlparse |
8 | from ..networking import HEADRequest, Request | |
9 | from ..networking.exceptions import HTTPError | |
8c25f81b | 10 | from ..utils import ( |
681ac7c9 | 11 | clean_html, |
d5f071af | 12 | determine_ext, |
b3d14cbf | 13 | ExtractorError, |
58ab5cbc | 14 | get_element_by_class, |
ca01d178 | 15 | js_to_json, |
9c44d242 | 16 | int_or_none, |
ae1c585c | 17 | merge_dicts, |
eb9c9c74 | 18 | OnDemandPagedList, |
ca01d178 | 19 | parse_filesize, |
cce889b9 | 20 | parse_iso8601, |
4dfbf869 | 21 | parse_qs, |
30965ac6 | 22 | smuggle_url, |
681ac7c9 | 23 | str_or_none, |
c15cd296 | 24 | try_get, |
c15cd296 | 25 | unified_timestamp, |
9d4660ca | 26 | unsmuggle_url, |
a980bc43 | 27 | urlencode_postdata, |
1c45ff55 | 28 | urljoin, |
9cb070f9 | 29 | urlhandle_detect_ext, |
b3d14cbf PH |
30 | ) |
31 | ||
bbafbe20 | 32 | |
efb7e119 JMF |
33 | class VimeoBaseInfoExtractor(InfoExtractor): |
34 | _NETRC_MACHINE = 'vimeo' | |
35 | _LOGIN_REQUIRED = False | |
f6c3664d | 36 | _LOGIN_URL = 'https://vimeo.com/log_in' |
efb7e119 | 37 | |
aedaa455 | 38 | @staticmethod |
39 | def _smuggle_referrer(url, referrer_url): | |
f04b5bed | 40 | return smuggle_url(url, {'referer': referrer_url}) |
aedaa455 | 41 | |
42 | def _unsmuggle_headers(self, url): | |
43 | """@returns (url, smuggled_data, headers)""" | |
44 | url, data = unsmuggle_url(url, {}) | |
45 | headers = self.get_param('http_headers').copy() | |
f04b5bed | 46 | if 'referer' in data: |
47 | headers['Referer'] = data['referer'] | |
aedaa455 | 48 | return url, data, headers |
49 | ||
52efa4b3 | 50 | def _perform_login(self, username, password): |
2e8de097 | 51 | viewer = self._download_json('https://vimeo.com/_next/viewer', None, 'Downloading login token') |
26ad6bcd | 52 | data = { |
f6c3664d | 53 | 'action': 'login', |
efb7e119 JMF |
54 | 'email': username, |
55 | 'password': password, | |
efb7e119 | 56 | 'service': 'vimeo', |
2e8de097 | 57 | 'token': viewer['xsrft'], |
26ad6bcd | 58 | } |
2e8de097 | 59 | self._set_vimeo_cookie('vuid', viewer['vuid']) |
26ad6bcd S |
60 | try: |
61 | self._download_webpage( | |
62 | self._LOGIN_URL, None, 'Logging in', | |
63 | data=urlencode_postdata(data), headers={ | |
64 | 'Content-Type': 'application/x-www-form-urlencoded', | |
65 | 'Referer': self._LOGIN_URL, | |
66 | }) | |
67 | except ExtractorError as e: | |
3d2623a8 | 68 | if isinstance(e.cause, HTTPError) and e.cause.status == 418: |
26ad6bcd S |
69 | raise ExtractorError( |
70 | 'Unable to log in: bad username or password', | |
71 | expected=True) | |
72 | raise ExtractorError('Unable to log in') | |
efb7e119 | 73 | |
52efa4b3 | 74 | def _real_initialize(self): |
75 | if self._LOGIN_REQUIRED and not self._get_cookies('https://vimeo.com').get('vuid'): | |
76 | self._raise_login_required() | |
77 | ||
cce889b9 | 78 | def _get_video_password(self): |
a06916d9 | 79 | password = self.get_param('videopassword') |
c1ff6e1a | 80 | if password is None: |
cce889b9 | 81 | raise ExtractorError( |
82 | 'This video is protected by a password, use the --video-password option', | |
83 | expected=True) | |
84 | return password | |
85 | ||
86 | def _verify_video_password(self, url, video_id, password, token, vuid): | |
c1ff6e1a YCH |
87 | if url.startswith('http://'): |
88 | # vimeo only supports https now, but the user can give an http url | |
89 | url = url.replace('http://', 'https://') | |
c1ff6e1a YCH |
90 | self._set_vimeo_cookie('vuid', vuid) |
91 | return self._download_webpage( | |
cce889b9 | 92 | url + '/password', video_id, 'Verifying the password', |
93 | 'Wrong password', data=urlencode_postdata({ | |
94 | 'password': password, | |
95 | 'token': token, | |
96 | }), headers={ | |
97 | 'Content-Type': 'application/x-www-form-urlencoded', | |
98 | 'Referer': url, | |
99 | }) | |
c1ff6e1a | 100 | |
7c845629 S |
101 | def _extract_xsrft_and_vuid(self, webpage): |
102 | xsrft = self._search_regex( | |
b826035d | 103 | r'(?:(?P<q1>["\'])xsrft(?P=q1)\s*:|xsrft\s*[=:])\s*(?P<q>["\'])(?P<xsrft>.+?)(?P=q)', |
f6c3664d | 104 | webpage, 'login token', group='xsrft') |
7c845629 S |
105 | vuid = self._search_regex( |
106 | r'["\']vuid["\']\s*:\s*(["\'])(?P<vuid>.+?)\1', | |
107 | webpage, 'vuid', group='vuid') | |
108 | return xsrft, vuid | |
f6c3664d | 109 | |
eb9c9c74 RA |
110 | def _extract_vimeo_config(self, webpage, video_id, *args, **kwargs): |
111 | vimeo_config = self._search_regex( | |
112 | r'vimeo\.config\s*=\s*(?:({.+?})|_extend\([^,]+,\s+({.+?})\));', | |
f9934b96 | 113 | webpage, 'vimeo config', *args, **kwargs) |
eb9c9c74 RA |
114 | if vimeo_config: |
115 | return self._parse_json(vimeo_config, video_id) | |
116 | ||
9eab37dc S |
117 | def _set_vimeo_cookie(self, name, value): |
118 | self._set_cookie('vimeo.com', name, value) | |
119 | ||
531a7496 | 120 | def _parse_config(self, config, video_id): |
d8c507c9 | 121 | video_data = config['video'] |
24146491 | 122 | video_title = video_data.get('title') |
85b6335d RA |
123 | live_event = video_data.get('live_event') or {} |
124 | is_live = live_event.get('status') == 'started' | |
58ab5cbc | 125 | request = config.get('request') or {} |
531a7496 YCH |
126 | |
127 | formats = [] | |
3f047fc4 F |
128 | subtitles = {} |
129 | ||
58ab5cbc | 130 | config_files = video_data.get('files') or request.get('files') or {} |
131 | for f in (config_files.get('progressive') or []): | |
531a7496 YCH |
132 | video_url = f.get('url') |
133 | if not video_url: | |
134 | continue | |
135 | formats.append({ | |
136 | 'url': video_url, | |
137 | 'format_id': 'http-%s' % f.get('quality'), | |
bc104778 | 138 | 'source_preference': 10, |
531a7496 YCH |
139 | 'width': int_or_none(f.get('width')), |
140 | 'height': int_or_none(f.get('height')), | |
141 | 'fps': int_or_none(f.get('fps')), | |
142 | 'tbr': int_or_none(f.get('bitrate')), | |
143 | }) | |
d8c507c9 | 144 | |
85b6335d | 145 | # TODO: fix handling of 308 status code returned for live archive manifest requests |
52c50a10 | 146 | sep_pattern = r'/sep/video/' |
d8c507c9 | 147 | for files_type in ('hls', 'dash'): |
58ab5cbc | 148 | for cdn_name, cdn_data in (try_get(config_files, lambda x: x[files_type]['cdns']) or {}).items(): |
d8c507c9 RA |
149 | manifest_url = cdn_data.get('url') |
150 | if not manifest_url: | |
151 | continue | |
152 | format_id = '%s-%s' % (files_type, cdn_name) | |
52c50a10 RA |
153 | sep_manifest_urls = [] |
154 | if re.search(sep_pattern, manifest_url): | |
155 | for suffix, repl in (('', 'video'), ('_sep', 'sep/video')): | |
156 | sep_manifest_urls.append((format_id + suffix, re.sub( | |
157 | sep_pattern, '/%s/' % repl, manifest_url))) | |
158 | else: | |
159 | sep_manifest_urls = [(format_id, manifest_url)] | |
160 | for f_id, m_url in sep_manifest_urls: | |
161 | if files_type == 'hls': | |
3f047fc4 | 162 | fmts, subs = self._extract_m3u8_formats_and_subtitles( |
a5c0c202 | 163 | m_url, video_id, 'mp4', live=is_live, m3u8_id=f_id, |
52c50a10 | 164 | note='Downloading %s m3u8 information' % cdn_name, |
3f047fc4 F |
165 | fatal=False) |
166 | formats.extend(fmts) | |
167 | self._merge_subtitles(subs, target=subtitles) | |
52c50a10 | 168 | elif files_type == 'dash': |
c25720ef RA |
169 | if 'json=1' in m_url: |
170 | real_m_url = (self._download_json(m_url, video_id, fatal=False) or {}).get('url') | |
171 | if real_m_url: | |
172 | m_url = real_m_url | |
3f047fc4 | 173 | fmts, subs = self._extract_mpd_formats_and_subtitles( |
ae9a173b RA |
174 | m_url.replace('/master.json', '/master.mpd'), video_id, f_id, |
175 | 'Downloading %s MPD information' % cdn_name, | |
e834f044 | 176 | fatal=False) |
3f047fc4 F |
177 | formats.extend(fmts) |
178 | self._merge_subtitles(subs, target=subtitles) | |
531a7496 | 179 | |
85b6335d RA |
180 | live_archive = live_event.get('archive') or {} |
181 | live_archive_source_url = live_archive.get('source_url') | |
182 | if live_archive_source_url and live_archive.get('status') == 'done': | |
183 | formats.append({ | |
184 | 'format_id': 'live-archive-source', | |
185 | 'url': live_archive_source_url, | |
f983b875 | 186 | 'quality': 10, |
85b6335d RA |
187 | }) |
188 | ||
58ab5cbc | 189 | for tt in (request.get('text_tracks') or []): |
3f047fc4 | 190 | subtitles.setdefault(tt['lang'], []).append({ |
58ab5cbc | 191 | 'ext': 'vtt', |
192 | 'url': urljoin('https://vimeo.com', tt['url']), | |
3f047fc4 | 193 | }) |
531a7496 | 194 | |
c25720ef RA |
195 | thumbnails = [] |
196 | if not is_live: | |
58ab5cbc | 197 | for key, thumb in (video_data.get('thumbs') or {}).items(): |
c25720ef RA |
198 | thumbnails.append({ |
199 | 'id': key, | |
200 | 'width': int_or_none(key), | |
201 | 'url': thumb, | |
202 | }) | |
203 | thumbnail = video_data.get('thumbnail') | |
204 | if thumbnail: | |
205 | thumbnails.append({ | |
206 | 'url': thumbnail, | |
207 | }) | |
208 | ||
209 | owner = video_data.get('owner') or {} | |
210 | video_uploader_url = owner.get('url') | |
211 | ||
818faa3a | 212 | duration = int_or_none(video_data.get('duration')) |
213 | chapter_data = try_get(config, lambda x: x['embed']['chapters']) or [] | |
214 | chapters = [{ | |
215 | 'title': current_chapter.get('title'), | |
216 | 'start_time': current_chapter.get('timecode'), | |
217 | 'end_time': next_chapter.get('timecode'), | |
218 | } for current_chapter, next_chapter in zip(chapter_data, chapter_data[1:] + [{'timecode': duration}])] | |
219 | if chapters and chapters[0]['start_time']: # Chapters may not start from 0 | |
220 | chapters[:0] = [{'title': '<Untitled>', 'start_time': 0, 'end_time': chapters[0]['start_time']}] | |
221 | ||
531a7496 | 222 | return { |
681ac7c9 | 223 | 'id': str_or_none(video_data.get('id')) or video_id, |
39ca3b5c | 224 | 'title': video_title, |
c25720ef RA |
225 | 'uploader': owner.get('name'), |
226 | 'uploader_id': video_uploader_url.split('/')[-1] if video_uploader_url else None, | |
531a7496 | 227 | 'uploader_url': video_uploader_url, |
c25720ef | 228 | 'thumbnails': thumbnails, |
818faa3a | 229 | 'duration': duration, |
230 | 'chapters': chapters or None, | |
531a7496 YCH |
231 | 'formats': formats, |
232 | 'subtitles': subtitles, | |
c25720ef | 233 | 'is_live': is_live, |
9f14daf2 | 234 | # Note: Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps |
235 | # at the same time without actual units specified. | |
236 | '_format_sort_fields': ('quality', 'res', 'fps', 'hdr:12', 'source'), | |
531a7496 YCH |
237 | } |
238 | ||
bc2ca1bb | 239 | def _extract_original_format(self, url, video_id, unlisted_hash=None): |
240 | query = {'action': 'load_download_config'} | |
241 | if unlisted_hash: | |
242 | query['unlisted_hash'] = unlisted_hash | |
27655037 | 243 | download_data = self._download_json( |
bc2ca1bb | 244 | url, video_id, fatal=False, query=query, |
9cb070f9 | 245 | headers={'X-Requested-With': 'XMLHttpRequest'}, |
246 | expected_status=(403, 404)) or {} | |
247 | source_file = download_data.get('source_file') | |
248 | download_url = try_get(source_file, lambda x: x['download_url']) | |
249 | if download_url and not source_file.get('is_cold') and not source_file.get('is_defrosting'): | |
250 | source_name = source_file.get('public_name', 'Original') | |
251 | if self._is_valid_url(download_url, video_id, '%s video' % source_name): | |
252 | ext = (try_get( | |
253 | source_file, lambda x: x['extension'], | |
254 | compat_str) or determine_ext( | |
255 | download_url, None) or 'mp4').lower() | |
256 | return { | |
257 | 'url': download_url, | |
258 | 'ext': ext, | |
259 | 'width': int_or_none(source_file.get('width')), | |
260 | 'height': int_or_none(source_file.get('height')), | |
261 | 'filesize': parse_filesize(source_file.get('size')), | |
262 | 'format_id': source_name, | |
263 | 'quality': 1, | |
264 | } | |
27655037 | 265 | |
605cad0b A |
266 | jwt_response = self._download_json( |
267 | 'https://vimeo.com/_rv/viewer', video_id, note='Downloading jwt token', fatal=False) or {} | |
268 | if not jwt_response.get('jwt'): | |
269 | return | |
8e765755 | 270 | headers = {'Authorization': 'jwt %s' % jwt_response['jwt'], 'Accept': 'application/json'} |
605cad0b A |
271 | original_response = self._download_json( |
272 | f'https://api.vimeo.com/videos/{video_id}', video_id, | |
9cb070f9 | 273 | headers=headers, fatal=False, expected_status=(403, 404)) or {} |
274 | for download_data in original_response.get('download') or []: | |
605cad0b A |
275 | download_url = download_data.get('link') |
276 | if not download_url or download_data.get('quality') != 'source': | |
277 | continue | |
9cb070f9 | 278 | ext = determine_ext(parse_qs(download_url).get('filename', [''])[0].lower(), default_ext=None) |
279 | if not ext: | |
280 | urlh = self._request_webpage( | |
281 | HEADRequest(download_url), video_id, fatal=False, note='Determining source extension') | |
282 | ext = urlh and urlhandle_detect_ext(urlh) | |
605cad0b A |
283 | return { |
284 | 'url': download_url, | |
9cb070f9 | 285 | 'ext': ext or 'unknown_video', |
605cad0b A |
286 | 'format_id': download_data.get('public_name', 'Original'), |
287 | 'width': int_or_none(download_data.get('width')), | |
288 | 'height': int_or_none(download_data.get('height')), | |
289 | 'fps': int_or_none(download_data.get('fps')), | |
290 | 'filesize': int_or_none(download_data.get('size')), | |
291 | 'quality': 1, | |
292 | } | |
293 | ||
efb7e119 | 294 | |
65469a7f | 295 | class VimeoIE(VimeoBaseInfoExtractor): |
b3d14cbf PH |
296 | """Information extractor for vimeo.com.""" |
297 | ||
298 | # _VALID_URL matches Vimeo URLs | |
bbafbe20 | 299 | _VALID_URL = r'''(?x) |
45b2ee6f | 300 | https?:// |
301 | (?: | |
302 | (?: | |
303 | www| | |
304 | player | |
305 | ) | |
306 | \. | |
307 | )? | |
308 | vimeo\.com/ | |
309 | (?: | |
310 | (?P<u>user)| | |
311 | (?!(?:channels|album|showcase)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/) | |
312 | (?:.*?/)?? | |
313 | (?P<q> | |
314 | (?: | |
315 | play_redirect_hls| | |
316 | moogaloop\.swf)\?clip_id= | |
317 | )? | |
318 | (?:videos?/)? | |
319 | ) | |
320 | (?P<id>[0-9]+) | |
321 | (?(u) | |
322 | /(?!videos|likes)[^/?#]+/?| | |
323 | (?(q)|/(?P<unlisted_hash>[\da-f]{10}))? | |
324 | ) | |
325 | (?:(?(q)[&]|(?(u)|/?)[?]).*?)?(?:[#].*)?$ | |
326 | ''' | |
9148eb00 | 327 | IE_NAME = 'vimeo' |
bfd973ec | 328 | _EMBED_REGEX = [ |
329 | # iframe | |
330 | r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/\d+.*?)\1', | |
331 | # Embedded (swf embed) Vimeo player | |
332 | r'<embed[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1', | |
333 | # Non-standard embedded Vimeo player | |
334 | r'<video[^>]+src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/[0-9]+)\1', | |
335 | ] | |
a91b954b JMF |
336 | _TESTS = [ |
337 | { | |
9148eb00 | 338 | 'url': 'http://vimeo.com/56015672#at=0', |
9148eb00 PH |
339 | 'md5': '8879b6cc097e987f02484baf890129e5', |
340 | 'info_dict': { | |
ad5976b4 PH |
341 | 'id': '56015672', |
342 | 'ext': 'mp4', | |
b9c7b1e9 | 343 | 'title': "youtube-dl test video '' ä↭𝕐-BaW jenozKc", |
681ac7c9 | 344 | 'description': 'md5:2d3305bad981a06ff79f027f19865021', |
c15cd296 | 345 | 'timestamp': 1355990239, |
68f3b61f | 346 | 'upload_date': '20121220', |
ec85ded8 | 347 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user7108434', |
68f3b61f S |
348 | 'uploader_id': 'user7108434', |
349 | 'uploader': 'Filippo Valsorda', | |
350 | 'duration': 10, | |
c38a67bc | 351 | 'license': 'by-sa', |
a91b954b | 352 | }, |
681ac7c9 RA |
353 | 'params': { |
354 | 'format': 'best[protocol=https]', | |
355 | }, | |
b9c7b1e9 | 356 | 'skip': 'No longer available' |
a91b954b | 357 | }, |
aa32314d | 358 | { |
9148eb00 | 359 | 'url': 'http://player.vimeo.com/video/54469442', |
c0cd13fb | 360 | 'md5': '619b811a4417aa4abe78dc653becf511', |
9148eb00 PH |
361 | 'note': 'Videos that embed the url in the player page', |
362 | 'info_dict': { | |
4f3e9430 JMF |
363 | 'id': '54469442', |
364 | 'ext': 'mp4', | |
0e6ebc13 | 365 | 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012', |
cce889b9 | 366 | 'uploader': 'Business of Software', |
367 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/businessofsoftware', | |
368 | 'uploader_id': 'businessofsoftware', | |
69c8fb9e | 369 | 'duration': 3610, |
58ea7ec8 | 370 | 'description': None, |
b9c7b1e9 | 371 | 'thumbnail': 'https://i.vimeocdn.com/video/376682406-f34043e7b766af6bef2af81366eacd6724f3fc3173179a11a97a1e26587c9529-d_1280', |
aa32314d | 372 | }, |
681ac7c9 RA |
373 | 'params': { |
374 | 'format': 'best[protocol=https]', | |
375 | }, | |
93b22c78 JMF |
376 | }, |
377 | { | |
9148eb00 | 378 | 'url': 'http://vimeo.com/68375962', |
9148eb00 PH |
379 | 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7', |
380 | 'note': 'Video protected with password', | |
381 | 'info_dict': { | |
4f3e9430 JMF |
382 | 'id': '68375962', |
383 | 'ext': 'mp4', | |
3867038a | 384 | 'title': 'youtube-dl password protected test video', |
c15cd296 | 385 | 'timestamp': 1371200155, |
9148eb00 | 386 | 'upload_date': '20130614', |
ec85ded8 | 387 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128', |
9148eb00 PH |
388 | 'uploader_id': 'user18948128', |
389 | 'uploader': 'Jaime Marquínez Ferrándiz', | |
69c8fb9e | 390 | 'duration': 10, |
c0cd13fb L |
391 | 'description': 'md5:6173f270cd0c0119f22817204b3eb86c', |
392 | 'thumbnail': 'https://i.vimeocdn.com/video/440665496-b2c5aee2b61089442c794f64113a8e8f7d5763c3e6b3ebfaf696ae6413f8b1f4-d_1280', | |
b9c7b1e9 | 393 | 'view_count': int, |
394 | 'comment_count': int, | |
395 | 'like_count': int, | |
93b22c78 | 396 | }, |
9148eb00 | 397 | 'params': { |
681ac7c9 | 398 | 'format': 'best[protocol=https]', |
3867038a | 399 | 'videopassword': 'youtube-dl', |
93b22c78 JMF |
400 | }, |
401 | }, | |
548f31d9 S |
402 | { |
403 | 'url': 'http://vimeo.com/channels/keypeele/75629013', | |
404 | 'md5': '2f86a05afe9d7abc0b9126d229bbe15d', | |
548f31d9 S |
405 | 'info_dict': { |
406 | 'id': '75629013', | |
407 | 'ext': 'mp4', | |
408 | 'title': 'Key & Peele: Terrorist Interrogation', | |
c0cd13fb | 409 | 'description': 'md5:6173f270cd0c0119f22817204b3eb86c', |
ec85ded8 | 410 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/atencio', |
548f31d9 S |
411 | 'uploader_id': 'atencio', |
412 | 'uploader': 'Peter Atencio', | |
d03beddf S |
413 | 'channel_id': 'keypeele', |
414 | 'channel_url': r're:https?://(?:www\.)?vimeo\.com/channels/keypeele', | |
c15cd296 S |
415 | 'timestamp': 1380339469, |
416 | 'upload_date': '20130928', | |
548f31d9 | 417 | 'duration': 187, |
b9c7b1e9 | 418 | 'thumbnail': 'https://i.vimeocdn.com/video/450239872-a05512d9b1e55d707a7c04365c10980f327b06d966351bc403a5d5d65c95e572-d_1280', |
419 | 'view_count': int, | |
420 | 'comment_count': int, | |
421 | 'like_count': int, | |
548f31d9 | 422 | }, |
9cb070f9 | 423 | 'params': {'format': 'http-1080p'}, |
548f31d9 | 424 | }, |
1eac553e S |
425 | { |
426 | 'url': 'http://vimeo.com/76979871', | |
1eac553e S |
427 | 'note': 'Video with subtitles', |
428 | 'info_dict': { | |
429 | 'id': '76979871', | |
b9c7b1e9 | 430 | 'ext': 'mov', |
1eac553e S |
431 | 'title': 'The New Vimeo Player (You Know, For Videos)', |
432 | 'description': 'md5:2ec900bf97c3f389378a96aee11260ea', | |
c15cd296 | 433 | 'timestamp': 1381846109, |
1eac553e | 434 | 'upload_date': '20131015', |
ec85ded8 | 435 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/staff', |
1eac553e S |
436 | 'uploader_id': 'staff', |
437 | 'uploader': 'Vimeo Staff', | |
69c8fb9e | 438 | 'duration': 62, |
58ab5cbc | 439 | 'subtitles': { |
440 | 'de': [{'ext': 'vtt'}], | |
441 | 'en': [{'ext': 'vtt'}], | |
442 | 'es': [{'ext': 'vtt'}], | |
443 | 'fr': [{'ext': 'vtt'}], | |
444 | }, | |
9cb070f9 | 445 | }, |
446 | 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'], | |
1eac553e | 447 | }, |
4698f0d8 JMF |
448 | { |
449 | # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/ | |
450 | 'url': 'https://player.vimeo.com/video/98044508', | |
451 | 'note': 'The js code contains assignments to the same variable as the config', | |
452 | 'info_dict': { | |
453 | 'id': '98044508', | |
454 | 'ext': 'mp4', | |
455 | 'title': 'Pier Solar OUYA Official Trailer', | |
456 | 'uploader': 'Tulio Gonçalves', | |
ec85ded8 | 457 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593', |
4698f0d8 | 458 | 'uploader_id': 'user28849593', |
b9c7b1e9 | 459 | 'duration': 118, |
460 | 'thumbnail': 'https://i.vimeocdn.com/video/478636036-c18440305ef3df9decfb6bf207a61fe39d2d17fa462a96f6f2d93d30492b037d-d_1280', | |
4698f0d8 JMF |
461 | }, |
462 | }, | |
323f82a7 | 463 | { |
464 | # contains original format | |
465 | 'url': 'https://vimeo.com/33951933', | |
365d136b | 466 | 'md5': '53c688fa95a55bf4b7293d37a89c5c53', |
323f82a7 | 467 | 'info_dict': { |
468 | 'id': '33951933', | |
469 | 'ext': 'mp4', | |
470 | 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute', | |
471 | 'uploader': 'The DMCI', | |
ec85ded8 | 472 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/dmci', |
323f82a7 | 473 | 'uploader_id': 'dmci', |
c15cd296 | 474 | 'timestamp': 1324343742, |
323f82a7 | 475 | 'upload_date': '20111220', |
476 | 'description': 'md5:ae23671e82d05415868f7ad1aec21147', | |
b9c7b1e9 | 477 | 'duration': 60, |
478 | 'comment_count': int, | |
479 | 'view_count': int, | |
480 | 'thumbnail': 'https://i.vimeocdn.com/video/231174622-dd07f015e9221ff529d451e1cc31c982b5d87bfafa48c4189b1da72824ee289a-d_1280', | |
481 | 'like_count': int, | |
323f82a7 | 482 | }, |
483 | }, | |
605cad0b A |
484 | { |
485 | 'note': 'Contains original format not accessible in webpage', | |
486 | 'url': 'https://vimeo.com/393756517', | |
487 | 'md5': 'c464af248b592190a5ffbb5d33f382b0', | |
488 | 'info_dict': { | |
489 | 'id': '393756517', | |
490 | 'ext': 'mov', | |
491 | 'timestamp': 1582642091, | |
492 | 'uploader_id': 'frameworkla', | |
493 | 'title': 'Straight To Hell - Sabrina: Netflix', | |
494 | 'uploader': 'Framework Studio', | |
495 | 'description': 'md5:f2edc61af3ea7a5592681ddbb683db73', | |
496 | 'upload_date': '20200225', | |
b9c7b1e9 | 497 | 'duration': 176, |
498 | 'thumbnail': 'https://i.vimeocdn.com/video/859377297-836494a4ef775e9d4edbace83937d9ad34dc846c688c0c419c0e87f7ab06c4b3-d_1280', | |
499 | 'uploader_url': 'https://vimeo.com/frameworkla', | |
605cad0b | 500 | }, |
605cad0b | 501 | }, |
c143ddce S |
502 | { |
503 | # only available via https://vimeo.com/channels/tributes/6213729 and | |
504 | # not via https://vimeo.com/6213729 | |
505 | 'url': 'https://vimeo.com/channels/tributes/6213729', | |
506 | 'info_dict': { | |
507 | 'id': '6213729', | |
d03beddf | 508 | 'ext': 'mp4', |
c143ddce S |
509 | 'title': 'Vimeo Tribute: The Shining', |
510 | 'uploader': 'Casey Donahue', | |
ec85ded8 | 511 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/caseydonahue', |
c143ddce | 512 | 'uploader_id': 'caseydonahue', |
d03beddf S |
513 | 'channel_url': r're:https?://(?:www\.)?vimeo\.com/channels/tributes', |
514 | 'channel_id': 'tributes', | |
c15cd296 | 515 | 'timestamp': 1250886430, |
c143ddce S |
516 | 'upload_date': '20090821', |
517 | 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6', | |
b9c7b1e9 | 518 | 'duration': 321, |
519 | 'comment_count': int, | |
520 | 'view_count': int, | |
521 | 'thumbnail': 'https://i.vimeocdn.com/video/22728298-bfc22146f930de7cf497821c7b0b9f168099201ecca39b00b6bd31fcedfca7a6-d_1280', | |
522 | 'like_count': int, | |
c143ddce S |
523 | }, |
524 | 'params': { | |
525 | 'skip_download': True, | |
526 | }, | |
c143ddce | 527 | }, |
f16f8505 | 528 | { |
cccd70a2 | 529 | # redirects to ondemand extractor and should be passed through it |
f16f8505 S |
530 | # for successful extraction |
531 | 'url': 'https://vimeo.com/73445910', | |
532 | 'info_dict': { | |
533 | 'id': '73445910', | |
534 | 'ext': 'mp4', | |
535 | 'title': 'The Reluctant Revolutionary', | |
536 | 'uploader': '10Ft Films', | |
ec85ded8 | 537 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/tenfootfilms', |
f16f8505 | 538 | 'uploader_id': 'tenfootfilms', |
681ac7c9 RA |
539 | 'description': 'md5:0fa704e05b04f91f40b7f3ca2e801384', |
540 | 'upload_date': '20130830', | |
541 | 'timestamp': 1377853339, | |
f16f8505 S |
542 | }, |
543 | 'params': { | |
544 | 'skip_download': True, | |
545 | }, | |
cce889b9 | 546 | 'skip': 'this page is no longer available.', |
f16f8505 | 547 | }, |
79fec976 RA |
548 | { |
549 | 'url': 'http://player.vimeo.com/video/68375962', | |
550 | 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7', | |
551 | 'info_dict': { | |
552 | 'id': '68375962', | |
553 | 'ext': 'mp4', | |
3867038a | 554 | 'title': 'youtube-dl password protected test video', |
b9c7b1e9 | 555 | 'timestamp': 1371200155, |
556 | 'upload_date': '20130614', | |
79fec976 RA |
557 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128', |
558 | 'uploader_id': 'user18948128', | |
559 | 'uploader': 'Jaime Marquínez Ferrándiz', | |
560 | 'duration': 10, | |
c0cd13fb L |
561 | 'description': 'md5:6173f270cd0c0119f22817204b3eb86c', |
562 | 'thumbnail': 'https://i.vimeocdn.com/video/440665496-b2c5aee2b61089442c794f64113a8e8f7d5763c3e6b3ebfaf696ae6413f8b1f4-d_1280', | |
b9c7b1e9 | 563 | 'view_count': int, |
564 | 'comment_count': int, | |
565 | 'like_count': int, | |
79fec976 RA |
566 | }, |
567 | 'params': { | |
681ac7c9 | 568 | 'format': 'best[protocol=https]', |
3867038a | 569 | 'videopassword': 'youtube-dl', |
79fec976 RA |
570 | }, |
571 | }, | |
c143ddce S |
572 | { |
573 | 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741', | |
574 | 'only_matching': True, | |
575 | }, | |
8bea039b LL |
576 | { |
577 | 'url': 'https://vimeo.com/109815029', | |
578 | 'note': 'Video not completely processed, "failed" seed status', | |
579 | 'only_matching': True, | |
580 | }, | |
6b7ceee1 S |
581 | { |
582 | 'url': 'https://vimeo.com/groups/travelhd/videos/22439234', | |
583 | 'only_matching': True, | |
584 | }, | |
c8e3e097 S |
585 | { |
586 | 'url': 'https://vimeo.com/album/2632481/video/79010983', | |
587 | 'only_matching': True, | |
588 | }, | |
1f52a09e | 589 | { |
590 | 'url': 'https://vimeo.com/showcase/3253534/video/119195465', | |
591 | 'note': 'A video in a password protected album (showcase)', | |
592 | 'info_dict': { | |
593 | 'id': '119195465', | |
594 | 'ext': 'mp4', | |
b9c7b1e9 | 595 | 'title': "youtube-dl test video '' ä↭𝕐-BaW jenozKc", |
1f52a09e | 596 | 'uploader': 'Philipp Hagemeister', |
597 | 'uploader_id': 'user20132939', | |
598 | 'description': 'md5:fa7b6c6d8db0bdc353893df2f111855b', | |
599 | 'upload_date': '20150209', | |
600 | 'timestamp': 1423518307, | |
b9c7b1e9 | 601 | 'thumbnail': 'https://i.vimeocdn.com/video/default_1280', |
602 | 'duration': 10, | |
603 | 'like_count': int, | |
604 | 'uploader_url': 'https://vimeo.com/user20132939', | |
605 | 'view_count': int, | |
606 | 'comment_count': int, | |
1f52a09e | 607 | }, |
608 | 'params': { | |
609 | 'format': 'best[protocol=https]', | |
610 | 'videopassword': 'youtube-dl', | |
611 | }, | |
612 | }, | |
16f1131a S |
613 | { |
614 | # source file returns 403: Forbidden | |
615 | 'url': 'https://vimeo.com/7809605', | |
616 | 'only_matching': True, | |
617 | }, | |
241a318f | 618 | { |
2a6f8475 | 619 | 'note': 'Direct URL with hash', |
241a318f | 620 | 'url': 'https://vimeo.com/160743502/abd0e13fb4', |
2a6f8475 | 621 | 'info_dict': { |
622 | 'id': '160743502', | |
623 | 'ext': 'mp4', | |
624 | 'uploader': 'Julian Tryba', | |
625 | 'uploader_id': 'aliniamedia', | |
626 | 'title': 'Harrisville New Hampshire', | |
627 | 'timestamp': 1459259666, | |
628 | 'upload_date': '20160329', | |
b9c7b1e9 | 629 | 'release_timestamp': 1459259666, |
630 | 'license': 'by-nc', | |
631 | 'duration': 159, | |
632 | 'comment_count': int, | |
633 | 'thumbnail': 'https://i.vimeocdn.com/video/562802436-585eeb13b5020c6ac0f171a2234067938098f84737787df05ff0d767f6d54ee9-d_1280', | |
634 | 'like_count': int, | |
635 | 'uploader_url': 'https://vimeo.com/aliniamedia', | |
636 | 'release_date': '20160329', | |
2a6f8475 | 637 | }, |
9cb070f9 | 638 | 'params': {'skip_download': True}, |
639 | }, | |
640 | { | |
641 | 'url': 'https://vimeo.com/138909882', | |
642 | 'info_dict': { | |
643 | 'id': '138909882', | |
644 | 'ext': 'mp4', | |
645 | 'title': 'Eastnor Castle 2015 Firework Champions - The Promo!', | |
646 | 'description': 'md5:5967e090768a831488f6e74b7821b3c1', | |
647 | 'uploader_id': 'fireworkchampions', | |
648 | 'uploader': 'Firework Champions', | |
649 | 'upload_date': '20150910', | |
650 | 'timestamp': 1441901895, | |
651 | }, | |
652 | 'params': { | |
653 | 'skip_download': True, | |
654 | 'format': 'Original', | |
655 | }, | |
bc2ca1bb | 656 | }, |
1ee34c76 | 657 | { |
658 | 'url': 'https://vimeo.com/channels/staffpicks/143603739', | |
659 | 'info_dict': { | |
660 | 'id': '143603739', | |
661 | 'ext': 'mp4', | |
662 | 'uploader': 'Karim Huu Do', | |
663 | 'timestamp': 1445846953, | |
664 | 'upload_date': '20151026', | |
665 | 'title': 'The Shoes - Submarine Feat. Blaine Harrison', | |
666 | 'uploader_id': 'karimhd', | |
667 | 'description': 'md5:8e2eea76de4504c2e8020a9bcfa1e843', | |
b9c7b1e9 | 668 | 'channel_id': 'staffpicks', |
669 | 'duration': 336, | |
670 | 'comment_count': int, | |
671 | 'view_count': int, | |
672 | 'thumbnail': 'https://i.vimeocdn.com/video/541243181-b593db36a16db2f0096f655da3f5a4dc46b8766d77b0f440df937ecb0c418347-d_1280', | |
673 | 'like_count': int, | |
674 | 'uploader_url': 'https://vimeo.com/karimhd', | |
675 | 'channel_url': 'https://vimeo.com/channels/staffpicks', | |
1ee34c76 | 676 | }, |
677 | 'params': {'skip_download': 'm3u8'}, | |
678 | }, | |
bc2ca1bb | 679 | { |
680 | # requires passing unlisted_hash(a52724358e) to load_download_config request | |
681 | 'url': 'https://vimeo.com/392479337/a52724358e', | |
682 | 'only_matching': True, | |
9cb070f9 | 683 | }, |
50e93e03 | 684 | { |
685 | # similar, but all numeric: ID must be 581039021, not 9603038895 | |
686 | # issue #29690 | |
687 | 'url': 'https://vimeo.com/581039021/9603038895', | |
688 | 'info_dict': { | |
689 | 'id': '581039021', | |
50e93e03 | 690 | 'ext': 'mp4', |
691 | 'timestamp': 1627621014, | |
b9c7b1e9 | 692 | 'release_timestamp': 1627621014, |
693 | 'duration': 976, | |
694 | 'comment_count': int, | |
695 | 'thumbnail': 'https://i.vimeocdn.com/video/1202249320-4ddb2c30398c0dc0ee059172d1bd5ea481ad12f0e0e3ad01d2266f56c744b015-d_1280', | |
696 | 'like_count': int, | |
697 | 'uploader_url': 'https://vimeo.com/txwestcapital', | |
698 | 'release_date': '20210730', | |
699 | 'uploader': 'Christopher Inks', | |
700 | 'title': 'Thursday, July 29, 2021 BMA Evening Video Update', | |
701 | 'uploader_id': 'txwestcapital', | |
702 | 'upload_date': '20210730', | |
50e93e03 | 703 | }, |
704 | 'params': { | |
705 | 'skip_download': True, | |
706 | }, | |
45b2ee6f | 707 | }, |
708 | { | |
709 | # user playlist alias -> https://vimeo.com/258705797 | |
710 | 'url': 'https://vimeo.com/user26785108/newspiritualguide', | |
711 | 'only_matching': True, | |
712 | }, | |
a1a46075 S |
713 | # https://gettingthingsdone.com/workflowmap/ |
714 | # vimeo embed with check-password page protected by Referer header | |
a91b954b | 715 | ] |
b3d14cbf | 716 | |
bfd973ec | 717 | @classmethod |
718 | def _extract_embed_urls(cls, url, webpage): | |
719 | for embed_url in super()._extract_embed_urls(url, webpage): | |
720 | yield cls._smuggle_referrer(embed_url, url) | |
b407e173 | 721 | |
4080efeb | 722 | @classmethod |
723 | def _extract_url(cls, url, webpage): | |
724 | return next(cls._extract_embed_urls(url, webpage), None) | |
725 | ||
a1a46075 | 726 | def _verify_player_video_password(self, url, video_id, headers): |
cce889b9 | 727 | password = self._get_video_password() |
79fec976 RA |
728 | data = urlencode_postdata({ |
729 | 'password': base64.b64encode(password.encode()), | |
730 | }) | |
a1a46075 S |
731 | headers = merge_dicts(headers, { |
732 | 'Content-Type': 'application/x-www-form-urlencoded', | |
733 | }) | |
734 | checked = self._download_json( | |
aedaa455 | 735 | f'{compat_urlparse.urlsplit(url)._replace(query=None).geturl()}/check-password', |
736 | video_id, 'Verifying the password', data=data, headers=headers) | |
a1a46075 S |
737 | if checked is False: |
738 | raise ExtractorError('Wrong video password', expected=True) | |
739 | return checked | |
0eecc6a4 | 740 | |
58ab5cbc | 741 | def _extract_from_api(self, video_id, unlisted_hash=None): |
742 | token = self._download_json( | |
743 | 'https://vimeo.com/_rv/jwt', video_id, headers={ | |
744 | 'X-Requested-With': 'XMLHttpRequest' | |
745 | })['token'] | |
746 | api_url = 'https://api.vimeo.com/videos/' + video_id | |
747 | if unlisted_hash: | |
748 | api_url += ':' + unlisted_hash | |
749 | video = self._download_json( | |
750 | api_url, video_id, headers={ | |
751 | 'Authorization': 'jwt ' + token, | |
8e765755 | 752 | 'Accept': 'application/json', |
58ab5cbc | 753 | }, query={ |
754 | 'fields': 'config_url,created_time,description,license,metadata.connections.comments.total,metadata.connections.likes.total,release_time,stats.plays', | |
755 | }) | |
756 | info = self._parse_config(self._download_json( | |
757 | video['config_url'], video_id), video_id) | |
58ab5cbc | 758 | get_timestamp = lambda x: parse_iso8601(video.get(x + '_time')) |
759 | info.update({ | |
760 | 'description': video.get('description'), | |
761 | 'license': video.get('license'), | |
762 | 'release_timestamp': get_timestamp('release'), | |
763 | 'timestamp': get_timestamp('created'), | |
764 | 'view_count': int_or_none(try_get(video, lambda x: x['stats']['plays'])), | |
765 | }) | |
766 | connections = try_get( | |
767 | video, lambda x: x['metadata']['connections'], dict) or {} | |
768 | for k in ('comment', 'like'): | |
769 | info[k + '_count'] = int_or_none(try_get(connections, lambda x: x[k + 's']['total'])) | |
770 | return info | |
771 | ||
1f52a09e | 772 | def _try_album_password(self, url): |
773 | album_id = self._search_regex( | |
774 | r'vimeo\.com/(?:album|showcase)/([^/]+)', url, 'album id', default=None) | |
775 | if not album_id: | |
776 | return | |
777 | viewer = self._download_json( | |
778 | 'https://vimeo.com/_rv/viewer', album_id, fatal=False) | |
779 | if not viewer: | |
780 | webpage = self._download_webpage(url, album_id) | |
781 | viewer = self._parse_json(self._search_regex( | |
782 | r'bootstrap_data\s*=\s*({.+?})</script>', | |
783 | webpage, 'bootstrap data'), album_id)['viewer'] | |
784 | jwt = viewer['jwt'] | |
785 | album = self._download_json( | |
786 | 'https://api.vimeo.com/albums/' + album_id, | |
8e765755 | 787 | album_id, headers={'Authorization': 'jwt ' + jwt, 'Accept': 'application/json'}, |
1f52a09e | 788 | query={'fields': 'description,name,privacy'}) |
789 | if try_get(album, lambda x: x['privacy']['view']) == 'password': | |
a06916d9 | 790 | password = self.get_param('videopassword') |
1f52a09e | 791 | if not password: |
792 | raise ExtractorError( | |
793 | 'This album is protected by a password, use the --video-password option', | |
794 | expected=True) | |
795 | self._set_vimeo_cookie('vuid', viewer['vuid']) | |
796 | try: | |
797 | self._download_json( | |
798 | 'https://vimeo.com/showcase/%s/auth' % album_id, | |
799 | album_id, 'Verifying the password', data=urlencode_postdata({ | |
800 | 'password': password, | |
801 | 'token': viewer['xsrft'], | |
802 | }), headers={ | |
803 | 'X-Requested-With': 'XMLHttpRequest', | |
804 | }) | |
805 | except ExtractorError as e: | |
3d2623a8 | 806 | if isinstance(e.cause, HTTPError) and e.cause.status == 401: |
1f52a09e | 807 | raise ExtractorError('Wrong password', expected=True) |
808 | raise | |
809 | ||
a0088bdf | 810 | def _real_extract(self, url): |
aedaa455 | 811 | url, data, headers = self._unsmuggle_headers(url) |
ba5d51b3 PH |
812 | if 'Referer' not in headers: |
813 | headers['Referer'] = url | |
9d4660ca | 814 | |
b3d14cbf | 815 | # Extract ID from URL |
2a6f8475 | 816 | mobj = self._match_valid_url(url).groupdict() |
817 | video_id, unlisted_hash = mobj['id'], mobj.get('unlisted_hash') | |
cce889b9 | 818 | if unlisted_hash: |
58ab5cbc | 819 | return self._extract_from_api(video_id, unlisted_hash) |
cce889b9 | 820 | |
7ff2fafe | 821 | if any(p in url for p in ('play_redirect_hls', 'moogaloop.swf')): |
10831b5e | 822 | url = 'https://vimeo.com/' + video_id |
b3d14cbf | 823 | |
1f52a09e | 824 | self._try_album_password(url) |
1060425c | 825 | try: |
681ac7c9 RA |
826 | # Retrieve video webpage to extract further information |
827 | webpage, urlh = self._download_webpage_handle( | |
828 | url, video_id, headers=headers) | |
3d2623a8 | 829 | redirect_url = urlh.url |
1060425c | 830 | except ExtractorError as ee: |
3d2623a8 | 831 | if isinstance(ee.cause, HTTPError) and ee.cause.status == 403: |
832 | errmsg = ee.cause.response.read() | |
1060425c PH |
833 | if b'Because of its privacy settings, this video cannot be played here' in errmsg: |
834 | raise ExtractorError( | |
835 | 'Cannot download embed-only video without embedding ' | |
7a5c1cfe | 836 | 'URL. Please call yt-dlp with the URL of the page ' |
1060425c PH |
837 | 'that embeds this video.', |
838 | expected=True) | |
839 | raise | |
b3d14cbf | 840 | |
58ab5cbc | 841 | if '://player.vimeo.com/video/' in url: |
c0cd13fb L |
842 | config = self._search_json( |
843 | r'\b(?:playerC|c)onfig\s*=', webpage, 'info section', video_id) | |
58ab5cbc | 844 | if config.get('view') == 4: |
845 | config = self._verify_player_video_password( | |
846 | redirect_url, video_id, headers) | |
9f14daf2 | 847 | return self._parse_config(config, video_id) |
58ab5cbc | 848 | |
849 | if re.search(r'<form[^>]+?id="pw_form"', webpage): | |
850 | video_password = self._get_video_password() | |
851 | token, vuid = self._extract_xsrft_and_vuid(webpage) | |
852 | webpage = self._verify_video_password( | |
853 | redirect_url, video_id, video_password, token, vuid) | |
b3d14cbf | 854 | |
eb9c9c74 | 855 | vimeo_config = self._extract_vimeo_config(webpage, video_id, default=None) |
998e6cdb | 856 | if vimeo_config: |
58ab5cbc | 857 | seed_status = vimeo_config.get('seed_status') or {} |
998e6cdb S |
858 | if seed_status.get('state') == 'failed': |
859 | raise ExtractorError( | |
b6aa99af | 860 | '%s said: %s' % (self.IE_NAME, seed_status['title']), |
998e6cdb S |
861 | expected=True) |
862 | ||
c38a67bc | 863 | cc_license = None |
c15cd296 | 864 | timestamp = None |
681ac7c9 | 865 | video_description = None |
58ab5cbc | 866 | info_dict = {} |
1ee34c76 | 867 | config_url = None |
c38a67bc | 868 | |
58ab5cbc | 869 | channel_id = self._search_regex( |
870 | r'vimeo\.com/channels/([^/]+)', url, 'channel id', default=None) | |
871 | if channel_id: | |
872 | config_url = self._html_search_regex( | |
1ee34c76 | 873 | r'\bdata-config-url="([^"]+)"', webpage, 'config URL', default=None) |
58ab5cbc | 874 | video_description = clean_html(get_element_by_class('description', webpage)) |
875 | info_dict.update({ | |
876 | 'channel_id': channel_id, | |
877 | 'channel_url': 'https://vimeo.com/channels/' + channel_id, | |
878 | }) | |
1ee34c76 | 879 | if not config_url: |
58ab5cbc | 880 | page_config = self._parse_json(self._search_regex( |
881 | r'vimeo\.(?:clip|vod_title)_page_config\s*=\s*({.+?});', | |
882 | webpage, 'page config', default='{}'), video_id, fatal=False) | |
883 | if not page_config: | |
884 | return self._extract_from_api(video_id) | |
885 | config_url = page_config['player']['config_url'] | |
886 | cc_license = page_config.get('cc_license') | |
887 | clip = page_config.get('clip') or {} | |
888 | timestamp = clip.get('uploaded_on') | |
889 | video_description = clean_html( | |
890 | clip.get('description') or page_config.get('description_html_escaped')) | |
891 | config = self._download_json(config_url, video_id) | |
bc2ca1bb | 892 | video = config.get('video') or {} |
893 | vod = video.get('vod') or {} | |
8b40c927 | 894 | |
6a55bb66 S |
895 | def is_rented(): |
896 | if '>You rented this title.<' in webpage: | |
897 | return True | |
58ab5cbc | 898 | if try_get(config, lambda x: x['user']['purchased']): |
6a55bb66 | 899 | return True |
58ab5cbc | 900 | for purchase_option in (vod.get('purchase_options') or []): |
8b40c927 RA |
901 | if purchase_option.get('purchased'): |
902 | return True | |
903 | label = purchase_option.get('label_string') | |
904 | if label and (label.startswith('You rented this') or label.endswith(' remaining')): | |
905 | return True | |
6a55bb66 S |
906 | return False |
907 | ||
8b40c927 RA |
908 | if is_rented() and vod.get('is_trailer'): |
909 | feature_id = vod.get('feature_id') | |
5dbe81a1 S |
910 | if feature_id and not data.get('force_feature_id', False): |
911 | return self.url_result(smuggle_url( | |
912 | 'https://player.vimeo.com/player/%s' % feature_id, | |
913 | {'force_feature_id': True}), 'Vimeo') | |
914 | ||
681ac7c9 RA |
915 | if not video_description: |
916 | video_description = self._html_search_regex( | |
917 | r'(?s)<div\s+class="[^"]*description[^"]*"[^>]*>(.*?)</div>', | |
918 | webpage, 'description', default=None) | |
58ea7ec8 PH |
919 | if not video_description: |
920 | video_description = self._html_search_meta( | |
58ab5cbc | 921 | ['description', 'og:description', 'twitter:description'], |
922 | webpage, default=None) | |
58ab5cbc | 923 | if not video_description: |
6a39ee13 | 924 | self.report_warning('Cannot find video description') |
b3d14cbf | 925 | |
c15cd296 S |
926 | if not timestamp: |
927 | timestamp = self._search_regex( | |
928 | r'<time[^>]+datetime="([^"]+)"', webpage, | |
929 | 'timestamp', default=None) | |
b3d14cbf | 930 | |
58ab5cbc | 931 | view_count = int_or_none(self._search_regex(r'UserPlays:(\d+)', webpage, 'view count', default=None)) |
932 | like_count = int_or_none(self._search_regex(r'UserLikes:(\d+)', webpage, 'like count', default=None)) | |
933 | comment_count = int_or_none(self._search_regex(r'UserComments:(\d+)', webpage, 'comment count', default=None)) | |
4e761794 | 934 | |
a6387bfd | 935 | formats = [] |
27655037 RA |
936 | |
937 | source_format = self._extract_original_format( | |
bc2ca1bb | 938 | 'https://vimeo.com/' + video_id, video_id, video.get('unlisted_hash')) |
27655037 RA |
939 | if source_format: |
940 | formats.append(source_format) | |
1eac553e | 941 | |
ae1c585c S |
942 | info_dict_config = self._parse_config(config, video_id) |
943 | formats.extend(info_dict_config['formats']) | |
9f14daf2 | 944 | info_dict['_format_sort_fields'] = info_dict_config['_format_sort_fields'] |
c38a67bc | 945 | |
ae1c585c S |
946 | json_ld = self._search_json_ld(webpage, video_id, default={}) |
947 | ||
c38a67bc S |
948 | if not cc_license: |
949 | cc_license = self._search_regex( | |
950 | r'<link[^>]+rel=["\']license["\'][^>]+href=(["\'])(?P<license>(?:(?!\1).)+)\1', | |
951 | webpage, 'license', default=None, group='license') | |
952 | ||
58ab5cbc | 953 | info_dict.update({ |
531a7496 | 954 | 'formats': formats, |
c15cd296 | 955 | 'timestamp': unified_timestamp(timestamp), |
b0268cb6 | 956 | 'description': video_description, |
9103bbc5 | 957 | 'webpage_url': url, |
4e761794 JMF |
958 | 'view_count': view_count, |
959 | 'like_count': like_count, | |
960 | 'comment_count': comment_count, | |
c38a67bc | 961 | 'license': cc_license, |
58ab5cbc | 962 | }) |
531a7496 | 963 | |
58ab5cbc | 964 | return merge_dicts(info_dict, info_dict_config, json_ld) |
caeefc29 JMF |
965 | |
966 | ||
6368e2e6 | 967 | class VimeoOndemandIE(VimeoIE): # XXX: Do not subclass from concrete IE |
1e501364 | 968 | IE_NAME = 'vimeo:ondemand' |
58ab5cbc | 969 | _VALID_URL = r'https?://(?:www\.)?vimeo\.com/ondemand/(?:[^/]+/)?(?P<id>[^/?#&]+)' |
74278def S |
970 | _TESTS = [{ |
971 | # ondemand video not available via https://vimeo.com/id | |
972 | 'url': 'https://vimeo.com/ondemand/20704', | |
973 | 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35', | |
974 | 'info_dict': { | |
975 | 'id': '105442900', | |
976 | 'ext': 'mp4', | |
977 | 'title': 'המעבדה - במאי יותם פלדמן', | |
978 | 'uploader': 'גם סרטים', | |
ec85ded8 | 979 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/gumfilms', |
74278def | 980 | 'uploader_id': 'gumfilms', |
b9c7b1e9 | 981 | 'description': 'md5:aeeba3dbd4d04b0fa98a4fdc9c639998', |
681ac7c9 RA |
982 | 'upload_date': '20140906', |
983 | 'timestamp': 1410032453, | |
b9c7b1e9 | 984 | 'thumbnail': 'https://i.vimeocdn.com/video/488238335-d7bf151c364cff8d467f1b73784668fe60aae28a54573a35d53a1210ae283bd8-d_1280', |
985 | 'comment_count': int, | |
986 | 'license': 'https://creativecommons.org/licenses/by-nc-nd/3.0/', | |
987 | 'duration': 53, | |
988 | 'view_count': int, | |
989 | 'like_count': int, | |
74278def | 990 | }, |
1fd0fc42 S |
991 | 'params': { |
992 | 'format': 'best[protocol=https]', | |
993 | }, | |
681ac7c9 | 994 | 'expected_warnings': ['Unable to download JSON metadata'], |
d002e919 S |
995 | }, { |
996 | # requires Referer to be passed along with og:video:url | |
997 | 'url': 'https://vimeo.com/ondemand/36938/126682985', | |
998 | 'info_dict': { | |
681ac7c9 | 999 | 'id': '126584684', |
d002e919 S |
1000 | 'ext': 'mp4', |
1001 | 'title': 'Rävlock, rätt läte på rätt plats', | |
1002 | 'uploader': 'Lindroth & Norin', | |
681ac7c9 RA |
1003 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/lindrothnorin', |
1004 | 'uploader_id': 'lindrothnorin', | |
1005 | 'description': 'md5:c3c46a90529612c8279fb6af803fc0df', | |
1006 | 'upload_date': '20150502', | |
1007 | 'timestamp': 1430586422, | |
b9c7b1e9 | 1008 | 'duration': 121, |
1009 | 'comment_count': int, | |
1010 | 'view_count': int, | |
1011 | 'thumbnail': 'https://i.vimeocdn.com/video/517077723-7066ae1d9a79d3eb361334fb5d58ec13c8f04b52f8dd5eadfbd6fb0bcf11f613-d_1280', | |
1012 | 'like_count': int, | |
d002e919 S |
1013 | }, |
1014 | 'params': { | |
1015 | 'skip_download': True, | |
1016 | }, | |
681ac7c9 | 1017 | 'expected_warnings': ['Unable to download JSON metadata'], |
74278def S |
1018 | }, { |
1019 | 'url': 'https://vimeo.com/ondemand/nazmaalik', | |
1020 | 'only_matching': True, | |
1021 | }, { | |
1022 | 'url': 'https://vimeo.com/ondemand/141692381', | |
1023 | 'only_matching': True, | |
1024 | }, { | |
1025 | 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832', | |
1026 | 'only_matching': True, | |
1027 | }] | |
1028 | ||
74278def | 1029 | |
f6c3664d | 1030 | class VimeoChannelIE(VimeoBaseInfoExtractor): |
9148eb00 | 1031 | IE_NAME = 'vimeo:channel' |
3946864c | 1032 | _VALID_URL = r'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])' |
caeefc29 | 1033 | _MORE_PAGES_INDICATOR = r'<a.+?rel="next"' |
84458766 | 1034 | _TITLE = None |
55a10eab | 1035 | _TITLE_RE = r'<link rel="alternate"[^>]+?title="(.*?)"' |
2929b3e7 | 1036 | _TESTS = [{ |
3946864c | 1037 | 'url': 'https://vimeo.com/channels/tributes', |
2929b3e7 | 1038 | 'info_dict': { |
a3fa5da4 | 1039 | 'id': 'tributes', |
2929b3e7 PH |
1040 | 'title': 'Vimeo Tributes', |
1041 | }, | |
b9c7b1e9 | 1042 | 'playlist_mincount': 22, |
2929b3e7 | 1043 | }] |
681ac7c9 | 1044 | _BASE_URL_TEMPL = 'https://vimeo.com/channels/%s' |
caeefc29 | 1045 | |
5cc14c2f JMF |
1046 | def _page_url(self, base_url, pagenum): |
1047 | return '%s/videos/page:%d/' % (base_url, pagenum) | |
1048 | ||
fb30ec22 | 1049 | def _extract_list_title(self, webpage): |
2605043d S |
1050 | return self._TITLE or self._html_search_regex( |
1051 | self._TITLE_RE, webpage, 'list title', fatal=False) | |
fb30ec22 | 1052 | |
2c94198e | 1053 | def _title_and_entries(self, list_id, base_url): |
caeefc29 | 1054 | for pagenum in itertools.count(1): |
bf8f082a | 1055 | page_url = self._page_url(base_url, pagenum) |
55a10eab | 1056 | webpage = self._download_webpage( |
bf8f082a | 1057 | page_url, list_id, |
9148eb00 | 1058 | 'Downloading page %s' % pagenum) |
bf8f082a PH |
1059 | |
1060 | if pagenum == 1: | |
2c94198e S |
1061 | yield self._extract_list_title(webpage) |
1062 | ||
c8e3e097 S |
1063 | # Try extracting href first since not all videos are available via |
1064 | # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729) | |
1065 | clips = re.findall( | |
04a3d4d2 | 1066 | r'id="clip_(\d+)"[^>]*>\s*<a[^>]+href="(/(?:[^/]+/)*\1)(?:[^>]+\btitle="([^"]+)")?', webpage) |
c8e3e097 | 1067 | if clips: |
04a3d4d2 | 1068 | for video_id, video_url, video_title in clips: |
c8e3e097 S |
1069 | yield self.url_result( |
1070 | compat_urlparse.urljoin(base_url, video_url), | |
04a3d4d2 | 1071 | VimeoIE.ie_key(), video_id=video_id, video_title=video_title) |
c8e3e097 S |
1072 | # More relaxed fallback |
1073 | else: | |
1074 | for video_id in re.findall(r'id=["\']clip_(\d+)', webpage): | |
1075 | yield self.url_result( | |
1076 | 'https://vimeo.com/%s' % video_id, | |
1077 | VimeoIE.ie_key(), video_id=video_id) | |
bf8f082a | 1078 | |
caeefc29 JMF |
1079 | if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None: |
1080 | break | |
1081 | ||
2c94198e S |
1082 | def _extract_videos(self, list_id, base_url): |
1083 | title_and_entries = self._title_and_entries(list_id, base_url) | |
1084 | list_title = next(title_and_entries) | |
1085 | return self.playlist_result(title_and_entries, list_id, list_title) | |
55a10eab JMF |
1086 | |
1087 | def _real_extract(self, url): | |
681ac7c9 RA |
1088 | channel_id = self._match_id(url) |
1089 | return self._extract_videos(channel_id, self._BASE_URL_TEMPL % channel_id) | |
55a10eab JMF |
1090 | |
1091 | ||
6368e2e6 | 1092 | class VimeoUserIE(VimeoChannelIE): # XXX: Do not subclass from concrete IE |
9148eb00 | 1093 | IE_NAME = 'vimeo:user' |
1d64a595 | 1094 | _VALID_URL = r'https://vimeo\.com/(?!(?:[0-9]+|watchlater)(?:$|[?#/]))(?P<id>[^/]+)(?:/videos)?/?(?:$|[?#])' |
55a10eab | 1095 | _TITLE_RE = r'<a[^>]+?class="user">([^<>]+?)</a>' |
2929b3e7 | 1096 | _TESTS = [{ |
3946864c | 1097 | 'url': 'https://vimeo.com/nkistudio/videos', |
2929b3e7 PH |
1098 | 'info_dict': { |
1099 | 'title': 'Nki', | |
a3fa5da4 | 1100 | 'id': 'nkistudio', |
2929b3e7 PH |
1101 | }, |
1102 | 'playlist_mincount': 66, | |
1d64a595 | 1103 | }, { |
1104 | 'url': 'https://vimeo.com/nkistudio/', | |
1105 | 'only_matching': True, | |
2929b3e7 | 1106 | }] |
681ac7c9 | 1107 | _BASE_URL_TEMPL = 'https://vimeo.com/%s' |
5cc14c2f JMF |
1108 | |
1109 | ||
51c7f40c | 1110 | class VimeoAlbumIE(VimeoBaseInfoExtractor): |
9148eb00 | 1111 | IE_NAME = 'vimeo:album' |
eb9c9c74 | 1112 | _VALID_URL = r'https://vimeo\.com/(?:album|showcase)/(?P<id>\d+)(?:$|[?#]|/(?!video))' |
5cc14c2f | 1113 | _TITLE_RE = r'<header id="page_header">\n\s*<h1>(.*?)</h1>' |
2929b3e7 | 1114 | _TESTS = [{ |
d1508cd6 | 1115 | 'url': 'https://vimeo.com/album/2632481', |
2929b3e7 | 1116 | 'info_dict': { |
a3fa5da4 | 1117 | 'id': '2632481', |
2929b3e7 PH |
1118 | 'title': 'Staff Favorites: November 2013', |
1119 | }, | |
1120 | 'playlist_mincount': 13, | |
bf8f082a PH |
1121 | }, { |
1122 | 'note': 'Password-protected album', | |
1123 | 'url': 'https://vimeo.com/album/3253534', | |
1124 | 'info_dict': { | |
1125 | 'title': 'test', | |
1126 | 'id': '3253534', | |
1127 | }, | |
1128 | 'playlist_count': 1, | |
1129 | 'params': { | |
3867038a | 1130 | 'videopassword': 'youtube-dl', |
bf8f082a | 1131 | } |
2929b3e7 | 1132 | }] |
eb9c9c74 RA |
1133 | _PAGE_SIZE = 100 |
1134 | ||
a0566bbf | 1135 | def _fetch_page(self, album_id, authorization, hashed_pass, page): |
eb9c9c74 RA |
1136 | api_page = page + 1 |
1137 | query = { | |
974311b5 | 1138 | 'fields': 'link,uri', |
eb9c9c74 RA |
1139 | 'page': api_page, |
1140 | 'per_page': self._PAGE_SIZE, | |
1141 | } | |
1142 | if hashed_pass: | |
1143 | query['_hashed_pass'] = hashed_pass | |
421a4595 | 1144 | try: |
1145 | videos = self._download_json( | |
1146 | 'https://api.vimeo.com/albums/%s/videos' % album_id, | |
1147 | album_id, 'Downloading page %d' % api_page, query=query, headers={ | |
1148 | 'Authorization': 'jwt ' + authorization, | |
8e765755 | 1149 | 'Accept': 'application/json', |
421a4595 | 1150 | })['data'] |
1151 | except ExtractorError as e: | |
3d2623a8 | 1152 | if isinstance(e.cause, HTTPError) and e.cause.status == 400: |
421a4595 | 1153 | return |
8e765755 | 1154 | raise |
eb9c9c74 RA |
1155 | for video in videos: |
1156 | link = video.get('link') | |
1157 | if not link: | |
1158 | continue | |
974311b5 RA |
1159 | uri = video.get('uri') |
1160 | video_id = self._search_regex(r'/videos/(\d+)', uri, 'video_id', default=None) if uri else None | |
1161 | yield self.url_result(link, VimeoIE.ie_key(), video_id) | |
5cc14c2f JMF |
1162 | |
1163 | def _real_extract(self, url): | |
bf8f082a | 1164 | album_id = self._match_id(url) |
8bdd16b4 | 1165 | viewer = self._download_json( |
1166 | 'https://vimeo.com/_rv/viewer', album_id, fatal=False) | |
1167 | if not viewer: | |
1168 | webpage = self._download_webpage(url, album_id) | |
1169 | viewer = self._parse_json(self._search_regex( | |
1170 | r'bootstrap_data\s*=\s*({.+?})</script>', | |
1171 | webpage, 'bootstrap data'), album_id)['viewer'] | |
51c7f40c RA |
1172 | jwt = viewer['jwt'] |
1173 | album = self._download_json( | |
1174 | 'https://api.vimeo.com/albums/' + album_id, | |
8e765755 | 1175 | album_id, headers={'Authorization': 'jwt ' + jwt, 'Accept': 'application/json'}, |
51c7f40c RA |
1176 | query={'fields': 'description,name,privacy'}) |
1177 | hashed_pass = None | |
1178 | if try_get(album, lambda x: x['privacy']['view']) == 'password': | |
a06916d9 | 1179 | password = self.get_param('videopassword') |
51c7f40c RA |
1180 | if not password: |
1181 | raise ExtractorError( | |
1182 | 'This album is protected by a password, use the --video-password option', | |
1183 | expected=True) | |
1184 | self._set_vimeo_cookie('vuid', viewer['vuid']) | |
1185 | try: | |
1186 | hashed_pass = self._download_json( | |
1187 | 'https://vimeo.com/showcase/%s/auth' % album_id, | |
1188 | album_id, 'Verifying the password', data=urlencode_postdata({ | |
1189 | 'password': password, | |
1190 | 'token': viewer['xsrft'], | |
1191 | }), headers={ | |
1192 | 'X-Requested-With': 'XMLHttpRequest', | |
1193 | })['hashed_pass'] | |
1194 | except ExtractorError as e: | |
3d2623a8 | 1195 | if isinstance(e.cause, HTTPError) and e.cause.status == 401: |
51c7f40c RA |
1196 | raise ExtractorError('Wrong password', expected=True) |
1197 | raise | |
eb9c9c74 | 1198 | entries = OnDemandPagedList(functools.partial( |
51c7f40c RA |
1199 | self._fetch_page, album_id, jwt, hashed_pass), self._PAGE_SIZE) |
1200 | return self.playlist_result( | |
1201 | entries, album_id, album.get('name'), album.get('description')) | |
fb30ec22 JMF |
1202 | |
1203 | ||
6368e2e6 | 1204 | class VimeoGroupsIE(VimeoChannelIE): # XXX: Do not subclass from concrete IE |
9148eb00 | 1205 | IE_NAME = 'vimeo:group' |
681ac7c9 | 1206 | _VALID_URL = r'https://vimeo\.com/groups/(?P<id>[^/]+)(?:/(?!videos?/\d+)|$)' |
2929b3e7 | 1207 | _TESTS = [{ |
9cb070f9 | 1208 | 'url': 'https://vimeo.com/groups/meetup', |
2929b3e7 | 1209 | 'info_dict': { |
9cb070f9 | 1210 | 'id': 'meetup', |
1211 | 'title': 'Vimeo Meetup!', | |
2929b3e7 | 1212 | }, |
681ac7c9 | 1213 | 'playlist_mincount': 27, |
2929b3e7 | 1214 | }] |
681ac7c9 | 1215 | _BASE_URL_TEMPL = 'https://vimeo.com/groups/%s' |
fcea44c6 PH |
1216 | |
1217 | ||
531a7496 | 1218 | class VimeoReviewIE(VimeoBaseInfoExtractor): |
9148eb00 PH |
1219 | IE_NAME = 'vimeo:review' |
1220 | IE_DESC = 'Review pages on vimeo' | |
27655037 | 1221 | _VALID_URL = r'(?P<url>https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)/[0-9a-f]{10})' |
d36d3f42 | 1222 | _TESTS = [{ |
fcea44c6 | 1223 | 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d', |
fcea44c6 PH |
1224 | 'md5': 'c507a72f780cacc12b2248bb4006d253', |
1225 | 'info_dict': { | |
fc09240e PH |
1226 | 'id': '75524534', |
1227 | 'ext': 'mp4', | |
fcea44c6 PH |
1228 | 'title': "DICK HARDWICK 'Comedian'", |
1229 | 'uploader': 'Richard Hardwick', | |
531a7496 | 1230 | 'uploader_id': 'user21297594', |
681ac7c9 | 1231 | 'description': "Comedian Dick Hardwick's five minute demo filmed in front of a live theater audience.\nEdit by Doug Mattocks", |
b9c7b1e9 | 1232 | 'duration': 304, |
1233 | 'thumbnail': 'https://i.vimeocdn.com/video/450115033-43303819d9ebe24c2630352e18b7056d25197d09b3ae901abdac4c4f1d68de71-d_1280', | |
1234 | 'uploader_url': 'https://vimeo.com/user21297594', | |
681ac7c9 | 1235 | }, |
d36d3f42 PH |
1236 | }, { |
1237 | 'note': 'video player needs Referer', | |
3946864c | 1238 | 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053', |
d36d3f42 PH |
1239 | 'md5': '6295fdab8f4bf6a002d058b2c6dce276', |
1240 | 'info_dict': { | |
1241 | 'id': '91613211', | |
1242 | 'ext': 'mp4', | |
9dec9930 | 1243 | 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn', |
d36d3f42 PH |
1244 | 'uploader': 'DevWeek Events', |
1245 | 'duration': 2773, | |
ec85ded8 | 1246 | 'thumbnail': r're:^https?://.*\.jpg$', |
531a7496 | 1247 | 'uploader_id': 'user22258446', |
681ac7c9 RA |
1248 | }, |
1249 | 'skip': 'video gone', | |
c1ff6e1a YCH |
1250 | }, { |
1251 | 'note': 'Password protected', | |
1252 | 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde', | |
1253 | 'info_dict': { | |
1254 | 'id': '138823582', | |
1255 | 'ext': 'mp4', | |
1256 | 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1', | |
1257 | 'uploader': 'TMB', | |
1258 | 'uploader_id': 'user37284429', | |
1259 | }, | |
1260 | 'params': { | |
1261 | 'videopassword': 'holygrail', | |
1262 | }, | |
a093cfc7 | 1263 | 'skip': 'video gone', |
d36d3f42 | 1264 | }] |
fcea44c6 PH |
1265 | |
1266 | def _real_extract(self, url): | |
5ad28e7f | 1267 | page_url, video_id = self._match_valid_url(url).groups() |
cce889b9 | 1268 | data = self._download_json( |
1269 | page_url.replace('/review/', '/review/data/'), video_id) | |
1270 | if data.get('isLocked') is True: | |
1271 | video_password = self._get_video_password() | |
1272 | viewer = self._download_json( | |
1273 | 'https://vimeo.com/_rv/viewer', video_id) | |
1274 | webpage = self._verify_video_password( | |
1275 | 'https://vimeo.com/' + video_id, video_id, | |
1276 | video_password, viewer['xsrft'], viewer['vuid']) | |
1277 | clip_page_config = self._parse_json(self._search_regex( | |
1278 | r'window\.vimeo\.clip_page_config\s*=\s*({.+?});', | |
1279 | webpage, 'clip page config'), video_id) | |
1280 | config_url = clip_page_config['player']['config_url'] | |
1281 | clip_data = clip_page_config.get('clip') or {} | |
1282 | else: | |
1283 | clip_data = data['clipData'] | |
1284 | config_url = clip_data['configUrl'] | |
c1ff6e1a | 1285 | config = self._download_json(config_url, video_id) |
531a7496 | 1286 | info_dict = self._parse_config(config, video_id) |
681ac7c9 RA |
1287 | source_format = self._extract_original_format( |
1288 | page_url + '/action', video_id) | |
27655037 RA |
1289 | if source_format: |
1290 | info_dict['formats'].append(source_format) | |
681ac7c9 | 1291 | info_dict['description'] = clean_html(clip_data.get('description')) |
531a7496 | 1292 | return info_dict |
efb7e119 JMF |
1293 | |
1294 | ||
6368e2e6 | 1295 | class VimeoWatchLaterIE(VimeoChannelIE): # XXX: Do not subclass from concrete IE |
efb7e119 | 1296 | IE_NAME = 'vimeo:watchlater' |
8dcce6a8 | 1297 | IE_DESC = 'Vimeo watch later list, ":vimeowatchlater" keyword (requires authentication)' |
84458766 S |
1298 | _VALID_URL = r'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater' |
1299 | _TITLE = 'Watch Later' | |
efb7e119 | 1300 | _LOGIN_REQUIRED = True |
2929b3e7 | 1301 | _TESTS = [{ |
84458766 | 1302 | 'url': 'https://vimeo.com/watchlater', |
2929b3e7 PH |
1303 | 'only_matching': True, |
1304 | }] | |
efb7e119 | 1305 | |
efb7e119 JMF |
1306 | def _page_url(self, base_url, pagenum): |
1307 | url = '%s/page:%d/' % (base_url, pagenum) | |
3d2623a8 | 1308 | request = Request(url) |
efb7e119 JMF |
1309 | # Set the header to get a partial html page with the ids, |
1310 | # the normal page doesn't contain them. | |
3d2623a8 | 1311 | request.headers['X-Requested-With'] = 'XMLHttpRequest' |
efb7e119 JMF |
1312 | return request |
1313 | ||
1314 | def _real_extract(self, url): | |
84458766 | 1315 | return self._extract_videos('watchlater', 'https://vimeo.com/watchlater') |
d6e6a422 PH |
1316 | |
1317 | ||
6368e2e6 | 1318 | class VimeoLikesIE(VimeoChannelIE): # XXX: Do not subclass from concrete IE |
361a965b | 1319 | _VALID_URL = r'https://(?:www\.)?vimeo\.com/(?P<id>[^/]+)/likes/?(?:$|[?#]|sort:)' |
d6e6a422 PH |
1320 | IE_NAME = 'vimeo:likes' |
1321 | IE_DESC = 'Vimeo user likes' | |
361a965b | 1322 | _TESTS = [{ |
9c44d242 PH |
1323 | 'url': 'https://vimeo.com/user755559/likes/', |
1324 | 'playlist_mincount': 293, | |
611c1dd9 | 1325 | 'info_dict': { |
091c9b43 S |
1326 | 'id': 'user755559', |
1327 | 'title': 'urza’s Likes', | |
d6e6a422 | 1328 | }, |
361a965b S |
1329 | }, { |
1330 | 'url': 'https://vimeo.com/stormlapse/likes', | |
1331 | 'only_matching': True, | |
1332 | }] | |
d6e6a422 | 1333 | |
091c9b43 S |
1334 | def _page_url(self, base_url, pagenum): |
1335 | return '%s/page:%d/' % (base_url, pagenum) | |
1336 | ||
d6e6a422 PH |
1337 | def _real_extract(self, url): |
1338 | user_id = self._match_id(url) | |
091c9b43 | 1339 | return self._extract_videos(user_id, 'https://vimeo.com/%s/likes' % user_id) |
ca01d178 RA |
1340 | |
1341 | ||
a1ee23e9 | 1342 | class VHXEmbedIE(VimeoBaseInfoExtractor): |
ca01d178 RA |
1343 | IE_NAME = 'vhx:embed' |
1344 | _VALID_URL = r'https?://embed\.vhx\.tv/videos/(?P<id>\d+)' | |
bfd973ec | 1345 | _EMBED_REGEX = [r'<iframe[^>]+src="(?P<url>https?://embed\.vhx\.tv/videos/\d+[^"]*)"'] |
ca01d178 | 1346 | |
bfd973ec | 1347 | @classmethod |
1348 | def _extract_embed_urls(cls, url, webpage): | |
1349 | for embed_url in super()._extract_embed_urls(url, webpage): | |
1350 | yield cls._smuggle_referrer(embed_url, url) | |
29f7c58a | 1351 | |
ca01d178 RA |
1352 | def _real_extract(self, url): |
1353 | video_id = self._match_id(url) | |
aedaa455 | 1354 | url, _, headers = self._unsmuggle_headers(url) |
1355 | webpage = self._download_webpage(url, video_id, headers=headers) | |
a1ee23e9 RA |
1356 | config_url = self._parse_json(self._search_regex( |
1357 | r'window\.OTTData\s*=\s*({.+})', webpage, | |
1358 | 'ott data'), video_id, js_to_json)['config_url'] | |
1359 | config = self._download_json(config_url, video_id) | |
1360 | info = self._parse_config(config, video_id) | |
29f7c58a | 1361 | info['id'] = video_id |
a1ee23e9 | 1362 | return info |
7ff2fafe | 1363 | |
1364 | ||
1365 | class VimeoProIE(VimeoBaseInfoExtractor): | |
1366 | IE_NAME = 'vimeo:pro' | |
1367 | _VALID_URL = r'https?://(?:www\.)?vimeopro\.com/[^/?#]+/(?P<slug>[^/?#]+)(?:(?:/videos?/(?P<id>[0-9]+)))?' | |
1368 | _TESTS = [{ | |
1369 | # Vimeo URL derived from video_id | |
1370 | 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876', | |
1371 | 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82', | |
1372 | 'note': 'Vimeo Pro video (#1197)', | |
1373 | 'info_dict': { | |
1374 | 'id': '68093876', | |
1375 | 'ext': 'mp4', | |
1376 | 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/openstreetmapus', | |
1377 | 'uploader_id': 'openstreetmapus', | |
1378 | 'uploader': 'OpenStreetMap US', | |
1379 | 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography', | |
1380 | 'description': 'md5:2c362968038d4499f4d79f88458590c1', | |
1381 | 'duration': 1595, | |
1382 | 'upload_date': '20130610', | |
1383 | 'timestamp': 1370893156, | |
1384 | 'license': 'by', | |
1385 | 'thumbnail': 'https://i.vimeocdn.com/video/440260469-19b0d92fca3bd84066623b53f1eb8aaa3980c6c809e2d67b6b39ab7b4a77a344-d_960', | |
1386 | 'view_count': int, | |
1387 | 'comment_count': int, | |
1388 | 'like_count': int, | |
1389 | 'tags': 'count:1', | |
1390 | }, | |
1391 | 'params': { | |
1392 | 'format': 'best[protocol=https]', | |
1393 | }, | |
1394 | }, { | |
1395 | # password-protected VimeoPro page with Vimeo player embed | |
1396 | 'url': 'https://vimeopro.com/cadfem/simulation-conference-mechanische-systeme-in-perfektion', | |
1397 | 'info_dict': { | |
1398 | 'id': '764543723', | |
1399 | 'ext': 'mp4', | |
1400 | 'title': 'Mechanische Systeme in Perfektion: Realität erfassen, Innovation treiben', | |
1401 | 'thumbnail': 'https://i.vimeocdn.com/video/1543784598-a1a750494a485e601110136b9fe11e28c2131942452b3a5d30391cb3800ca8fd-d_1280', | |
1402 | 'description': 'md5:2a9d195cd1b0f6f79827107dc88c2420', | |
1403 | 'uploader': 'CADFEM', | |
1404 | 'uploader_id': 'cadfem', | |
1405 | 'uploader_url': 'https://vimeo.com/cadfem', | |
1406 | 'duration': 12505, | |
1407 | 'chapters': 'count:10', | |
1408 | }, | |
1409 | 'params': { | |
1410 | 'videopassword': 'Conference2022', | |
1411 | 'skip_download': True, | |
1412 | }, | |
1413 | }] | |
1414 | ||
1415 | def _real_extract(self, url): | |
1416 | display_id, video_id = self._match_valid_url(url).group('slug', 'id') | |
1417 | if video_id: | |
1418 | display_id = video_id | |
1419 | webpage = self._download_webpage(url, display_id) | |
1420 | ||
1421 | password_form = self._search_regex( | |
1422 | r'(?is)<form[^>]+?method=["\']post["\'][^>]*>(.+?password.+?)</form>', | |
1423 | webpage, 'password form', default=None) | |
1424 | if password_form: | |
1425 | try: | |
1426 | webpage = self._download_webpage(url, display_id, data=urlencode_postdata({ | |
1427 | 'password': self._get_video_password(), | |
1428 | **self._hidden_inputs(password_form), | |
1429 | }), note='Logging in with video password') | |
1430 | except ExtractorError as e: | |
3d2623a8 | 1431 | if isinstance(e.cause, HTTPError) and e.cause.status == 418: |
7ff2fafe | 1432 | raise ExtractorError('Wrong video password', expected=True) |
1433 | raise | |
1434 | ||
1435 | description = None | |
1436 | # even if we have video_id, some videos require player URL with portfolio_id query param | |
1437 | # https://github.com/ytdl-org/youtube-dl/issues/20070 | |
1438 | vimeo_url = VimeoIE._extract_url(url, webpage) | |
1439 | if vimeo_url: | |
1440 | description = self._html_search_meta('description', webpage, default=None) | |
1441 | elif video_id: | |
1442 | vimeo_url = f'https://vimeo.com/{video_id}' | |
1443 | else: | |
1444 | raise ExtractorError( | |
1445 | 'No Vimeo embed or video ID could be found in VimeoPro page', expected=True) | |
1446 | ||
1447 | return self.url_result(vimeo_url, VimeoIE, video_id, url_transparent=True, | |
1448 | description=description) |