2 from __future__
import unicode_literals
10 from .common
import InfoExtractor
11 from ..compat
import (
42 class VimeoBaseInfoExtractor(InfoExtractor
):
43 _NETRC_MACHINE
= 'vimeo'
44 _LOGIN_REQUIRED
= False
45 _LOGIN_URL
= 'https://vimeo.com/log_in'
48 username
, password
= self
._get
_login
_info
()
50 if self
._LOGIN
_REQUIRED
:
51 raise ExtractorError('No login info available, needed for using %s.' % self
.IE_NAME
, expected
=True)
53 webpage
= self
._download
_webpage
(
54 self
._LOGIN
_URL
, None, 'Downloading login page')
55 token
, vuid
= self
._extract
_xsrft
_and
_vuid
(webpage
)
63 self
._set
_vimeo
_cookie
('vuid', vuid
)
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
, compat_HTTPError
) and e
.cause
.code
== 418:
74 'Unable to log in: bad username or password',
76 raise ExtractorError('Unable to log in')
78 def _get_video_password(self
):
79 password
= self
.get_param('videopassword')
82 'This video is protected by a password, use the --video-password option',
86 def _verify_video_password(self
, url
, video_id
, password
, token
, vuid
):
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://')
90 self
._set
_vimeo
_cookie
('vuid', vuid
)
91 return self
._download
_webpage
(
92 url
+ '/password', video_id
, 'Verifying the password',
93 'Wrong password', data
=urlencode_postdata({
97 'Content-Type': 'application/x-www-form-urlencoded',
101 def _extract_xsrft_and_vuid(self
, webpage
):
102 xsrft
= self
._search
_regex
(
103 r
'(?:(?P<q1>["\'])xsrft(?P
=q1
)\s
*:|xsrft\s
*[=:])\s
*(?P
<q
>["\'])(?P<xsrft>.+?)(?P=q)',
104 webpage, 'login token', group='xsrft')
105 vuid = self._search_regex(
106 r'["\']vuid
["\']\s*:\s*(["\'])(?P
<vuid
>.+?
)\
1',
107 webpage, 'vuid
', group='vuid
')
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
+({.+?}
)\
));',
113 webpage, 'vimeo config
', *args, **compat_kwargs(kwargs))
115 return self._parse_json(vimeo_config, video_id)
117 def _set_vimeo_cookie(self, name, value):
118 self._set_cookie('vimeo
.com
', name, value)
120 def _vimeo_sort_formats(self, formats):
121 # Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps
122 # at the same time without actual units specified. This lead to wrong sorting.
123 # But since yt-dlp prefers 'res
,fps
' anyway, 'field_preference
' is not needed
124 self._sort_formats(formats)
126 def _parse_config(self, config, video_id):
127 video_data = config['video
']
128 video_title = video_data['title
']
129 live_event = video_data.get('live_event
') or {}
130 is_live = live_event.get('status
') == 'started
'
133 config_files = video_data.get('files
') or config['request
'].get('files
', {})
134 for f in config_files.get('progressive
', []):
135 video_url = f.get('url
')
140 'format_id
': 'http
-%s' % f.get('quality
'),
141 'width
': int_or_none(f.get('width
')),
142 'height
': int_or_none(f.get('height
')),
143 'fps
': int_or_none(f.get('fps
')),
144 'tbr
': int_or_none(f.get('bitrate
')),
147 # TODO: fix handling of 308 status code returned for live archive manifest requests
148 sep_pattern = r'/sep
/video
/'
149 for files_type in ('hls
', 'dash
'):
150 for cdn_name, cdn_data in config_files.get(files_type, {}).get('cdns', {}).items():
151 manifest_url = cdn_data.get('url
')
154 format_id = '%s-%s' % (files_type, cdn_name)
155 sep_manifest_urls = []
156 if re.search(sep_pattern, manifest_url):
157 for suffix, repl in (('', 'video
'), ('_sep
', 'sep
/video
')):
158 sep_manifest_urls.append((format_id + suffix, re.sub(
159 sep_pattern, '/%s/' % repl, manifest_url)))
161 sep_manifest_urls = [(format_id, manifest_url)]
162 for f_id, m_url in sep_manifest_urls:
163 if files_type == 'hls
':
164 formats.extend(self._extract_m3u8_formats(
165 m_url, video_id, 'mp4
',
166 'm3u8
' if is_live else 'm3u8_native
', m3u8_id=f_id,
167 note='Downloading
%s m3u8 information
' % cdn_name,
169 elif files_type == 'dash
':
170 if 'json
=1' in m_url:
171 real_m_url = (self._download_json(m_url, video_id, fatal=False) or {}).get('url
')
174 mpd_formats = self._extract_mpd_formats(
175 m_url.replace('/master
.json
', '/master
.mpd
'), video_id, f_id,
176 'Downloading
%s MPD information
' % cdn_name,
178 formats.extend(mpd_formats)
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
':
184 'format_id
': 'live
-archive
-source
',
185 'url
': live_archive_source_url,
190 text_tracks = config['request
'].get('text_tracks
')
192 for tt in text_tracks:
193 subtitles[tt['lang
']] = [{
195 'url
': urljoin('https
://vimeo
.com
', tt['url
']),
200 for key, thumb in video_data.get('thumbs
', {}).items():
203 'width
': int_or_none(key),
206 thumbnail = video_data.get('thumbnail
')
212 owner = video_data.get('owner
') or {}
213 video_uploader_url = owner.get('url
')
216 'id': str_or_none(video_data.get('id')) or video_id,
217 'title
': self._live_title(video_title) if is_live else video_title,
218 'uploader
': owner.get('name
'),
219 'uploader_id
': video_uploader_url.split('/')[-1] if video_uploader_url else None,
220 'uploader_url
': video_uploader_url,
221 'thumbnails
': thumbnails,
222 'duration
': int_or_none(video_data.get('duration
')),
224 'subtitles
': subtitles,
228 def _extract_original_format(self, url, video_id, unlisted_hash=None):
229 query = {'action': 'load_download_config'}
231 query['unlisted_hash
'] = unlisted_hash
232 download_data = self._download_json(
233 url, video_id, fatal=False, query=query,
234 headers={'X-Requested-With': 'XMLHttpRequest'})
236 source_file = download_data.get('source_file
')
237 if isinstance(source_file, dict):
238 download_url = source_file.get('download_url
')
239 if download_url and not source_file.get('is_cold
') and not source_file.get('is_defrosting
'):
240 source_name = source_file.get('public_name
', 'Original
')
241 if self._is_valid_url(download_url, video_id, '%s video
' % source_name):
243 source_file, lambda x: x['extension
'],
244 compat_str) or determine_ext(
245 download_url, None) or 'mp4
').lower()
249 'width
': int_or_none(source_file.get('width
')),
250 'height
': int_or_none(source_file.get('height
')),
251 'filesize
': parse_filesize(source_file.get('size
')),
252 'format_id
': source_name,
256 jwt_response = self._download_json(
257 'https
://vimeo
.com
/_rv
/viewer
', video_id, note='Downloading jwt token
', fatal=False) or {}
258 if not jwt_response.get('jwt
'):
260 headers = {'Authorization': 'jwt %s' % jwt_response['jwt']}
261 original_response = self._download_json(
262 f'https
://api
.vimeo
.com
/videos
/{video_id}
', video_id,
263 headers=headers, fatal=False) or {}
264 for download_data in original_response.get('download
') or {}:
265 download_url = download_data.get('link
')
266 if not download_url or download_data.get('quality
') != 'source
':
268 query = compat_urlparse.parse_qs(compat_urlparse.urlparse(download_url).query)
271 'ext
': determine_ext(query.get('filename
', [''])[0].lower()),
272 'format_id
': download_data.get('public_name
', 'Original
'),
273 'width
': int_or_none(download_data.get('width
')),
274 'height
': int_or_none(download_data.get('height
')),
275 'fps
': int_or_none(download_data.get('fps
')),
276 'filesize
': int_or_none(download_data.get('size
')),
281 class VimeoIE(VimeoBaseInfoExtractor):
282 """Information extractor for vimeo.com."""
284 # _VALID_URL matches Vimeo URLs
285 _VALID_URL = r'''(?x)
295 (?!(?:channels|album|showcase)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/)
300 moogaloop\.swf)\?clip_id=
304 (?:/(?P<unlisted_hash>[\da-f]{10}))?
305 /?(?:[?&].*)?(?:[#].*)?$
310 'url
': 'http
://vimeo
.com
/56015672#at=0',
311 'md5': '8879b6cc097e987f02484baf890129e5',
315 'title': "youtube-dl test video - \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550",
316 'description': 'md5:2d3305bad981a06ff79f027f19865021',
317 'timestamp': 1355990239,
318 'upload_date': '20121220',
319 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user7108434',
320 'uploader_id': 'user7108434',
321 'uploader': 'Filippo Valsorda',
326 'format': 'best[protocol=https]',
330 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
331 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
332 'note': 'Vimeo Pro video (#1197)',
336 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/openstreetmapus',
337 'uploader_id': 'openstreetmapus',
338 'uploader': 'OpenStreetMap US',
339 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
340 'description': 'md5:2c362968038d4499f4d79f88458590c1',
342 'upload_date': '20130610',
343 'timestamp': 1370893156,
346 'format': 'best[protocol=https]',
350 'url': 'http://player.vimeo.com/video/54469442',
351 'md5': '619b811a4417aa4abe78dc653becf511',
352 'note': 'Videos that embed the url in the player page',
356 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
357 'uploader': 'Business of Software',
358 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/businessofsoftware',
359 'uploader_id': 'businessofsoftware',
364 'format': 'best[protocol=https]',
366 'expected_warnings': ['Unable to download JSON metadata'],
369 'url': 'http://vimeo.com/68375962',
370 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
371 'note': 'Video protected with password',
375 'title': 'youtube-dl password protected test video',
376 'timestamp': 1371200155,
377 'upload_date': '20130614',
378 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user18948128',
379 'uploader_id': 'user18948128',
380 'uploader': 'Jaime Marquínez Ferrándiz',
382 'description': 'md5:dca3ea23adb29ee387127bc4ddfce63f',
385 'format': 'best[protocol=https]',
386 'videopassword': 'youtube-dl',
390 'url': 'http://vimeo.com/channels/keypeele/75629013',
391 'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
395 'title': 'Key & Peele: Terrorist Interrogation',
396 'description': 'md5:8678b246399b070816b12313e8b4eb5c',
397 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/atencio',
398 'uploader_id': 'atencio',
399 'uploader': 'Peter Atencio',
400 'channel_id': 'keypeele',
401 'channel_url': r
're:https?://(?:www\.)?vimeo\.com/channels/keypeele',
402 'timestamp': 1380339469,
403 'upload_date': '20130928',
406 'expected_warnings': ['Unable to download JSON metadata'],
409 'url': 'http://vimeo.com/76979871',
410 'note': 'Video with subtitles',
414 'title': 'The New Vimeo Player (You Know, For Videos)',
415 'description': 'md5:2ec900bf97c3f389378a96aee11260ea',
416 'timestamp': 1381846109,
417 'upload_date': '20131015',
418 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/staff',
419 'uploader_id': 'staff',
420 'uploader': 'Vimeo Staff',
425 # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
426 'url': 'https://player.vimeo.com/video/98044508',
427 'note': 'The js code contains assignments to the same variable as the config',
431 'title': 'Pier Solar OUYA Official Trailer',
432 'uploader': 'Tulio Gonçalves',
433 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user28849593',
434 'uploader_id': 'user28849593',
438 # contains original format
439 'url': 'https://vimeo.com/33951933',
440 'md5': '53c688fa95a55bf4b7293d37a89c5c53',
444 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
445 'uploader': 'The DMCI',
446 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/dmci',
447 'uploader_id': 'dmci',
448 'timestamp': 1324343742,
449 'upload_date': '20111220',
450 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
454 'note': 'Contains original format not accessible in webpage',
455 'url': 'https://vimeo.com/393756517',
456 'md5': 'c464af248b592190a5ffbb5d33f382b0',
460 'timestamp': 1582642091,
461 'uploader_id': 'frameworkla',
462 'title': 'Straight To Hell - Sabrina: Netflix',
463 'uploader': 'Framework Studio',
464 'description': 'md5:f2edc61af3ea7a5592681ddbb683db73',
465 'upload_date': '20200225',
467 'expected_warnings': ['Unable to download JSON metadata'],
470 # only available via https://vimeo.com/channels/tributes/6213729 and
471 # not via https://vimeo.com/6213729
472 'url': 'https://vimeo.com/channels/tributes/6213729',
476 'title': 'Vimeo Tribute: The Shining',
477 'uploader': 'Casey Donahue',
478 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/caseydonahue',
479 'uploader_id': 'caseydonahue',
480 'channel_url': r
're:https?://(?:www\.)?vimeo\.com/channels/tributes',
481 'channel_id': 'tributes',
482 'timestamp': 1250886430,
483 'upload_date': '20090821',
484 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6',
487 'skip_download': True,
489 'expected_warnings': ['Unable to download JSON metadata'],
492 # redirects to ondemand extractor and should be passed through it
493 # for successful extraction
494 'url': 'https://vimeo.com/73445910',
498 'title': 'The Reluctant Revolutionary',
499 'uploader': '10Ft Films',
500 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/tenfootfilms',
501 'uploader_id': 'tenfootfilms',
502 'description': 'md5:0fa704e05b04f91f40b7f3ca2e801384',
503 'upload_date': '20130830',
504 'timestamp': 1377853339,
507 'skip_download': True,
509 'expected_warnings': ['Unable to download JSON metadata'],
510 'skip': 'this page is no longer available.',
513 'url': 'http://player.vimeo.com/video/68375962',
514 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
518 'title': 'youtube-dl password protected test video',
519 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user18948128',
520 'uploader_id': 'user18948128',
521 'uploader': 'Jaime Marquínez Ferrándiz',
525 'format': 'best[protocol=https]',
526 'videopassword': 'youtube-dl',
530 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741',
531 'only_matching': True,
534 'url': 'https://vimeo.com/109815029',
535 'note': 'Video not completely processed, "failed" seed status',
536 'only_matching': True,
539 'url': 'https://vimeo.com/groups/travelhd/videos/22439234',
540 'only_matching': True,
543 'url': 'https://vimeo.com/album/2632481/video/79010983',
544 'only_matching': True,
547 'url': 'https://vimeo.com/showcase/3253534/video/119195465',
548 'note': 'A video in a password protected album (showcase)',
552 'title': 'youtube-dl test video \'ä"BaW_jenozKc',
553 'uploader': 'Philipp Hagemeister',
554 'uploader_id': 'user20132939',
555 'description': 'md5:fa7b6c6d8db0bdc353893df2f111855b',
556 'upload_date': '20150209',
557 'timestamp': 1423518307,
560 'format': 'best[protocol=https]',
561 'videopassword': 'youtube-dl',
565 # source file returns 403: Forbidden
566 'url': 'https://vimeo.com/7809605',
567 'only_matching': True,
570 'url': 'https://vimeo.com/160743502/abd0e13fb4',
571 'only_matching': True,
574 # requires passing unlisted_hash(a52724358e) to load_download_config request
575 'url': 'https://vimeo.com/392479337/a52724358e',
576 'only_matching': True,
578 # https://gettingthingsdone.com/workflowmap/
579 # vimeo embed with check-password page protected by Referer header
583 def _smuggle_referrer(url
, referrer_url
):
584 return smuggle_url(url
, {'http_headers': {'Referer': referrer_url}
})
587 def _extract_urls(url
, webpage
):
589 # Look for embedded (iframe) Vimeo player
590 for mobj
in re
.finditer(
591 r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//player\
.vimeo\
.com
/video
/\d
+.*?
)\
1',
593 urls.append(VimeoIE._smuggle_referrer(unescapeHTML(mobj.group('url
')), url))
595 # Look for embedded (swf embed) Vimeo player
596 r'<embed
[^
>]+?src
=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1',
597 # Look more for non-standard embedded Vimeo player
598 r'<video[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:www\
.)?vimeo\
.com
/[0-9]+)\
1',
600 for embed_re in PLAIN_EMBED_RE:
601 for mobj in re.finditer(embed_re, webpage):
602 urls.append(mobj.group('url
'))
606 def _extract_url(url, webpage):
607 urls = VimeoIE._extract_urls(url, webpage)
608 return urls[0] if urls else None
610 def _verify_player_video_password(self, url, video_id, headers):
611 password = self._get_video_password()
612 data = urlencode_postdata({
613 'password
': base64.b64encode(password.encode()),
615 headers = merge_dicts(headers, {
616 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
618 checked = self._download_json(
619 url + '/check
-password
', video_id,
620 'Verifying the password
', data=data, headers=headers)
622 raise ExtractorError('Wrong video password
', expected=True)
625 def _real_initialize(self):
628 def _try_album_password(self, url):
629 album_id = self._search_regex(
630 r'vimeo\
.com
/(?
:album|showcase
)/([^
/]+)', url, 'album
id', default=None)
633 viewer = self._download_json(
634 'https
://vimeo
.com
/_rv
/viewer
', album_id, fatal=False)
636 webpage = self._download_webpage(url, album_id)
637 viewer = self._parse_json(self._search_regex(
638 r'bootstrap_data\s
*=\s
*({.+?}
)</script
>',
639 webpage, 'bootstrap data
'), album_id)['viewer
']
641 album = self._download_json(
642 'https
://api
.vimeo
.com
/albums
/' + album_id,
643 album_id, headers={'Authorization': 'jwt ' + jwt},
644 query={'fields': 'description,name,privacy'})
645 if try_get(album, lambda x: x['privacy
']['view
']) == 'password
':
646 password = self.get_param('videopassword
')
648 raise ExtractorError(
649 'This album
is protected by a password
, use the
--video
-password option
',
651 self._set_vimeo_cookie('vuid
', viewer['vuid
'])
654 'https
://vimeo
.com
/showcase
/%s/auth
' % album_id,
655 album_id, 'Verifying the password
', data=urlencode_postdata({
656 'password
': password,
657 'token
': viewer['xsrft
'],
659 'X
-Requested
-With
': 'XMLHttpRequest
',
661 except ExtractorError as e:
662 if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
663 raise ExtractorError('Wrong password
', expected=True)
666 def _real_extract(self, url):
667 url, data = unsmuggle_url(url, {})
668 headers = std_headers.copy()
669 if 'http_headers
' in data:
670 headers.update(data['http_headers
'])
671 if 'Referer
' not in headers:
672 headers['Referer
'] = url
674 # Extract ID from URL
675 video_id, unlisted_hash = re.match(self._VALID_URL, url).groups()
677 token = self._download_json(
678 'https
://vimeo
.com
/_rv
/jwt
', video_id, headers={
679 'X
-Requested
-With
': 'XMLHttpRequest
'
681 video = self._download_json(
682 'https
://api
.vimeo
.com
/videos
/%s:%s' % (video_id, unlisted_hash),
684 'Authorization
': 'jwt
' + token,
686 'fields
': 'config_url
,created_time
,description
,license
,metadata
.connections
.comments
.total
,metadata
.connections
.likes
.total
,release_time
,stats
.plays
',
688 info = self._parse_config(self._download_json(
689 video['config_url
'], video_id), video_id)
690 self._vimeo_sort_formats(info['formats
'])
691 get_timestamp = lambda x: parse_iso8601(video.get(x + '_time
'))
693 'description
': video.get('description
'),
694 'license
': video.get('license
'),
695 'release_timestamp
': get_timestamp('release
'),
696 'timestamp
': get_timestamp('created
'),
697 'view_count
': int_or_none(try_get(video, lambda x: x['stats
']['plays
'])),
699 connections = try_get(
700 video, lambda x: x['metadata
']['connections
'], dict) or {}
701 for k in ('comment
', 'like
'):
702 info[k + '_count
'] = int_or_none(try_get(connections, lambda x: x[k + 's
']['total
']))
706 is_pro = 'vimeopro
.com
/' in url
707 is_player = '://player
.vimeo
.com
/video
/' in url
709 # some videos require portfolio_id to be present in player url
710 # https://github.com/ytdl-org/youtube-dl/issues/20070
711 url = self._extract_url(url, self._download_webpage(url, video_id))
713 url = 'https
://vimeo
.com
/' + video_id
715 url = 'https
://player
.vimeo
.com
/video
/' + video_id
716 elif any(p in url for p in ('play_redirect_hls
', 'moogaloop
.swf
')):
717 url = 'https
://vimeo
.com
/' + video_id
719 self._try_album_password(url)
721 # Retrieve video webpage to extract further information
722 webpage, urlh = self._download_webpage_handle(
723 url, video_id, headers=headers)
724 redirect_url = urlh.geturl()
725 except ExtractorError as ee:
726 if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
727 errmsg = ee.cause.read()
728 if b'Because of its privacy settings
, this video cannot be played here
' in errmsg:
729 raise ExtractorError(
730 'Cannot download embed
-only video without embedding
'
731 'URL
. Please call yt
-dlp
with the URL of the page
'
732 'that embeds this video
.',
736 # Now we begin extracting as much information as we can from what we
737 # retrieved. First we extract the information common to all extractors,
738 # and latter we extract those that are Vimeo specific.
739 self.report_extraction(video_id)
741 vimeo_config = self._extract_vimeo_config(webpage, video_id, default=None)
743 seed_status = vimeo_config.get('seed_status
', {})
744 if seed_status.get('state
') == 'failed
':
745 raise ExtractorError(
746 '%s said
: %s' % (self.IE_NAME, seed_status['title
']),
751 video_description = None
753 # Extract the config JSON
756 config_url = self._html_search_regex(
757 r' data
-config
-url
="(.+?)"', webpage,
758 'config URL
', default=None)
760 # Sometimes new react-based page is served instead of old one that require
761 # different config URL extraction approach (see
762 # https://github.com/ytdl-org/youtube-dl/pull/7209)
763 page_config = self._parse_json(self._search_regex(
764 r'vimeo\
.(?
:clip|vod_title
)_page_config\s
*=\s
*({.+?}
);',
765 webpage, 'page config
'), video_id)
766 config_url = page_config['player
']['config_url
']
767 cc_license = page_config.get('cc_license
')
769 page_config, lambda x: x['clip
']['uploaded_on
'],
771 video_description = clean_html(dict_get(
772 page_config, ('description
', 'description_html_escaped
')))
773 config = self._download_json(config_url, video_id)
774 except RegexNotFoundError:
775 # For pro videos or player.vimeo.com urls
776 # We try to find out to which variable is assigned the config dic
777 m_variable_name = re.search(r'(\w
)\
.video\
.id', webpage)
778 if m_variable_name is not None:
779 config_re = [r'%s=({[^}
].+?
});' % re.escape(m_variable_name.group(1))]
781 config_re = [r' = {config:({.+?}
),assets
:', r'(?
:[abc
])=({.+?}
);']
782 config_re.append(r'\bvar\s
+r\s
*=\s
*({.+?}
)\s
*;')
783 config_re.append(r'\bconfig\s
*=\s
*({.+?}
)\s
*;')
784 config = self._search_regex(config_re, webpage, 'info section
',
786 config = json.loads(config)
787 except Exception as e:
788 if re.search('The creator of this video has
not given you permission to embed it on this domain
.', webpage):
789 raise ExtractorError('The author has restricted the access to this video
, try with the
"--referer" option
')
791 if re.search(r'<form
[^
>]+?
id="pw_form"', webpage) is not None:
792 if '_video_password_verified
' in data:
793 raise ExtractorError('video password verification failed
!')
794 video_password = self._get_video_password()
795 token, vuid = self._extract_xsrft_and_vuid(webpage)
796 self._verify_video_password(
797 redirect_url, video_id, video_password, token, vuid)
798 return self._real_extract(
799 smuggle_url(redirect_url, {'_video_password_verified': 'verified'}))
801 raise ExtractorError('Unable to extract info section
',
804 if config.get('view
') == 4:
805 config = self._verify_player_video_password(redirect_url, video_id, headers)
807 video = config.get('video
') or {}
808 vod = video.get('vod
') or {}
811 if '>You rented this title
.<' in webpage:
813 if config.get('user
', {}).get('purchased
'):
815 for purchase_option in vod.get('purchase_options
', []):
816 if purchase_option.get('purchased
'):
818 label = purchase_option.get('label_string
')
819 if label and (label.startswith('You rented this
') or label.endswith(' remaining
')):
823 if is_rented() and vod.get('is_trailer
'):
824 feature_id = vod.get('feature_id
')
825 if feature_id and not data.get('force_feature_id
', False):
826 return self.url_result(smuggle_url(
827 'https
://player
.vimeo
.com
/player
/%s' % feature_id,
828 {'force_feature_id': True}), 'Vimeo
')
830 # Extract video description
831 if not video_description:
832 video_description = self._html_search_regex(
833 r'(?s
)<div\s
+class="[^"]*description
[^
"]*"[^
>]*>(.*?
)</div
>',
834 webpage, 'description
', default=None)
835 if not video_description:
836 video_description = self._html_search_meta(
837 'description
', webpage, default=None)
838 if not video_description and is_pro:
839 orig_webpage = self._download_webpage(
841 note='Downloading webpage
for description
',
844 video_description = self._html_search_meta(
845 'description
', orig_webpage, default=None)
846 if not video_description and not is_player:
847 self.report_warning('Cannot find video description
')
849 # Extract upload date
851 timestamp = self._search_regex(
852 r'<time
[^
>]+datetime
="([^"]+)"', webpage,
853 'timestamp', default=None)
856 view_count = int(self._search_regex(r'UserPlays:(\d+)', webpage, 'view count'))
857 like_count = int(self._search_regex(r'UserLikes:(\d+)', webpage, 'like count'))
858 comment_count = int(self._search_regex(r'UserComments:(\d+)', webpage, 'comment count'))
859 except RegexNotFoundError:
860 # This info is only available in vimeo.com/{id} urls
867 source_format = self._extract_original_format(
868 'https://vimeo.com/' + video_id, video_id, video.get('unlisted_hash'))
870 formats.append(source_format)
872 info_dict_config = self._parse_config(config, video_id)
873 formats.extend(info_dict_config['formats'])
874 self._vimeo_sort_formats(formats)
876 json_ld = self._search_json_ld(webpage, video_id, default={})
879 cc_license = self._search_regex(
880 r'<link[^>]+rel=["\']license
["\'][^>]+href=(["\'])(?P
<license
>(?
:(?
!\
1).)+)\
1',
881 webpage, 'license
', default=None, group='license
')
883 channel_id = self._search_regex(
884 r'vimeo\
.com
/channels
/([^
/]+)', url, 'channel
id', default=None)
885 channel_url = 'https
://vimeo
.com
/channels
/%s' % channel_id if channel_id else None
889 'timestamp
': unified_timestamp(timestamp),
890 'description
': video_description,
892 'view_count
': view_count,
893 'like_count
': like_count,
894 'comment_count
': comment_count,
895 'license
': cc_license,
896 'channel_id
': channel_id,
897 'channel_url
': channel_url,
900 info_dict = merge_dicts(info_dict, info_dict_config, json_ld)
905 class VimeoOndemandIE(VimeoIE):
906 IE_NAME = 'vimeo
:ondemand
'
907 _VALID_URL = r'https?
://(?
:www\
.)?vimeo\
.com
/ondemand
/([^
/]+/)?
(?P
<id>[^
/?
#&]+)'
909 # ondemand video not available via https://vimeo.com/id
910 'url': 'https://vimeo.com/ondemand/20704',
911 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35',
915 'title': 'המעבדה - במאי יותם פלדמן',
916 'uploader': 'גם סרטים',
917 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/gumfilms',
918 'uploader_id': 'gumfilms',
919 'description': 'md5:4c027c965e439de4baab621e48b60791',
920 'upload_date': '20140906',
921 'timestamp': 1410032453,
924 'format': 'best[protocol=https]',
926 'expected_warnings': ['Unable to download JSON metadata'],
928 # requires Referer to be passed along with og:video:url
929 'url': 'https://vimeo.com/ondemand/36938/126682985',
933 'title': 'Rävlock, rätt läte på rätt plats',
934 'uploader': 'Lindroth & Norin',
935 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/lindrothnorin',
936 'uploader_id': 'lindrothnorin',
937 'description': 'md5:c3c46a90529612c8279fb6af803fc0df',
938 'upload_date': '20150502',
939 'timestamp': 1430586422,
942 'skip_download': True,
944 'expected_warnings': ['Unable to download JSON metadata'],
946 'url': 'https://vimeo.com/ondemand/nazmaalik',
947 'only_matching': True,
949 'url': 'https://vimeo.com/ondemand/141692381',
950 'only_matching': True,
952 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832',
953 'only_matching': True,
957 class VimeoChannelIE(VimeoBaseInfoExtractor
):
958 IE_NAME
= 'vimeo:channel'
959 _VALID_URL
= r
'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
960 _MORE_PAGES_INDICATOR
= r
'<a.+?rel="next"'
962 _TITLE_RE
= r
'<link rel="alternate"[^>]+?title="(.*?)"'
964 'url': 'https://vimeo.com/channels/tributes',
967 'title': 'Vimeo Tributes',
969 'playlist_mincount': 25,
971 _BASE_URL_TEMPL
= 'https://vimeo.com/channels/%s'
973 def _page_url(self
, base_url
, pagenum
):
974 return '%s/videos/page:%d/' % (base_url
, pagenum
)
976 def _extract_list_title(self
, webpage
):
977 return self
._TITLE
or self
._html
_search
_regex
(
978 self
._TITLE
_RE
, webpage
, 'list title', fatal
=False)
980 def _title_and_entries(self
, list_id
, base_url
):
981 for pagenum
in itertools
.count(1):
982 page_url
= self
._page
_url
(base_url
, pagenum
)
983 webpage
= self
._download
_webpage
(
985 'Downloading page %s' % pagenum
)
988 yield self
._extract
_list
_title
(webpage
)
990 # Try extracting href first since not all videos are available via
991 # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729)
993 r
'id="clip_(\d+)"[^>]*>\s*<a[^>]+href="(/(?:[^/]+/)*\1)(?:[^>]+\btitle="([^"]+)")?', webpage
)
995 for video_id
, video_url
, video_title
in clips
:
996 yield self
.url_result(
997 compat_urlparse
.urljoin(base_url
, video_url
),
998 VimeoIE
.ie_key(), video_id
=video_id
, video_title
=video_title
)
999 # More relaxed fallback
1001 for video_id
in re
.findall(r
'id=["\']clip_(\d
+)', webpage):
1002 yield self.url_result(
1003 'https
://vimeo
.com
/%s' % video_id,
1004 VimeoIE.ie_key(), video_id=video_id)
1006 if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
1009 def _extract_videos(self, list_id, base_url):
1010 title_and_entries = self._title_and_entries(list_id, base_url)
1011 list_title = next(title_and_entries)
1012 return self.playlist_result(title_and_entries, list_id, list_title)
1014 def _real_extract(self, url):
1015 channel_id = self._match_id(url)
1016 return self._extract_videos(channel_id, self._BASE_URL_TEMPL % channel_id)
1019 class VimeoUserIE(VimeoChannelIE):
1020 IE_NAME = 'vimeo
:user
'
1021 _VALID_URL = r'https
://vimeo\
.com
/(?
!(?
:[0-9]+|watchlater
)(?
:$|
[?
#/]))(?P<id>[^/]+)(?:/videos|[#?]|$)'
1022 _TITLE_RE
= r
'<a[^>]+?class="user">([^<>]+?)</a>'
1024 'url': 'https://vimeo.com/nkistudio/videos',
1029 'playlist_mincount': 66,
1031 _BASE_URL_TEMPL
= 'https://vimeo.com/%s'
1034 class VimeoAlbumIE(VimeoBaseInfoExtractor
):
1035 IE_NAME
= 'vimeo:album'
1036 _VALID_URL
= r
'https://vimeo\.com/(?:album|showcase)/(?P<id>\d+)(?:$|[?#]|/(?!video))'
1037 _TITLE_RE
= r
'<header id="page_header">\n\s*<h1>(.*?)</h1>'
1039 'url': 'https://vimeo.com/album/2632481',
1042 'title': 'Staff Favorites: November 2013',
1044 'playlist_mincount': 13,
1046 'note': 'Password-protected album',
1047 'url': 'https://vimeo.com/album/3253534',
1052 'playlist_count': 1,
1054 'videopassword': 'youtube-dl',
1059 def _fetch_page(self
, album_id
, authorization
, hashed_pass
, page
):
1062 'fields': 'link,uri',
1064 'per_page': self
._PAGE
_SIZE
,
1067 query
['_hashed_pass'] = hashed_pass
1069 videos
= self
._download
_json
(
1070 'https://api.vimeo.com/albums/%s/videos' % album_id
,
1071 album_id
, 'Downloading page %d' % api_page
, query
=query
, headers
={
1072 'Authorization': 'jwt ' + authorization
,
1074 except ExtractorError
as e
:
1075 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
1077 for video
in videos
:
1078 link
= video
.get('link')
1081 uri
= video
.get('uri')
1082 video_id
= self
._search
_regex
(r
'/videos/(\d+)', uri
, 'video_id', default
=None) if uri
else None
1083 yield self
.url_result(link
, VimeoIE
.ie_key(), video_id
)
1085 def _real_extract(self
, url
):
1086 album_id
= self
._match
_id
(url
)
1087 viewer
= self
._download
_json
(
1088 'https://vimeo.com/_rv/viewer', album_id
, fatal
=False)
1090 webpage
= self
._download
_webpage
(url
, album_id
)
1091 viewer
= self
._parse
_json
(self
._search
_regex
(
1092 r
'bootstrap_data\s*=\s*({.+?})</script>',
1093 webpage
, 'bootstrap data'), album_id
)['viewer']
1095 album
= self
._download
_json
(
1096 'https://api.vimeo.com/albums/' + album_id
,
1097 album_id
, headers
={'Authorization': 'jwt ' + jwt}
,
1098 query
={'fields': 'description,name,privacy'}
)
1100 if try_get(album
, lambda x
: x
['privacy']['view']) == 'password':
1101 password
= self
.get_param('videopassword')
1103 raise ExtractorError(
1104 'This album is protected by a password, use the --video-password option',
1106 self
._set
_vimeo
_cookie
('vuid', viewer
['vuid'])
1108 hashed_pass
= self
._download
_json
(
1109 'https://vimeo.com/showcase/%s/auth' % album_id
,
1110 album_id
, 'Verifying the password', data
=urlencode_postdata({
1111 'password': password
,
1112 'token': viewer
['xsrft'],
1114 'X-Requested-With': 'XMLHttpRequest',
1116 except ExtractorError
as e
:
1117 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 401:
1118 raise ExtractorError('Wrong password', expected
=True)
1120 entries
= OnDemandPagedList(functools
.partial(
1121 self
._fetch
_page
, album_id
, jwt
, hashed_pass
), self
._PAGE
_SIZE
)
1122 return self
.playlist_result(
1123 entries
, album_id
, album
.get('name'), album
.get('description'))
1126 class VimeoGroupsIE(VimeoChannelIE
):
1127 IE_NAME
= 'vimeo:group'
1128 _VALID_URL
= r
'https://vimeo\.com/groups/(?P<id>[^/]+)(?:/(?!videos?/\d+)|$)'
1130 'url': 'https://vimeo.com/groups/kattykay',
1133 'title': 'Katty Kay',
1135 'playlist_mincount': 27,
1137 _BASE_URL_TEMPL
= 'https://vimeo.com/groups/%s'
1140 class VimeoReviewIE(VimeoBaseInfoExtractor
):
1141 IE_NAME
= 'vimeo:review'
1142 IE_DESC
= 'Review pages on vimeo'
1143 _VALID_URL
= r
'(?P<url>https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)/[0-9a-f]{10})'
1145 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
1146 'md5': 'c507a72f780cacc12b2248bb4006d253',
1150 'title': "DICK HARDWICK 'Comedian'",
1151 'uploader': 'Richard Hardwick',
1152 'uploader_id': 'user21297594',
1153 'description': "Comedian Dick Hardwick's five minute demo filmed in front of a live theater audience.\nEdit by Doug Mattocks",
1155 'expected_warnings': ['Unable to download JSON metadata'],
1157 'note': 'video player needs Referer',
1158 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
1159 'md5': '6295fdab8f4bf6a002d058b2c6dce276',
1163 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
1164 'uploader': 'DevWeek Events',
1166 'thumbnail': r
're:^https?://.*\.jpg$',
1167 'uploader_id': 'user22258446',
1169 'skip': 'video gone',
1171 'note': 'Password protected',
1172 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde',
1176 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1',
1178 'uploader_id': 'user37284429',
1181 'videopassword': 'holygrail',
1183 'skip': 'video gone',
1186 def _real_initialize(self
):
1189 def _real_extract(self
, url
):
1190 page_url
, video_id
= re
.match(self
._VALID
_URL
, url
).groups()
1191 data
= self
._download
_json
(
1192 page_url
.replace('/review/', '/review/data/'), video_id
)
1193 if data
.get('isLocked') is True:
1194 video_password
= self
._get
_video
_password
()
1195 viewer
= self
._download
_json
(
1196 'https://vimeo.com/_rv/viewer', video_id
)
1197 webpage
= self
._verify
_video
_password
(
1198 'https://vimeo.com/' + video_id
, video_id
,
1199 video_password
, viewer
['xsrft'], viewer
['vuid'])
1200 clip_page_config
= self
._parse
_json
(self
._search
_regex
(
1201 r
'window\.vimeo\.clip_page_config\s*=\s*({.+?});',
1202 webpage
, 'clip page config'), video_id
)
1203 config_url
= clip_page_config
['player']['config_url']
1204 clip_data
= clip_page_config
.get('clip') or {}
1206 clip_data
= data
['clipData']
1207 config_url
= clip_data
['configUrl']
1208 config
= self
._download
_json
(config_url
, video_id
)
1209 info_dict
= self
._parse
_config
(config
, video_id
)
1210 source_format
= self
._extract
_original
_format
(
1211 page_url
+ '/action', video_id
)
1213 info_dict
['formats'].append(source_format
)
1214 self
._vimeo
_sort
_formats
(info_dict
['formats'])
1215 info_dict
['description'] = clean_html(clip_data
.get('description'))
1219 class VimeoWatchLaterIE(VimeoChannelIE
):
1220 IE_NAME
= 'vimeo:watchlater'
1221 IE_DESC
= 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)'
1222 _VALID_URL
= r
'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater'
1223 _TITLE
= 'Watch Later'
1224 _LOGIN_REQUIRED
= True
1226 'url': 'https://vimeo.com/watchlater',
1227 'only_matching': True,
1230 def _real_initialize(self
):
1233 def _page_url(self
, base_url
, pagenum
):
1234 url
= '%s/page:%d/' % (base_url
, pagenum
)
1235 request
= sanitized_Request(url
)
1236 # Set the header to get a partial html page with the ids,
1237 # the normal page doesn't contain them.
1238 request
.add_header('X-Requested-With', 'XMLHttpRequest')
1241 def _real_extract(self
, url
):
1242 return self
._extract
_videos
('watchlater', 'https://vimeo.com/watchlater')
1245 class VimeoLikesIE(VimeoChannelIE
):
1246 _VALID_URL
= r
'https://(?:www\.)?vimeo\.com/(?P<id>[^/]+)/likes/?(?:$|[?#]|sort:)'
1247 IE_NAME
= 'vimeo:likes'
1248 IE_DESC
= 'Vimeo user likes'
1250 'url': 'https://vimeo.com/user755559/likes/',
1251 'playlist_mincount': 293,
1254 'title': 'urza’s Likes',
1257 'url': 'https://vimeo.com/stormlapse/likes',
1258 'only_matching': True,
1261 def _page_url(self
, base_url
, pagenum
):
1262 return '%s/page:%d/' % (base_url
, pagenum
)
1264 def _real_extract(self
, url
):
1265 user_id
= self
._match
_id
(url
)
1266 return self
._extract
_videos
(user_id
, 'https://vimeo.com/%s/likes' % user_id
)
1269 class VHXEmbedIE(VimeoBaseInfoExtractor
):
1270 IE_NAME
= 'vhx:embed'
1271 _VALID_URL
= r
'https?://embed\.vhx\.tv/videos/(?P<id>\d+)'
1274 def _extract_url(webpage
):
1276 r
'<iframe[^>]+src="(https?://embed\.vhx\.tv/videos/\d+[^"]*)"', webpage
)
1277 return unescapeHTML(mobj
.group(1)) if mobj
else None
1279 def _real_extract(self
, url
):
1280 video_id
= self
._match
_id
(url
)
1281 webpage
= self
._download
_webpage
(url
, video_id
)
1282 config_url
= self
._parse
_json
(self
._search
_regex
(
1283 r
'window\.OTTData\s*=\s*({.+})', webpage
,
1284 'ott data'), video_id
, js_to_json
)['config_url']
1285 config
= self
._download
_json
(config_url
, video_id
)
1286 info
= self
._parse
_config
(config
, video_id
)
1287 info
['id'] = video_id
1288 self
._vimeo
_sort
_formats
(info
['formats'])