[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / vimeo.py
blob0ed7b9ec1fe4aa889af2e79bdd30caf616e71fea
1 import base64
2 import functools
3 import itertools
4 import json
5 import re
6 import urllib.parse
8 from .common import InfoExtractor
9 from ..networking import HEADRequest, Request
10 from ..networking.exceptions import HTTPError
11 from ..utils import (
12 ExtractorError,
13 OnDemandPagedList,
14 clean_html,
15 determine_ext,
16 get_element_by_class,
17 int_or_none,
18 join_nonempty,
19 js_to_json,
20 merge_dicts,
21 parse_filesize,
22 parse_iso8601,
23 parse_qs,
24 qualities,
25 smuggle_url,
26 str_or_none,
27 traverse_obj,
28 try_get,
29 unified_timestamp,
30 unsmuggle_url,
31 urlencode_postdata,
32 urlhandle_detect_ext,
33 urljoin,
37 class VimeoBaseInfoExtractor(InfoExtractor):
38 _NETRC_MACHINE = 'vimeo'
39 _LOGIN_REQUIRED = False
40 _LOGIN_URL = 'https://vimeo.com/log_in'
42 @staticmethod
43 def _smuggle_referrer(url, referrer_url):
44 return smuggle_url(url, {'referer': referrer_url})
46 def _unsmuggle_headers(self, url):
47 """@returns (url, smuggled_data, headers)"""
48 url, data = unsmuggle_url(url, {})
49 headers = self.get_param('http_headers').copy()
50 if 'referer' in data:
51 headers['Referer'] = data['referer']
52 return url, data, headers
54 def _perform_login(self, username, password):
55 viewer = self._download_json('https://vimeo.com/_next/viewer', None, 'Downloading login token')
56 data = {
57 'action': 'login',
58 'email': username,
59 'password': password,
60 'service': 'vimeo',
61 'token': viewer['xsrft'],
63 self._set_vimeo_cookie('vuid', viewer['vuid'])
64 try:
65 self._download_webpage(
66 self._LOGIN_URL, None, 'Logging in',
67 data=urlencode_postdata(data), headers={
68 'Content-Type': 'application/x-www-form-urlencoded',
69 'Referer': self._LOGIN_URL,
71 except ExtractorError as e:
72 if isinstance(e.cause, HTTPError) and e.cause.status == 418:
73 raise ExtractorError(
74 'Unable to log in: bad username or password',
75 expected=True)
76 raise ExtractorError('Unable to log in')
78 def _real_initialize(self):
79 if self._LOGIN_REQUIRED and not self._get_cookies('https://vimeo.com').get('vuid'):
80 self._raise_login_required()
82 def _get_video_password(self):
83 password = self.get_param('videopassword')
84 if password is None:
85 raise ExtractorError(
86 'This video is protected by a password, use the --video-password option',
87 expected=True)
88 return password
90 def _verify_video_password(self, video_id, password, token):
91 url = f'https://vimeo.com/{video_id}'
92 try:
93 return self._download_webpage(
94 f'{url}/password', video_id,
95 'Submitting video password', data=json.dumps({
96 'password': password,
97 'token': token,
98 }, separators=(',', ':')).encode(), headers={
99 'Accept': '*/*',
100 'Content-Type': 'application/json',
101 'Referer': url,
102 }, impersonate=True)
103 except ExtractorError as error:
104 if isinstance(error.cause, HTTPError) and error.cause.status == 418:
105 raise ExtractorError('Wrong password', expected=True)
106 raise
108 def _extract_vimeo_config(self, webpage, video_id, *args, **kwargs):
109 vimeo_config = self._search_regex(
110 r'vimeo\.config\s*=\s*(?:({.+?})|_extend\([^,]+,\s+({.+?})\));',
111 webpage, 'vimeo config', *args, **kwargs)
112 if vimeo_config:
113 return self._parse_json(vimeo_config, video_id)
115 def _set_vimeo_cookie(self, name, value):
116 self._set_cookie('vimeo.com', name, value)
118 def _parse_config(self, config, video_id):
119 video_data = config['video']
120 video_title = video_data.get('title')
121 live_event = video_data.get('live_event') or {}
122 live_status = {
123 'pending': 'is_upcoming',
124 'active': 'is_upcoming',
125 'started': 'is_live',
126 'ended': 'post_live',
127 }.get(live_event.get('status'))
128 is_live = live_status == 'is_live'
129 request = config.get('request') or {}
131 formats = []
132 subtitles = {}
134 config_files = video_data.get('files') or request.get('files') or {}
135 for f in (config_files.get('progressive') or []):
136 video_url = f.get('url')
137 if not video_url:
138 continue
139 formats.append({
140 'url': video_url,
141 'format_id': 'http-{}'.format(f.get('quality')),
142 'source_preference': 10,
143 'width': int_or_none(f.get('width')),
144 'height': int_or_none(f.get('height')),
145 'fps': int_or_none(f.get('fps')),
146 'tbr': int_or_none(f.get('bitrate')),
149 # TODO: fix handling of 308 status code returned for live archive manifest requests
150 QUALITIES = ('low', 'medium', 'high')
151 quality = qualities(QUALITIES)
152 sep_pattern = r'/sep/video/'
153 for files_type in ('hls', 'dash'):
154 for cdn_name, cdn_data in (try_get(config_files, lambda x: x[files_type]['cdns']) or {}).items():
155 manifest_url = cdn_data.get('url')
156 if not manifest_url:
157 continue
158 format_id = f'{files_type}-{cdn_name}'
159 sep_manifest_urls = []
160 if re.search(sep_pattern, manifest_url):
161 for suffix, repl in (('', 'video'), ('_sep', 'sep/video')):
162 sep_manifest_urls.append((format_id + suffix, re.sub(
163 sep_pattern, f'/{repl}/', manifest_url)))
164 else:
165 sep_manifest_urls = [(format_id, manifest_url)]
166 for f_id, m_url in sep_manifest_urls:
167 if files_type == 'hls':
168 fmts, subs = self._extract_m3u8_formats_and_subtitles(
169 m_url, video_id, 'mp4', live=is_live, m3u8_id=f_id,
170 note=f'Downloading {cdn_name} m3u8 information',
171 fatal=False)
172 # m3u8 doesn't give audio bitrates; need to prioritize based on GROUP-ID
173 # See: https://github.com/yt-dlp/yt-dlp/issues/10854
174 for f in fmts:
175 if mobj := re.search(rf'audio-({"|".join(QUALITIES)})', f['format_id']):
176 f['quality'] = quality(mobj.group(1))
177 formats.extend(fmts)
178 self._merge_subtitles(subs, target=subtitles)
179 elif files_type == 'dash':
180 if 'json=1' in m_url:
181 real_m_url = (self._download_json(m_url, video_id, fatal=False) or {}).get('url')
182 if real_m_url:
183 m_url = real_m_url
184 fmts, subs = self._extract_mpd_formats_and_subtitles(
185 m_url.replace('/master.json', '/master.mpd'), video_id, f_id,
186 f'Downloading {cdn_name} MPD information',
187 fatal=False)
188 formats.extend(fmts)
189 self._merge_subtitles(subs, target=subtitles)
191 live_archive = live_event.get('archive') or {}
192 live_archive_source_url = live_archive.get('source_url')
193 if live_archive_source_url and live_archive.get('status') == 'done':
194 formats.append({
195 'format_id': 'live-archive-source',
196 'url': live_archive_source_url,
197 'quality': 10,
200 for tt in (request.get('text_tracks') or []):
201 subtitles.setdefault(tt['lang'], []).append({
202 'ext': 'vtt',
203 'url': urljoin('https://vimeo.com', tt['url']),
206 thumbnails = []
207 if not is_live:
208 for key, thumb in (video_data.get('thumbs') or {}).items():
209 thumbnails.append({
210 'id': key,
211 'width': int_or_none(key),
212 'url': thumb,
214 thumbnail = video_data.get('thumbnail')
215 if thumbnail:
216 thumbnails.append({
217 'url': thumbnail,
220 owner = video_data.get('owner') or {}
221 video_uploader_url = owner.get('url')
223 return {
224 'id': str_or_none(video_data.get('id')) or video_id,
225 'title': video_title,
226 'uploader': owner.get('name'),
227 'uploader_id': video_uploader_url.split('/')[-1] if video_uploader_url else None,
228 'uploader_url': video_uploader_url,
229 'thumbnails': thumbnails,
230 'duration': int_or_none(video_data.get('duration')),
231 'chapters': sorted(traverse_obj(config, (
232 'embed', 'chapters', lambda _, v: int(v['timecode']) is not None, {
233 'title': ('title', {str}),
234 'start_time': ('timecode', {int_or_none}),
235 })), key=lambda c: c['start_time']) or None,
236 'formats': formats,
237 'subtitles': subtitles,
238 'live_status': live_status,
239 'release_timestamp': traverse_obj(live_event, ('ingest', 'scheduled_start_time', {parse_iso8601})),
240 # Note: Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps
241 # at the same time without actual units specified.
242 '_format_sort_fields': ('quality', 'res', 'fps', 'hdr:12', 'source'),
245 def _call_videos_api(self, video_id, jwt_token, unlisted_hash=None, **kwargs):
246 return self._download_json(
247 join_nonempty(f'https://api.vimeo.com/videos/{video_id}', unlisted_hash, delim=':'),
248 video_id, 'Downloading API JSON', headers={
249 'Authorization': f'jwt {jwt_token}',
250 'Accept': 'application/json',
251 }, query={
252 'fields': ','.join((
253 'config_url', 'created_time', 'description', 'download', 'license',
254 'metadata.connections.comments.total', 'metadata.connections.likes.total',
255 'release_time', 'stats.plays')),
256 }, **kwargs)
258 def _extract_original_format(self, url, video_id, unlisted_hash=None, jwt=None, api_data=None):
259 # Original/source formats are only available when logged in
260 if not self._get_cookies('https://vimeo.com/').get('vimeo'):
261 return
263 query = {'action': 'load_download_config'}
264 if unlisted_hash:
265 query['unlisted_hash'] = unlisted_hash
266 download_data = self._download_json(
267 url, video_id, 'Loading download config JSON', fatal=False,
268 query=query, headers={'X-Requested-With': 'XMLHttpRequest'},
269 expected_status=(403, 404)) or {}
270 source_file = download_data.get('source_file')
271 download_url = try_get(source_file, lambda x: x['download_url'])
272 if download_url and not source_file.get('is_cold') and not source_file.get('is_defrosting'):
273 source_name = source_file.get('public_name', 'Original')
274 if self._is_valid_url(download_url, video_id, f'{source_name} video'):
275 ext = (try_get(
276 source_file, lambda x: x['extension'],
277 str) or determine_ext(
278 download_url, None) or 'mp4').lower()
279 return {
280 'url': download_url,
281 'ext': ext,
282 'width': int_or_none(source_file.get('width')),
283 'height': int_or_none(source_file.get('height')),
284 'filesize': parse_filesize(source_file.get('size')),
285 'format_id': source_name,
286 'quality': 1,
289 jwt = jwt or traverse_obj(self._download_json(
290 'https://vimeo.com/_rv/viewer', video_id, 'Downloading jwt token', fatal=False), ('jwt', {str}))
291 if not jwt:
292 return
293 original_response = api_data or self._call_videos_api(
294 video_id, jwt, unlisted_hash, fatal=False, expected_status=(403, 404))
295 for download_data in traverse_obj(original_response, ('download', ..., {dict})):
296 download_url = download_data.get('link')
297 if not download_url or download_data.get('quality') != 'source':
298 continue
299 ext = determine_ext(parse_qs(download_url).get('filename', [''])[0].lower(), default_ext=None)
300 if not ext:
301 urlh = self._request_webpage(
302 HEADRequest(download_url), video_id, fatal=False, note='Determining source extension')
303 ext = urlh and urlhandle_detect_ext(urlh)
304 return {
305 'url': download_url,
306 'ext': ext or 'unknown_video',
307 'format_id': download_data.get('public_name', 'Original'),
308 'width': int_or_none(download_data.get('width')),
309 'height': int_or_none(download_data.get('height')),
310 'fps': int_or_none(download_data.get('fps')),
311 'filesize': int_or_none(download_data.get('size')),
312 'quality': 1,
316 class VimeoIE(VimeoBaseInfoExtractor):
317 """Information extractor for vimeo.com."""
319 # _VALID_URL matches Vimeo URLs
320 _VALID_URL = r'''(?x)
321 https?://
324 www|
325 player
329 vimeo\.com/
331 (?P<u>user)|
332 (?!(?:channels|album|showcase)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/)
333 (?:.*?/)??
334 (?P<q>
336 play_redirect_hls|
337 moogaloop\.swf)\?clip_id=
339 (?:videos?/)?
341 (?P<id>[0-9]+)
342 (?(u)
343 /(?!videos|likes)[^/?#]+/?|
344 (?(q)|/(?P<unlisted_hash>[\da-f]{10}))?
346 (?:(?(q)[&]|(?(u)|/?)[?]).*?)?(?:[#].*)?$
348 IE_NAME = 'vimeo'
349 _EMBED_REGEX = [
350 # iframe
351 r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/\d+.*?)\1',
352 # Embedded (swf embed) Vimeo player
353 r'<embed[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1',
354 # Non-standard embedded Vimeo player
355 r'<video[^>]+src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/[0-9]+)\1',
357 _TESTS = [
359 'url': 'http://vimeo.com/56015672#at=0',
360 'md5': '8879b6cc097e987f02484baf890129e5',
361 'info_dict': {
362 'id': '56015672',
363 'ext': 'mp4',
364 'title': "youtube-dl test video '' ä↭𝕐-BaW jenozKc",
365 'description': 'md5:2d3305bad981a06ff79f027f19865021',
366 'timestamp': 1355990239,
367 'upload_date': '20121220',
368 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user7108434',
369 'uploader_id': 'user7108434',
370 'uploader': 'Filippo Valsorda',
371 'duration': 10,
372 'license': 'by-sa',
374 'params': {
375 'format': 'best[protocol=https]',
377 'skip': 'No longer available',
380 'url': 'https://player.vimeo.com/video/54469442',
381 'md5': '619b811a4417aa4abe78dc653becf511',
382 'note': 'Videos that embed the url in the player page',
383 'info_dict': {
384 'id': '54469442',
385 'ext': 'mp4',
386 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
387 'uploader': 'Business of Software',
388 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/businessofsoftware',
389 'uploader_id': 'businessofsoftware',
390 'duration': 3610,
391 'thumbnail': 'https://i.vimeocdn.com/video/376682406-f34043e7b766af6bef2af81366eacd6724f3fc3173179a11a97a1e26587c9529-d_1280',
393 'params': {
394 'format': 'best[protocol=https]',
396 'expected_warnings': ['Failed to parse XML: not well-formed'],
399 'url': 'http://vimeo.com/68375962',
400 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
401 'note': 'Video protected with password',
402 'info_dict': {
403 'id': '68375962',
404 'ext': 'mp4',
405 'title': 'youtube-dl password protected test video',
406 'timestamp': 1371214555,
407 'upload_date': '20130614',
408 'release_timestamp': 1371214555,
409 'release_date': '20130614',
410 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128',
411 'uploader_id': 'user18948128',
412 'uploader': 'Jaime Marquínez Ferrándiz',
413 'duration': 10,
414 'comment_count': int,
415 'like_count': int,
416 'thumbnail': 'https://i.vimeocdn.com/video/440665496-b2c5aee2b61089442c794f64113a8e8f7d5763c3e6b3ebfaf696ae6413f8b1f4-d_1280',
418 'params': {
419 'format': 'best[protocol=https]',
420 'videopassword': 'youtube-dl',
422 'expected_warnings': ['Failed to parse XML: not well-formed'],
425 'url': 'http://vimeo.com/channels/keypeele/75629013',
426 'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
427 'info_dict': {
428 'id': '75629013',
429 'ext': 'mp4',
430 'title': 'Key & Peele: Terrorist Interrogation',
431 'description': 'md5:6173f270cd0c0119f22817204b3eb86c',
432 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/atencio',
433 'uploader_id': 'atencio',
434 'uploader': 'Peter Atencio',
435 'channel_id': 'keypeele',
436 'channel_url': r're:https?://(?:www\.)?vimeo\.com/channels/keypeele',
437 'timestamp': 1380339469,
438 'upload_date': '20130928',
439 'duration': 187,
440 'thumbnail': 'https://i.vimeocdn.com/video/450239872-a05512d9b1e55d707a7c04365c10980f327b06d966351bc403a5d5d65c95e572-d_1280',
441 'view_count': int,
442 'comment_count': int,
443 'like_count': int,
445 'params': {'format': 'http-1080p'},
446 'expected_warnings': ['Failed to parse XML: not well-formed'],
449 'url': 'http://vimeo.com/76979871',
450 'note': 'Video with subtitles',
451 'info_dict': {
452 'id': '76979871',
453 'ext': 'mp4',
454 'title': 'The New Vimeo Player (You Know, For Videos)',
455 'description': str, # FIXME: Dynamic SEO spam description
456 'timestamp': 1381860509,
457 'upload_date': '20131015',
458 'release_timestamp': 1381860509,
459 'release_date': '20131015',
460 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/staff',
461 'uploader_id': 'staff',
462 'uploader': 'Vimeo',
463 'duration': 62,
464 'comment_count': int,
465 'like_count': int,
466 'thumbnail': 'https://i.vimeocdn.com/video/452001751-8216e0571c251a09d7a8387550942d89f7f86f6398f8ed886e639b0dd50d3c90-d_1280',
467 'subtitles': {
468 'de': 'count:3',
469 'en': 'count:3',
470 'es': 'count:3',
471 'fr': 'count:3',
474 'expected_warnings': [
475 'Ignoring subtitle tracks found in the HLS manifest',
476 'Failed to parse XML: not well-formed',
480 # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
481 'url': 'https://player.vimeo.com/video/98044508',
482 'note': 'The js code contains assignments to the same variable as the config',
483 'info_dict': {
484 'id': '98044508',
485 'ext': 'mp4',
486 'title': 'Pier Solar OUYA Official Trailer',
487 'uploader': 'Tulio Gonçalves',
488 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593',
489 'uploader_id': 'user28849593',
490 'duration': 118,
491 'thumbnail': 'https://i.vimeocdn.com/video/478636036-c18440305ef3df9decfb6bf207a61fe39d2d17fa462a96f6f2d93d30492b037d-d_1280',
493 'expected_warnings': ['Failed to parse XML: not well-formed'],
496 # contains Original format
497 'url': 'https://vimeo.com/33951933',
498 # 'md5': '53c688fa95a55bf4b7293d37a89c5c53',
499 'info_dict': {
500 'id': '33951933',
501 'ext': 'mp4',
502 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
503 'uploader': 'The DMCI',
504 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/dmci',
505 'uploader_id': 'dmci',
506 'timestamp': 1324343742,
507 'upload_date': '20111220',
508 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
509 'duration': 60,
510 'comment_count': int,
511 'view_count': int,
512 'thumbnail': 'https://i.vimeocdn.com/video/231174622-dd07f015e9221ff529d451e1cc31c982b5d87bfafa48c4189b1da72824ee289a-d_1280',
513 'like_count': int,
514 'tags': 'count:11',
516 # 'params': {'format': 'Original'},
517 'expected_warnings': ['Failed to parse XML: not well-formed'],
520 'note': 'Contains source format not accessible in webpage',
521 'url': 'https://vimeo.com/393756517',
522 # 'md5': 'c464af248b592190a5ffbb5d33f382b0',
523 'info_dict': {
524 'id': '393756517',
525 # 'ext': 'mov',
526 'ext': 'mp4',
527 'timestamp': 1582642091,
528 'uploader_id': 'frameworkla',
529 'title': 'Straight To Hell - Sabrina: Netflix',
530 'uploader': 'Framework Studio',
531 'description': 'md5:f2edc61af3ea7a5592681ddbb683db73',
532 'upload_date': '20200225',
533 'duration': 176,
534 'thumbnail': 'https://i.vimeocdn.com/video/859377297-836494a4ef775e9d4edbace83937d9ad34dc846c688c0c419c0e87f7ab06c4b3-d_1280',
535 'uploader_url': 'https://vimeo.com/frameworkla',
537 # 'params': {'format': 'source'},
538 'expected_warnings': ['Failed to parse XML: not well-formed'],
541 # only available via https://vimeo.com/channels/tributes/6213729 and
542 # not via https://vimeo.com/6213729
543 'url': 'https://vimeo.com/channels/tributes/6213729',
544 'info_dict': {
545 'id': '6213729',
546 'ext': 'mp4',
547 'title': 'Vimeo Tribute: The Shining',
548 'uploader': 'Casey Donahue',
549 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/caseydonahue',
550 'uploader_id': 'caseydonahue',
551 'channel_url': r're:https?://(?:www\.)?vimeo\.com/channels/tributes',
552 'channel_id': 'tributes',
553 'timestamp': 1250886430,
554 'upload_date': '20090821',
555 'description': str, # FIXME: Dynamic SEO spam description
556 'duration': 321,
557 'comment_count': int,
558 'view_count': int,
559 'thumbnail': 'https://i.vimeocdn.com/video/22728298-bfc22146f930de7cf497821c7b0b9f168099201ecca39b00b6bd31fcedfca7a6-d_1280',
560 'like_count': int,
561 'tags': ['[the shining', 'vimeohq', 'cv', 'vimeo tribute]'],
563 'params': {
564 'skip_download': True,
566 'expected_warnings': ['Failed to parse XML: not well-formed'],
569 # redirects to ondemand extractor and should be passed through it
570 # for successful extraction
571 'url': 'https://vimeo.com/73445910',
572 'info_dict': {
573 'id': '73445910',
574 'ext': 'mp4',
575 'title': 'The Reluctant Revolutionary',
576 'uploader': '10Ft Films',
577 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/tenfootfilms',
578 'uploader_id': 'tenfootfilms',
579 'description': 'md5:0fa704e05b04f91f40b7f3ca2e801384',
580 'upload_date': '20130830',
581 'timestamp': 1377853339,
583 'params': {
584 'skip_download': True,
586 'skip': 'this page is no longer available.',
589 'url': 'https://player.vimeo.com/video/68375962',
590 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
591 'info_dict': {
592 'id': '68375962',
593 'ext': 'mp4',
594 'title': 'youtube-dl password protected test video',
595 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128',
596 'uploader_id': 'user18948128',
597 'uploader': 'Jaime Marquínez Ferrándiz',
598 'duration': 10,
599 'thumbnail': 'https://i.vimeocdn.com/video/440665496-b2c5aee2b61089442c794f64113a8e8f7d5763c3e6b3ebfaf696ae6413f8b1f4-d_1280',
601 'params': {
602 'format': 'best[protocol=https]',
603 'videopassword': 'youtube-dl',
605 'expected_warnings': ['Failed to parse XML: not well-formed'],
608 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741',
609 'only_matching': True,
612 'url': 'https://vimeo.com/109815029',
613 'note': 'Video not completely processed, "failed" seed status',
614 'only_matching': True,
617 'url': 'https://vimeo.com/groups/travelhd/videos/22439234',
618 'only_matching': True,
621 'url': 'https://vimeo.com/album/2632481/video/79010983',
622 'only_matching': True,
625 'url': 'https://vimeo.com/showcase/3253534/video/119195465',
626 'note': 'A video in a password protected album (showcase)',
627 'info_dict': {
628 'id': '119195465',
629 'ext': 'mp4',
630 'title': "youtube-dl test video '' ä↭𝕐-BaW jenozKc",
631 'uploader': 'Philipp Hagemeister',
632 'uploader_id': 'user20132939',
633 'description': str, # FIXME: Dynamic SEO spam description
634 'upload_date': '20150209',
635 'timestamp': 1423518307,
636 'thumbnail': 'https://i.vimeocdn.com/video/default_1280',
637 'duration': 10,
638 'like_count': int,
639 'uploader_url': 'https://vimeo.com/user20132939',
640 'view_count': int,
641 'comment_count': int,
643 'params': {
644 'format': 'best[protocol=https]',
645 'videopassword': 'youtube-dl',
647 'expected_warnings': ['Failed to parse XML: not well-formed'],
650 # source file returns 403: Forbidden
651 'url': 'https://vimeo.com/7809605',
652 'only_matching': True,
655 'note': 'Direct URL with hash',
656 'url': 'https://vimeo.com/160743502/abd0e13fb4',
657 'info_dict': {
658 'id': '160743502',
659 'ext': 'mp4',
660 'uploader': 'Julian Tryba',
661 'uploader_id': 'aliniamedia',
662 'title': 'Harrisville New Hampshire',
663 'timestamp': 1459259666,
664 'upload_date': '20160329',
665 'release_timestamp': 1459259666,
666 'license': 'by-nc',
667 'duration': 159,
668 'comment_count': int,
669 'thumbnail': 'https://i.vimeocdn.com/video/562802436-585eeb13b5020c6ac0f171a2234067938098f84737787df05ff0d767f6d54ee9-d_1280',
670 'like_count': int,
671 'uploader_url': 'https://vimeo.com/aliniamedia',
672 'release_date': '20160329',
674 'params': {'skip_download': True},
675 'expected_warnings': ['Failed to parse XML: not well-formed'],
678 'url': 'https://vimeo.com/138909882',
679 'info_dict': {
680 'id': '138909882',
681 # 'ext': 'm4v',
682 'ext': 'mp4',
683 'title': 'Eastnor Castle 2015 Firework Champions - The Promo!',
684 'description': 'md5:5967e090768a831488f6e74b7821b3c1',
685 'uploader_id': 'fireworkchampions',
686 'uploader': 'Firework Champions',
687 'upload_date': '20150910',
688 'timestamp': 1441901895,
689 'thumbnail': 'https://i.vimeocdn.com/video/534715882-6ff8e4660cbf2fea68282876d8d44f318825dfe572cc4016e73b3266eac8ae3a-d_1280',
690 'uploader_url': 'https://vimeo.com/fireworkchampions',
691 'tags': 'count:6',
692 'duration': 229,
693 'view_count': int,
694 'like_count': int,
695 'comment_count': int,
697 'params': {
698 'skip_download': True,
699 # 'format': 'source',
701 'expected_warnings': ['Failed to parse XML: not well-formed'],
704 'url': 'https://vimeo.com/channels/staffpicks/143603739',
705 'info_dict': {
706 'id': '143603739',
707 'ext': 'mp4',
708 'uploader': 'Karim Huu Do',
709 'timestamp': 1445846953,
710 'upload_date': '20151026',
711 'title': 'The Shoes - Submarine Feat. Blaine Harrison',
712 'uploader_id': 'karimhd',
713 'description': 'md5:8e2eea76de4504c2e8020a9bcfa1e843',
714 'channel_id': 'staffpicks',
715 'duration': 336,
716 'comment_count': int,
717 'view_count': int,
718 'thumbnail': 'https://i.vimeocdn.com/video/541243181-b593db36a16db2f0096f655da3f5a4dc46b8766d77b0f440df937ecb0c418347-d_1280',
719 'like_count': int,
720 'uploader_url': 'https://vimeo.com/karimhd',
721 'channel_url': 'https://vimeo.com/channels/staffpicks',
722 'tags': 'count:6',
724 'params': {'skip_download': 'm3u8'},
725 'expected_warnings': ['Failed to parse XML: not well-formed'],
728 # requires passing unlisted_hash(a52724358e) to load_download_config request
729 'url': 'https://vimeo.com/392479337/a52724358e',
730 'only_matching': True,
733 # similar, but all numeric: ID must be 581039021, not 9603038895
734 # issue #29690
735 'url': 'https://vimeo.com/581039021/9603038895',
736 'info_dict': {
737 'id': '581039021',
738 'ext': 'mp4',
739 'timestamp': 1627621014,
740 'release_timestamp': 1627621014,
741 'duration': 976,
742 'comment_count': int,
743 'thumbnail': 'https://i.vimeocdn.com/video/1202249320-4ddb2c30398c0dc0ee059172d1bd5ea481ad12f0e0e3ad01d2266f56c744b015-d_1280',
744 'like_count': int,
745 'uploader_url': 'https://vimeo.com/txwestcapital',
746 'release_date': '20210730',
747 'uploader': 'Christopher Inks',
748 'title': 'Thursday, July 29, 2021 BMA Evening Video Update',
749 'uploader_id': 'txwestcapital',
750 'upload_date': '20210730',
752 'params': {
753 'skip_download': True,
755 'expected_warnings': ['Failed to parse XML: not well-formed'],
758 # chapters must be sorted, see: https://github.com/yt-dlp/yt-dlp/issues/5308
759 'url': 'https://player.vimeo.com/video/756714419',
760 'info_dict': {
761 'id': '756714419',
762 'ext': 'mp4',
763 'title': 'Dr Arielle Schwartz - Therapeutic yoga for optimum sleep',
764 'uploader': 'Alex Howard',
765 'uploader_id': 'user54729178',
766 'uploader_url': 'https://vimeo.com/user54729178',
767 'thumbnail': r're:https://i\.vimeocdn\.com/video/1520099929-[\da-f]+-d_1280',
768 'duration': 2636,
769 'chapters': [
770 {'start_time': 0, 'end_time': 10, 'title': '<Untitled Chapter 1>'},
771 {'start_time': 10, 'end_time': 106, 'title': 'Welcoming Dr Arielle Schwartz'},
772 {'start_time': 106, 'end_time': 305, 'title': 'What is therapeutic yoga?'},
773 {'start_time': 305, 'end_time': 594, 'title': 'Vagal toning practices'},
774 {'start_time': 594, 'end_time': 888, 'title': 'Trauma and difficulty letting go'},
775 {'start_time': 888, 'end_time': 1059, 'title': "Dr Schwartz' insomnia experience"},
776 {'start_time': 1059, 'end_time': 1471, 'title': 'A strategy for helping sleep issues'},
777 {'start_time': 1471, 'end_time': 1667, 'title': 'Yoga nidra'},
778 {'start_time': 1667, 'end_time': 2121, 'title': 'Wisdom in stillness'},
779 {'start_time': 2121, 'end_time': 2386, 'title': 'What helps us be more able to let go?'},
780 {'start_time': 2386, 'end_time': 2510, 'title': 'Practical tips to help ourselves'},
781 {'start_time': 2510, 'end_time': 2636, 'title': 'Where to find out more'},
784 'params': {
785 'http_headers': {'Referer': 'https://sleepsuperconference.com'},
786 'skip_download': 'm3u8',
788 'expected_warnings': ['Failed to parse XML: not well-formed'],
791 # vimeo.com URL with unlisted hash and Original format
792 'url': 'https://vimeo.com/144579403/ec02229140',
793 # 'md5': '6b662c2884e0373183fbde2a0d15cb78',
794 'info_dict': {
795 'id': '144579403',
796 'ext': 'mp4',
797 'title': 'SALESMANSHIP',
798 'description': 'md5:4338302f347a1ff8841b4a3aecaa09f0',
799 'uploader': 'Off the Picture Pictures',
800 'uploader_id': 'offthepicturepictures',
801 'uploader_url': 'https://vimeo.com/offthepicturepictures',
802 'duration': 669,
803 'upload_date': '20151104',
804 'timestamp': 1446607180,
805 'release_date': '20151104',
806 'release_timestamp': 1446607180,
807 'like_count': int,
808 'view_count': int,
809 'comment_count': int,
810 'thumbnail': r're:https://i\.vimeocdn\.com/video/1018638656-[\da-f]+-d_1280',
812 # 'params': {'format': 'Original'},
813 'expected_warnings': ['Failed to parse XML: not well-formed'],
816 # player.vimeo.com URL with source format
817 'url': 'https://player.vimeo.com/video/859028877',
818 # 'md5': '19ca3d2463441dee2d2f0671ac2916a2',
819 'info_dict': {
820 'id': '859028877',
821 'ext': 'mp4',
822 'title': 'Ariana Grande - Honeymoon Avenue (Live from London)',
823 'uploader': 'Raja Virdi',
824 'uploader_id': 'rajavirdi',
825 'uploader_url': 'https://vimeo.com/rajavirdi',
826 'duration': 309,
827 'thumbnail': r're:https://i\.vimeocdn\.com/video/1716727772-[\da-f]+-d_1280',
829 # 'params': {'format': 'source'},
830 'expected_warnings': ['Failed to parse XML: not well-formed'],
833 # user playlist alias -> https://vimeo.com/258705797
834 'url': 'https://vimeo.com/user26785108/newspiritualguide',
835 'only_matching': True,
837 # https://gettingthingsdone.com/workflowmap/
838 # vimeo embed with check-password page protected by Referer header
841 @classmethod
842 def _extract_embed_urls(cls, url, webpage):
843 for embed_url in super()._extract_embed_urls(url, webpage):
844 yield cls._smuggle_referrer(embed_url, url)
846 @classmethod
847 def _extract_url(cls, url, webpage):
848 return next(cls._extract_embed_urls(url, webpage), None)
850 def _verify_player_video_password(self, url, video_id, headers):
851 password = self._get_video_password()
852 data = urlencode_postdata({
853 'password': base64.b64encode(password.encode()),
855 headers = merge_dicts(headers, {
856 'Content-Type': 'application/x-www-form-urlencoded',
858 checked = self._download_json(
859 f'{urllib.parse.urlsplit(url)._replace(query=None).geturl()}/check-password',
860 video_id, 'Verifying the password', data=data, headers=headers)
861 if checked is False:
862 raise ExtractorError('Wrong video password', expected=True)
863 return checked
865 def _extract_from_api(self, video_id, unlisted_hash=None):
866 viewer = self._download_json(
867 'https://vimeo.com/_next/viewer', video_id, 'Downloading viewer info')
869 for retry in (False, True):
870 try:
871 video = self._call_videos_api(video_id, viewer['jwt'], unlisted_hash)
872 break
873 except ExtractorError as e:
874 if (not retry and isinstance(e.cause, HTTPError) and e.cause.status == 400
875 and 'password' in traverse_obj(
876 self._webpage_read_content(e.cause.response, e.cause.response.url, video_id, fatal=False),
877 ({json.loads}, 'invalid_parameters', ..., 'field'),
879 self._verify_video_password(
880 video_id, self._get_video_password(), viewer['xsrft'])
881 continue
882 raise
884 info = self._parse_config(self._download_json(
885 video['config_url'], video_id), video_id)
886 source_format = self._extract_original_format(
887 f'https://vimeo.com/{video_id}', video_id, unlisted_hash, jwt=viewer['jwt'], api_data=video)
888 if source_format:
889 info['formats'].append(source_format)
891 get_timestamp = lambda x: parse_iso8601(video.get(x + '_time'))
892 info.update({
893 'description': video.get('description'),
894 'license': video.get('license'),
895 'release_timestamp': get_timestamp('release'),
896 'timestamp': get_timestamp('created'),
897 'view_count': int_or_none(try_get(video, lambda x: x['stats']['plays'])),
899 connections = try_get(
900 video, lambda x: x['metadata']['connections'], dict) or {}
901 for k in ('comment', 'like'):
902 info[k + '_count'] = int_or_none(try_get(connections, lambda x: x[k + 's']['total']))
903 return info
905 def _try_album_password(self, url):
906 album_id = self._search_regex(
907 r'vimeo\.com/(?:album|showcase)/([^/]+)', url, 'album id', default=None)
908 if not album_id:
909 return
910 viewer = self._download_json(
911 'https://vimeo.com/_rv/viewer', album_id, fatal=False)
912 if not viewer:
913 webpage = self._download_webpage(url, album_id)
914 viewer = self._parse_json(self._search_regex(
915 r'bootstrap_data\s*=\s*({.+?})</script>',
916 webpage, 'bootstrap data'), album_id)['viewer']
917 jwt = viewer['jwt']
918 album = self._download_json(
919 'https://api.vimeo.com/albums/' + album_id,
920 album_id, headers={'Authorization': 'jwt ' + jwt, 'Accept': 'application/json'},
921 query={'fields': 'description,name,privacy'})
922 if try_get(album, lambda x: x['privacy']['view']) == 'password':
923 password = self.get_param('videopassword')
924 if not password:
925 raise ExtractorError(
926 'This album is protected by a password, use the --video-password option',
927 expected=True)
928 self._set_vimeo_cookie('vuid', viewer['vuid'])
929 try:
930 self._download_json(
931 f'https://vimeo.com/showcase/{album_id}/auth',
932 album_id, 'Verifying the password', data=urlencode_postdata({
933 'password': password,
934 'token': viewer['xsrft'],
935 }), headers={
936 'X-Requested-With': 'XMLHttpRequest',
938 except ExtractorError as e:
939 if isinstance(e.cause, HTTPError) and e.cause.status == 401:
940 raise ExtractorError('Wrong password', expected=True)
941 raise
943 def _real_extract(self, url):
944 url, data, headers = self._unsmuggle_headers(url)
945 if 'Referer' not in headers:
946 headers['Referer'] = url
948 # Extract ID from URL
949 mobj = self._match_valid_url(url).groupdict()
950 video_id, unlisted_hash = mobj['id'], mobj.get('unlisted_hash')
951 if unlisted_hash:
952 return self._extract_from_api(video_id, unlisted_hash)
954 if any(p in url for p in ('play_redirect_hls', 'moogaloop.swf')):
955 url = 'https://vimeo.com/' + video_id
957 self._try_album_password(url)
958 is_secure = urllib.parse.urlparse(url).scheme == 'https'
959 try:
960 # Retrieve video webpage to extract further information
961 webpage, urlh = self._download_webpage_handle(
962 url, video_id, headers=headers, impersonate=is_secure)
963 redirect_url = urlh.url
964 except ExtractorError as error:
965 if not isinstance(error.cause, HTTPError) or error.cause.status not in (403, 429):
966 raise
967 errmsg = error.cause.response.read()
968 if b'Because of its privacy settings, this video cannot be played here' in errmsg:
969 raise ExtractorError(
970 'Cannot download embed-only video without embedding URL. Please call yt-dlp '
971 'with the URL of the page that embeds this video.', expected=True)
972 # 403 == vimeo.com TLS fingerprint or DC IP block; 429 == player.vimeo.com TLS FP block
973 status = error.cause.status
974 dcip_msg = 'If you are using a data center IP or VPN/proxy, your IP may be blocked'
975 if target := error.cause.response.extensions.get('impersonate'):
976 raise ExtractorError(
977 f'Got HTTP Error {status} when using impersonate target "{target}". {dcip_msg}')
978 elif not is_secure:
979 raise ExtractorError(f'Got HTTP Error {status}. {dcip_msg}', expected=True)
980 raise ExtractorError(
981 'This request has been blocked due to its TLS fingerprint. Install a '
982 'required impersonation dependency if possible, or else if you are okay with '
983 f'{self._downloader._format_err("compromising your security/cookies", "light red")}, '
984 f'try replacing "https:" with "http:" in the input URL. {dcip_msg}.', expected=True)
986 if '://player.vimeo.com/video/' in url:
987 config = self._search_json(
988 r'\b(?:playerC|c)onfig\s*=', webpage, 'info section', video_id)
989 if config.get('view') == 4:
990 config = self._verify_player_video_password(
991 redirect_url, video_id, headers)
992 info = self._parse_config(config, video_id)
993 source_format = self._extract_original_format(
994 f'https://vimeo.com/{video_id}', video_id, unlisted_hash)
995 if source_format:
996 info['formats'].append(source_format)
997 return info
999 vimeo_config = self._extract_vimeo_config(webpage, video_id, default=None)
1000 if vimeo_config:
1001 seed_status = vimeo_config.get('seed_status') or {}
1002 if seed_status.get('state') == 'failed':
1003 raise ExtractorError(
1004 '{} said: {}'.format(self.IE_NAME, seed_status['title']),
1005 expected=True)
1007 cc_license = None
1008 timestamp = None
1009 video_description = None
1010 info_dict = {}
1011 config_url = None
1013 channel_id = self._search_regex(
1014 r'vimeo\.com/channels/([^/]+)', url, 'channel id', default=None)
1015 if channel_id:
1016 config_url = self._html_search_regex(
1017 r'\bdata-config-url="([^"]+)"', webpage, 'config URL', default=None)
1018 video_description = clean_html(get_element_by_class('description', webpage))
1019 info_dict.update({
1020 'channel_id': channel_id,
1021 'channel_url': 'https://vimeo.com/channels/' + channel_id,
1023 if not config_url:
1024 page_config = self._parse_json(self._search_regex(
1025 r'vimeo\.(?:clip|vod_title)_page_config\s*=\s*({.+?});',
1026 webpage, 'page config', default='{}'), video_id, fatal=False)
1027 if not page_config:
1028 return self._extract_from_api(video_id)
1029 config_url = page_config['player']['config_url']
1030 cc_license = page_config.get('cc_license')
1031 clip = page_config.get('clip') or {}
1032 timestamp = clip.get('uploaded_on')
1033 video_description = clean_html(
1034 clip.get('description') or page_config.get('description_html_escaped'))
1035 config = self._download_json(config_url, video_id)
1036 video = config.get('video') or {}
1037 vod = video.get('vod') or {}
1039 def is_rented():
1040 if '>You rented this title.<' in webpage:
1041 return True
1042 if try_get(config, lambda x: x['user']['purchased']):
1043 return True
1044 for purchase_option in (vod.get('purchase_options') or []):
1045 if purchase_option.get('purchased'):
1046 return True
1047 label = purchase_option.get('label_string')
1048 if label and (label.startswith('You rented this') or label.endswith(' remaining')):
1049 return True
1050 return False
1052 if is_rented() and vod.get('is_trailer'):
1053 feature_id = vod.get('feature_id')
1054 if feature_id and not data.get('force_feature_id', False):
1055 return self.url_result(smuggle_url(
1056 f'https://player.vimeo.com/player/{feature_id}',
1057 {'force_feature_id': True}), 'Vimeo')
1059 if not video_description:
1060 video_description = self._html_search_regex(
1061 r'(?s)<div\s+class="[^"]*description[^"]*"[^>]*>(.*?)</div>',
1062 webpage, 'description', default=None)
1063 if not video_description:
1064 video_description = self._html_search_meta(
1065 ['description', 'og:description', 'twitter:description'],
1066 webpage, default=None)
1067 if not video_description:
1068 self.report_warning('Cannot find video description')
1070 if not timestamp:
1071 timestamp = self._search_regex(
1072 r'<time[^>]+datetime="([^"]+)"', webpage,
1073 'timestamp', default=None)
1075 view_count = int_or_none(self._search_regex(r'UserPlays:(\d+)', webpage, 'view count', default=None))
1076 like_count = int_or_none(self._search_regex(r'UserLikes:(\d+)', webpage, 'like count', default=None))
1077 comment_count = int_or_none(self._search_regex(r'UserComments:(\d+)', webpage, 'comment count', default=None))
1079 formats = []
1081 source_format = self._extract_original_format(
1082 'https://vimeo.com/' + video_id, video_id, video.get('unlisted_hash'))
1083 if source_format:
1084 formats.append(source_format)
1086 info_dict_config = self._parse_config(config, video_id)
1087 formats.extend(info_dict_config['formats'])
1088 info_dict['_format_sort_fields'] = info_dict_config['_format_sort_fields']
1090 json_ld = self._search_json_ld(webpage, video_id, default={})
1092 if not cc_license:
1093 cc_license = self._search_regex(
1094 r'<link[^>]+rel=["\']license["\'][^>]+href=(["\'])(?P<license>(?:(?!\1).)+)\1',
1095 webpage, 'license', default=None, group='license')
1097 info_dict.update({
1098 'formats': formats,
1099 'timestamp': unified_timestamp(timestamp),
1100 'description': video_description,
1101 'webpage_url': url,
1102 'view_count': view_count,
1103 'like_count': like_count,
1104 'comment_count': comment_count,
1105 'license': cc_license,
1108 return merge_dicts(info_dict, info_dict_config, json_ld)
1111 class VimeoOndemandIE(VimeoIE): # XXX: Do not subclass from concrete IE
1112 IE_NAME = 'vimeo:ondemand'
1113 _VALID_URL = r'https?://(?:www\.)?vimeo\.com/ondemand/(?:[^/]+/)?(?P<id>[^/?#&]+)'
1114 _TESTS = [{
1115 # ondemand video not available via https://vimeo.com/id
1116 'url': 'https://vimeo.com/ondemand/20704',
1117 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35',
1118 'info_dict': {
1119 'id': '105442900',
1120 'ext': 'mp4',
1121 'title': 'המעבדה - במאי יותם פלדמן',
1122 'uploader': 'גם סרטים',
1123 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/gumfilms',
1124 'uploader_id': 'gumfilms',
1125 'description': 'md5:aeeba3dbd4d04b0fa98a4fdc9c639998',
1126 'upload_date': '20140906',
1127 'timestamp': 1410032453,
1128 'thumbnail': 'https://i.vimeocdn.com/video/488238335-d7bf151c364cff8d467f1b73784668fe60aae28a54573a35d53a1210ae283bd8-d_1280',
1129 'comment_count': int,
1130 'license': 'https://creativecommons.org/licenses/by-nc-nd/3.0/',
1131 'duration': 53,
1132 'view_count': int,
1133 'like_count': int,
1135 'params': {
1136 'format': 'best[protocol=https]',
1138 'expected_warnings': ['Unable to download JSON metadata'],
1139 }, {
1140 # requires Referer to be passed along with og:video:url
1141 'url': 'https://vimeo.com/ondemand/36938/126682985',
1142 'info_dict': {
1143 'id': '126584684',
1144 'ext': 'mp4',
1145 'title': 'Rävlock, rätt läte på rätt plats',
1146 'uploader': 'Lindroth & Norin',
1147 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/lindrothnorin',
1148 'uploader_id': 'lindrothnorin',
1149 'description': 'md5:c3c46a90529612c8279fb6af803fc0df',
1150 'upload_date': '20150502',
1151 'timestamp': 1430586422,
1152 'duration': 121,
1153 'comment_count': int,
1154 'view_count': int,
1155 'thumbnail': 'https://i.vimeocdn.com/video/517077723-7066ae1d9a79d3eb361334fb5d58ec13c8f04b52f8dd5eadfbd6fb0bcf11f613-d_1280',
1156 'like_count': int,
1158 'params': {
1159 'skip_download': True,
1161 'expected_warnings': ['Unable to download JSON metadata'],
1162 }, {
1163 'url': 'https://vimeo.com/ondemand/nazmaalik',
1164 'only_matching': True,
1165 }, {
1166 'url': 'https://vimeo.com/ondemand/141692381',
1167 'only_matching': True,
1168 }, {
1169 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832',
1170 'only_matching': True,
1174 class VimeoChannelIE(VimeoBaseInfoExtractor):
1175 IE_NAME = 'vimeo:channel'
1176 _VALID_URL = r'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
1177 _MORE_PAGES_INDICATOR = r'<a.+?rel="next"'
1178 _TITLE = None
1179 _TITLE_RE = r'<link rel="alternate"[^>]+?title="(.*?)"'
1180 _TESTS = [{
1181 'url': 'https://vimeo.com/channels/tributes',
1182 'info_dict': {
1183 'id': 'tributes',
1184 'title': 'Vimeo Tributes',
1186 'playlist_mincount': 22,
1188 _BASE_URL_TEMPL = 'https://vimeo.com/channels/%s'
1190 def _page_url(self, base_url, pagenum):
1191 return f'{base_url}/videos/page:{pagenum}/'
1193 def _extract_list_title(self, webpage):
1194 return self._TITLE or self._html_search_regex(
1195 self._TITLE_RE, webpage, 'list title', fatal=False)
1197 def _title_and_entries(self, list_id, base_url):
1198 for pagenum in itertools.count(1):
1199 page_url = self._page_url(base_url, pagenum)
1200 webpage = self._download_webpage(
1201 page_url, list_id,
1202 f'Downloading page {pagenum}')
1204 if pagenum == 1:
1205 yield self._extract_list_title(webpage)
1207 # Try extracting href first since not all videos are available via
1208 # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729)
1209 clips = re.findall(
1210 r'id="clip_(\d+)"[^>]*>\s*<a[^>]+href="(/(?:[^/]+/)*\1)(?:[^>]+\btitle="([^"]+)")?', webpage)
1211 if clips:
1212 for video_id, video_url, video_title in clips:
1213 yield self.url_result(
1214 urllib.parse.urljoin(base_url, video_url),
1215 VimeoIE.ie_key(), video_id=video_id, video_title=video_title)
1216 # More relaxed fallback
1217 else:
1218 for video_id in re.findall(r'id=["\']clip_(\d+)', webpage):
1219 yield self.url_result(
1220 f'https://vimeo.com/{video_id}',
1221 VimeoIE.ie_key(), video_id=video_id)
1223 if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
1224 break
1226 def _extract_videos(self, list_id, base_url):
1227 title_and_entries = self._title_and_entries(list_id, base_url)
1228 list_title = next(title_and_entries)
1229 return self.playlist_result(title_and_entries, list_id, list_title)
1231 def _real_extract(self, url):
1232 channel_id = self._match_id(url)
1233 return self._extract_videos(channel_id, self._BASE_URL_TEMPL % channel_id)
1236 class VimeoUserIE(VimeoChannelIE): # XXX: Do not subclass from concrete IE
1237 IE_NAME = 'vimeo:user'
1238 _VALID_URL = r'https://vimeo\.com/(?!(?:[0-9]+|watchlater)(?:$|[?#/]))(?P<id>[^/]+)(?:/videos)?/?(?:$|[?#])'
1239 _TITLE_RE = r'<a[^>]+?class="user">([^<>]+?)</a>'
1240 _TESTS = [{
1241 'url': 'https://vimeo.com/nkistudio/videos',
1242 'info_dict': {
1243 'title': 'Nki',
1244 'id': 'nkistudio',
1246 'playlist_mincount': 66,
1247 }, {
1248 'url': 'https://vimeo.com/nkistudio/',
1249 'only_matching': True,
1251 _BASE_URL_TEMPL = 'https://vimeo.com/%s'
1254 class VimeoAlbumIE(VimeoBaseInfoExtractor):
1255 IE_NAME = 'vimeo:album'
1256 _VALID_URL = r'https://vimeo\.com/(?:album|showcase)/(?P<id>\d+)(?:$|[?#]|/(?!video))'
1257 _TITLE_RE = r'<header id="page_header">\n\s*<h1>(.*?)</h1>'
1258 _TESTS = [{
1259 'url': 'https://vimeo.com/album/2632481',
1260 'info_dict': {
1261 'id': '2632481',
1262 'title': 'Staff Favorites: November 2013',
1264 'playlist_mincount': 13,
1265 }, {
1266 'note': 'Password-protected album',
1267 'url': 'https://vimeo.com/album/3253534',
1268 'info_dict': {
1269 'title': 'test',
1270 'id': '3253534',
1272 'playlist_count': 1,
1273 'params': {
1274 'videopassword': 'youtube-dl',
1277 _PAGE_SIZE = 100
1279 def _fetch_page(self, album_id, authorization, hashed_pass, page):
1280 api_page = page + 1
1281 query = {
1282 'fields': 'link,uri',
1283 'page': api_page,
1284 'per_page': self._PAGE_SIZE,
1286 if hashed_pass:
1287 query['_hashed_pass'] = hashed_pass
1288 try:
1289 videos = self._download_json(
1290 f'https://api.vimeo.com/albums/{album_id}/videos',
1291 album_id, f'Downloading page {api_page}', query=query, headers={
1292 'Authorization': 'jwt ' + authorization,
1293 'Accept': 'application/json',
1294 })['data']
1295 except ExtractorError as e:
1296 if isinstance(e.cause, HTTPError) and e.cause.status == 400:
1297 return
1298 raise
1299 for video in videos:
1300 link = video.get('link')
1301 if not link:
1302 continue
1303 uri = video.get('uri')
1304 video_id = self._search_regex(r'/videos/(\d+)', uri, 'video_id', default=None) if uri else None
1305 yield self.url_result(link, VimeoIE.ie_key(), video_id)
1307 def _real_extract(self, url):
1308 album_id = self._match_id(url)
1309 viewer = self._download_json(
1310 'https://vimeo.com/_rv/viewer', album_id, fatal=False)
1311 if not viewer:
1312 webpage = self._download_webpage(url, album_id)
1313 viewer = self._parse_json(self._search_regex(
1314 r'bootstrap_data\s*=\s*({.+?})</script>',
1315 webpage, 'bootstrap data'), album_id)['viewer']
1316 jwt = viewer['jwt']
1317 album = self._download_json(
1318 'https://api.vimeo.com/albums/' + album_id,
1319 album_id, headers={'Authorization': 'jwt ' + jwt, 'Accept': 'application/json'},
1320 query={'fields': 'description,name,privacy'})
1321 hashed_pass = None
1322 if try_get(album, lambda x: x['privacy']['view']) == 'password':
1323 password = self.get_param('videopassword')
1324 if not password:
1325 raise ExtractorError(
1326 'This album is protected by a password, use the --video-password option',
1327 expected=True)
1328 self._set_vimeo_cookie('vuid', viewer['vuid'])
1329 try:
1330 hashed_pass = self._download_json(
1331 f'https://vimeo.com/showcase/{album_id}/auth',
1332 album_id, 'Verifying the password', data=urlencode_postdata({
1333 'password': password,
1334 'token': viewer['xsrft'],
1335 }), headers={
1336 'X-Requested-With': 'XMLHttpRequest',
1337 })['hashed_pass']
1338 except ExtractorError as e:
1339 if isinstance(e.cause, HTTPError) and e.cause.status == 401:
1340 raise ExtractorError('Wrong password', expected=True)
1341 raise
1342 entries = OnDemandPagedList(functools.partial(
1343 self._fetch_page, album_id, jwt, hashed_pass), self._PAGE_SIZE)
1344 return self.playlist_result(
1345 entries, album_id, album.get('name'), album.get('description'))
1348 class VimeoGroupsIE(VimeoChannelIE): # XXX: Do not subclass from concrete IE
1349 IE_NAME = 'vimeo:group'
1350 _VALID_URL = r'https://vimeo\.com/groups/(?P<id>[^/]+)(?:/(?!videos?/\d+)|$)'
1351 _TESTS = [{
1352 'url': 'https://vimeo.com/groups/meetup',
1353 'info_dict': {
1354 'id': 'meetup',
1355 'title': 'Vimeo Meetup!',
1357 'playlist_mincount': 27,
1359 _BASE_URL_TEMPL = 'https://vimeo.com/groups/%s'
1362 class VimeoReviewIE(VimeoBaseInfoExtractor):
1363 IE_NAME = 'vimeo:review'
1364 IE_DESC = 'Review pages on vimeo'
1365 _VALID_URL = r'https?://vimeo\.com/(?P<user>[^/?#]+)/review/(?P<id>\d+)/(?P<hash>[\da-f]{10})'
1366 _TESTS = [{
1367 'url': 'https://vimeo.com/user170863801/review/996447483/a316d6ed8d',
1368 'info_dict': {
1369 'id': '996447483',
1370 'ext': 'mp4',
1371 'title': 'Rodeo day 1-_2',
1372 'uploader': 'BROADKAST',
1373 'uploader_id': 'user170863801',
1374 'uploader_url': 'https://vimeo.com/user170863801',
1375 'duration': 30,
1376 'thumbnail': 'https://i.vimeocdn.com/video/1912612821-09a43bd2e75c203d503aed89de7534f28fc4474a48f59c51999716931a246af5-d_1280',
1378 'params': {'skip_download': 'm3u8'},
1379 'expected_warnings': ['Failed to parse XML'],
1380 }, {
1381 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
1382 'md5': 'c507a72f780cacc12b2248bb4006d253',
1383 'info_dict': {
1384 'id': '75524534',
1385 'ext': 'mp4',
1386 'title': "DICK HARDWICK 'Comedian'",
1387 'uploader': 'Richard Hardwick',
1388 'uploader_id': 'user21297594',
1389 'description': "Comedian Dick Hardwick's five minute demo filmed in front of a live theater audience.\nEdit by Doug Mattocks",
1390 'duration': 304,
1391 'thumbnail': 'https://i.vimeocdn.com/video/450115033-43303819d9ebe24c2630352e18b7056d25197d09b3ae901abdac4c4f1d68de71-d_1280',
1392 'uploader_url': 'https://vimeo.com/user21297594',
1394 'skip': '404 Not Found',
1395 }, {
1396 'note': 'video player needs Referer',
1397 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
1398 'md5': '6295fdab8f4bf6a002d058b2c6dce276',
1399 'info_dict': {
1400 'id': '91613211',
1401 'ext': 'mp4',
1402 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
1403 'uploader': 'DevWeek Events',
1404 'duration': 2773,
1405 'thumbnail': r're:^https?://.*\.jpg$',
1406 'uploader_id': 'user22258446',
1408 'skip': 'video gone',
1409 }, {
1410 'note': 'Password protected',
1411 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde',
1412 'info_dict': {
1413 'id': '138823582',
1414 'ext': 'mp4',
1415 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1',
1416 'uploader': 'TMB',
1417 'uploader_id': 'user37284429',
1419 'params': {
1420 'videopassword': 'holygrail',
1422 'skip': 'video gone',
1425 def _real_extract(self, url):
1426 user, video_id, review_hash = self._match_valid_url(url).group('user', 'id', 'hash')
1427 data_url = f'https://vimeo.com/{user}/review/data/{video_id}/{review_hash}'
1428 data = self._download_json(data_url, video_id)
1429 viewer = {}
1430 if data.get('isLocked') is True:
1431 video_password = self._get_video_password()
1432 viewer = self._download_json(
1433 'https://vimeo.com/_rv/viewer', video_id)
1434 self._verify_video_password(video_id, video_password, viewer['xsrft'])
1435 data = self._download_json(data_url, video_id)
1436 clip_data = data['clipData']
1437 config_url = clip_data['configUrl']
1438 config = self._download_json(config_url, video_id)
1439 info_dict = self._parse_config(config, video_id)
1440 source_format = self._extract_original_format(
1441 f'https://vimeo.com/{user}/review/{video_id}/{review_hash}/action',
1442 video_id, unlisted_hash=clip_data.get('unlistedHash'), jwt=viewer.get('jwt'))
1443 if source_format:
1444 info_dict['formats'].append(source_format)
1445 info_dict['description'] = clean_html(clip_data.get('description'))
1446 return info_dict
1449 class VimeoWatchLaterIE(VimeoChannelIE): # XXX: Do not subclass from concrete IE
1450 IE_NAME = 'vimeo:watchlater'
1451 IE_DESC = 'Vimeo watch later list, ":vimeowatchlater" keyword (requires authentication)'
1452 _VALID_URL = r'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater'
1453 _TITLE = 'Watch Later'
1454 _LOGIN_REQUIRED = True
1455 _TESTS = [{
1456 'url': 'https://vimeo.com/watchlater',
1457 'only_matching': True,
1460 def _page_url(self, base_url, pagenum):
1461 url = f'{base_url}/page:{pagenum}/'
1462 request = Request(url)
1463 # Set the header to get a partial html page with the ids,
1464 # the normal page doesn't contain them.
1465 request.headers['X-Requested-With'] = 'XMLHttpRequest'
1466 return request
1468 def _real_extract(self, url):
1469 return self._extract_videos('watchlater', 'https://vimeo.com/watchlater')
1472 class VimeoLikesIE(VimeoChannelIE): # XXX: Do not subclass from concrete IE
1473 _VALID_URL = r'https://(?:www\.)?vimeo\.com/(?P<id>[^/]+)/likes/?(?:$|[?#]|sort:)'
1474 IE_NAME = 'vimeo:likes'
1475 IE_DESC = 'Vimeo user likes'
1476 _TESTS = [{
1477 'url': 'https://vimeo.com/user755559/likes/',
1478 'playlist_mincount': 293,
1479 'info_dict': {
1480 'id': 'user755559',
1481 'title': 'urza’s Likes',
1483 }, {
1484 'url': 'https://vimeo.com/stormlapse/likes',
1485 'only_matching': True,
1488 def _page_url(self, base_url, pagenum):
1489 return f'{base_url}/page:{pagenum}/'
1491 def _real_extract(self, url):
1492 user_id = self._match_id(url)
1493 return self._extract_videos(user_id, f'https://vimeo.com/{user_id}/likes')
1496 class VHXEmbedIE(VimeoBaseInfoExtractor):
1497 IE_NAME = 'vhx:embed'
1498 _VALID_URL = r'https?://embed\.vhx\.tv/videos/(?P<id>\d+)'
1499 _EMBED_REGEX = [r'<iframe[^>]+src="(?P<url>https?://embed\.vhx\.tv/videos/\d+[^"]*)"']
1501 @classmethod
1502 def _extract_embed_urls(cls, url, webpage):
1503 for embed_url in super()._extract_embed_urls(url, webpage):
1504 yield cls._smuggle_referrer(embed_url, url)
1506 def _real_extract(self, url):
1507 video_id = self._match_id(url)
1508 url, _, headers = self._unsmuggle_headers(url)
1509 webpage = self._download_webpage(url, video_id, headers=headers)
1510 config_url = self._parse_json(self._search_regex(
1511 r'window\.OTTData\s*=\s*({.+})', webpage,
1512 'ott data'), video_id, js_to_json)['config_url']
1513 config = self._download_json(config_url, video_id)
1514 info = self._parse_config(config, video_id)
1515 info['id'] = video_id
1516 return info
1519 class VimeoProIE(VimeoBaseInfoExtractor):
1520 IE_NAME = 'vimeo:pro'
1521 _VALID_URL = r'https?://(?:www\.)?vimeopro\.com/[^/?#]+/(?P<slug>[^/?#]+)(?:(?:/videos?/(?P<id>[0-9]+)))?'
1522 _TESTS = [{
1523 # Vimeo URL derived from video_id
1524 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
1525 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
1526 'note': 'Vimeo Pro video (#1197)',
1527 'info_dict': {
1528 'id': '68093876',
1529 'ext': 'mp4',
1530 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/openstreetmapus',
1531 'uploader_id': 'openstreetmapus',
1532 'uploader': 'OpenStreetMap US',
1533 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
1534 'description': 'md5:2c362968038d4499f4d79f88458590c1',
1535 'duration': 1595,
1536 'upload_date': '20130610',
1537 'timestamp': 1370893156,
1538 'license': 'by',
1539 'thumbnail': 'https://i.vimeocdn.com/video/440260469-19b0d92fca3bd84066623b53f1eb8aaa3980c6c809e2d67b6b39ab7b4a77a344-d_960',
1540 'view_count': int,
1541 'comment_count': int,
1542 'like_count': int,
1543 'tags': 'count:1',
1545 'params': {
1546 'format': 'best[protocol=https]',
1548 }, {
1549 # password-protected VimeoPro page with Vimeo player embed
1550 'url': 'https://vimeopro.com/cadfem/simulation-conference-mechanische-systeme-in-perfektion',
1551 'info_dict': {
1552 'id': '764543723',
1553 'ext': 'mp4',
1554 'title': 'Mechanische Systeme in Perfektion: Realität erfassen, Innovation treiben',
1555 'thumbnail': 'https://i.vimeocdn.com/video/1543784598-a1a750494a485e601110136b9fe11e28c2131942452b3a5d30391cb3800ca8fd-d_1280',
1556 'description': 'md5:2a9d195cd1b0f6f79827107dc88c2420',
1557 'uploader': 'CADFEM',
1558 'uploader_id': 'cadfem',
1559 'uploader_url': 'https://vimeo.com/cadfem',
1560 'duration': 12505,
1561 'chapters': 'count:10',
1563 'params': {
1564 'videopassword': 'Conference2022',
1565 'skip_download': True,
1569 def _real_extract(self, url):
1570 display_id, video_id = self._match_valid_url(url).group('slug', 'id')
1571 if video_id:
1572 display_id = video_id
1573 webpage = self._download_webpage(url, display_id)
1575 password_form = self._search_regex(
1576 r'(?is)<form[^>]+?method=["\']post["\'][^>]*>(.+?password.+?)</form>',
1577 webpage, 'password form', default=None)
1578 if password_form:
1579 try:
1580 webpage = self._download_webpage(url, display_id, data=urlencode_postdata({
1581 'password': self._get_video_password(),
1582 **self._hidden_inputs(password_form),
1583 }), note='Logging in with video password')
1584 except ExtractorError as e:
1585 if isinstance(e.cause, HTTPError) and e.cause.status == 418:
1586 raise ExtractorError('Wrong video password', expected=True)
1587 raise
1589 description = None
1590 # even if we have video_id, some videos require player URL with portfolio_id query param
1591 # https://github.com/ytdl-org/youtube-dl/issues/20070
1592 vimeo_url = VimeoIE._extract_url(url, webpage)
1593 if vimeo_url:
1594 description = self._html_search_meta('description', webpage, default=None)
1595 elif video_id:
1596 vimeo_url = f'https://vimeo.com/{video_id}'
1597 else:
1598 raise ExtractorError(
1599 'No Vimeo embed or video ID could be found in VimeoPro page', expected=True)
1601 return self.url_result(vimeo_url, VimeoIE, video_id, url_transparent=True,
1602 description=description)