2 from __future__
import unicode_literals
10 from .common
import InfoExtractor
11 from ..compat
import (
43 class VimeoBaseInfoExtractor(InfoExtractor
):
44 _NETRC_MACHINE
= 'vimeo'
45 _LOGIN_REQUIRED
= False
46 _LOGIN_URL
= 'https://vimeo.com/log_in'
49 username
, password
= self
._get
_login
_info
()
51 if self
._LOGIN
_REQUIRED
:
52 raise ExtractorError('No login info available, needed for using %s.' % self
.IE_NAME
, expected
=True)
54 webpage
= self
._download
_webpage
(
55 self
._LOGIN
_URL
, None, 'Downloading login page')
56 token
, vuid
= self
._extract
_xsrft
_and
_vuid
(webpage
)
64 self
._set
_vimeo
_cookie
('vuid', vuid
)
66 self
._download
_webpage
(
67 self
._LOGIN
_URL
, None, 'Logging in',
68 data
=urlencode_postdata(data
), headers
={
69 'Content-Type': 'application/x-www-form-urlencoded',
70 'Referer': self
._LOGIN
_URL
,
72 except ExtractorError
as e
:
73 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 418:
75 'Unable to log in: bad username or password',
77 raise ExtractorError('Unable to log in')
79 def _get_video_password(self
):
80 password
= self
.get_param('videopassword')
83 'This video is protected by a password, use the --video-password option',
87 def _verify_video_password(self
, url
, video_id
, password
, token
, vuid
):
88 if url
.startswith('http://'):
89 # vimeo only supports https now, but the user can give an http url
90 url
= url
.replace('http://', 'https://')
91 self
._set
_vimeo
_cookie
('vuid', vuid
)
92 return self
._download
_webpage
(
93 url
+ '/password', video_id
, 'Verifying the password',
94 'Wrong password', data
=urlencode_postdata({
98 'Content-Type': 'application/x-www-form-urlencoded',
102 def _extract_xsrft_and_vuid(self
, webpage
):
103 xsrft
= self
._search
_regex
(
104 r
'(?:(?P<q1>["\'])xsrft(?P
=q1
)\s
*:|xsrft\s
*[=:])\s
*(?P
<q
>["\'])(?P<xsrft>.+?)(?P=q)',
105 webpage, 'login token', group='xsrft')
106 vuid = self._search_regex(
107 r'["\']vuid
["\']\s*:\s*(["\'])(?P
<vuid
>.+?
)\
1',
108 webpage, 'vuid
', group='vuid
')
111 def _extract_vimeo_config(self, webpage, video_id, *args, **kwargs):
112 vimeo_config = self._search_regex(
113 r'vimeo\
.config\s
*=\s
*(?
:({.+?}
)|_extend\
([^
,]+,\s
+({.+?}
)\
));',
114 webpage, 'vimeo config
', *args, **compat_kwargs(kwargs))
116 return self._parse_json(vimeo_config, video_id)
118 def _set_vimeo_cookie(self, name, value):
119 self._set_cookie('vimeo
.com
', name, value)
121 def _vimeo_sort_formats(self, formats):
122 # Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps
123 # at the same time without actual units specified. This lead to wrong sorting.
124 # But since yt-dlp prefers 'res
,fps
' anyway, 'field_preference
' is not needed
125 self._sort_formats(formats)
127 def _parse_config(self, config, video_id):
128 video_data = config['video
']
129 video_title = video_data['title
']
130 live_event = video_data.get('live_event
') or {}
131 is_live = live_event.get('status
') == 'started
'
134 config_files = video_data.get('files
') or config['request
'].get('files
', {})
135 for f in config_files.get('progressive
', []):
136 video_url = f.get('url
')
141 'format_id
': 'http
-%s' % f.get('quality
'),
142 'width
': int_or_none(f.get('width
')),
143 'height
': int_or_none(f.get('height
')),
144 'fps
': int_or_none(f.get('fps
')),
145 'tbr
': int_or_none(f.get('bitrate
')),
148 # TODO: fix handling of 308 status code returned for live archive manifest requests
149 sep_pattern = r'/sep
/video
/'
150 for files_type in ('hls
', 'dash
'):
151 for cdn_name, cdn_data in config_files.get(files_type, {}).get('cdns', {}).items():
152 manifest_url = cdn_data.get('url
')
155 format_id = '%s-%s' % (files_type, cdn_name)
156 sep_manifest_urls = []
157 if re.search(sep_pattern, manifest_url):
158 for suffix, repl in (('', 'video
'), ('_sep
', 'sep
/video
')):
159 sep_manifest_urls.append((format_id + suffix, re.sub(
160 sep_pattern, '/%s/' % repl, manifest_url)))
162 sep_manifest_urls = [(format_id, manifest_url)]
163 for f_id, m_url in sep_manifest_urls:
164 if files_type == 'hls
':
165 formats.extend(self._extract_m3u8_formats(
166 m_url, video_id, 'mp4
',
167 'm3u8
' if is_live else 'm3u8_native
', m3u8_id=f_id,
168 note='Downloading
%s m3u8 information
' % cdn_name,
170 elif files_type == 'dash
':
171 if 'json
=1' in m_url:
172 real_m_url = (self._download_json(m_url, video_id, fatal=False) or {}).get('url
')
175 mpd_formats = self._extract_mpd_formats(
176 m_url.replace('/master
.json
', '/master
.mpd
'), video_id, f_id,
177 'Downloading
%s MPD information
' % cdn_name,
179 formats.extend(mpd_formats)
181 live_archive = live_event.get('archive
') or {}
182 live_archive_source_url = live_archive.get('source_url
')
183 if live_archive_source_url and live_archive.get('status
') == 'done
':
185 'format_id
': 'live
-archive
-source
',
186 'url
': live_archive_source_url,
191 text_tracks = config['request
'].get('text_tracks
')
193 for tt in text_tracks:
194 subtitles[tt['lang
']] = [{
196 'url
': urljoin('https
://vimeo
.com
', tt['url
']),
201 for key, thumb in video_data.get('thumbs
', {}).items():
204 'width
': int_or_none(key),
207 thumbnail = video_data.get('thumbnail
')
213 owner = video_data.get('owner
') or {}
214 video_uploader_url = owner.get('url
')
217 'id': str_or_none(video_data.get('id')) or video_id,
218 'title
': self._live_title(video_title) if is_live else video_title,
219 'uploader
': owner.get('name
'),
220 'uploader_id
': video_uploader_url.split('/')[-1] if video_uploader_url else None,
221 'uploader_url
': video_uploader_url,
222 'thumbnails
': thumbnails,
223 'duration
': int_or_none(video_data.get('duration
')),
225 'subtitles
': subtitles,
229 def _extract_original_format(self, url, video_id, unlisted_hash=None):
230 query = {'action': 'load_download_config'}
232 query['unlisted_hash
'] = unlisted_hash
233 download_data = self._download_json(
234 url, video_id, fatal=False, query=query,
235 headers={'X-Requested-With': 'XMLHttpRequest'})
237 source_file = download_data.get('source_file
')
238 if isinstance(source_file, dict):
239 download_url = source_file.get('download_url
')
240 if download_url and not source_file.get('is_cold
') and not source_file.get('is_defrosting
'):
241 source_name = source_file.get('public_name
', 'Original
')
242 if self._is_valid_url(download_url, video_id, '%s video
' % source_name):
244 source_file, lambda x: x['extension
'],
245 compat_str) or determine_ext(
246 download_url, None) or 'mp4
').lower()
250 'width
': int_or_none(source_file.get('width
')),
251 'height
': int_or_none(source_file.get('height
')),
252 'filesize
': parse_filesize(source_file.get('size
')),
253 'format_id
': source_name,
257 jwt_response = self._download_json(
258 'https
://vimeo
.com
/_rv
/viewer
', video_id, note='Downloading jwt token
', fatal=False) or {}
259 if not jwt_response.get('jwt
'):
261 headers = {'Authorization': 'jwt %s' % jwt_response['jwt']}
262 original_response = self._download_json(
263 f'https
://api
.vimeo
.com
/videos
/{video_id}
', video_id,
264 headers=headers, fatal=False) or {}
265 for download_data in original_response.get('download
') or {}:
266 download_url = download_data.get('link
')
267 if not download_url or download_data.get('quality
') != 'source
':
269 query = parse_qs(download_url)
272 'ext
': determine_ext(query.get('filename
', [''])[0].lower()),
273 'format_id
': download_data.get('public_name
', 'Original
'),
274 'width
': int_or_none(download_data.get('width
')),
275 'height
': int_or_none(download_data.get('height
')),
276 'fps
': int_or_none(download_data.get('fps
')),
277 'filesize
': int_or_none(download_data.get('size
')),
282 class VimeoIE(VimeoBaseInfoExtractor):
283 """Information extractor for vimeo.com."""
285 # _VALID_URL matches Vimeo URLs
286 _VALID_URL = r'''(?x)
296 (?!(?:channels|album|showcase)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/)
301 moogaloop\.swf)\?clip_id=
305 (?:/(?P<unlisted_hash>[\da-f]{10}))?
306 /?(?:[?&].*)?(?:[#].*)?$
311 'url
': 'http
://vimeo
.com
/56015672#at=0',
312 'md5': '8879b6cc097e987f02484baf890129e5',
316 'title': "youtube-dl test video - \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550",
317 'description': 'md5:2d3305bad981a06ff79f027f19865021',
318 'timestamp': 1355990239,
319 'upload_date': '20121220',
320 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user7108434',
321 'uploader_id': 'user7108434',
322 'uploader': 'Filippo Valsorda',
327 'format': 'best[protocol=https]',
331 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
332 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
333 'note': 'Vimeo Pro video (#1197)',
337 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/openstreetmapus',
338 'uploader_id': 'openstreetmapus',
339 'uploader': 'OpenStreetMap US',
340 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
341 'description': 'md5:2c362968038d4499f4d79f88458590c1',
343 'upload_date': '20130610',
344 'timestamp': 1370893156,
347 'format': 'best[protocol=https]',
351 'url': 'http://player.vimeo.com/video/54469442',
352 'md5': '619b811a4417aa4abe78dc653becf511',
353 'note': 'Videos that embed the url in the player page',
357 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
358 'uploader': 'Business of Software',
359 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/businessofsoftware',
360 'uploader_id': 'businessofsoftware',
365 'format': 'best[protocol=https]',
367 'expected_warnings': ['Unable to download JSON metadata'],
370 'url': 'http://vimeo.com/68375962',
371 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
372 'note': 'Video protected with password',
376 'title': 'youtube-dl password protected test video',
377 'timestamp': 1371200155,
378 'upload_date': '20130614',
379 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user18948128',
380 'uploader_id': 'user18948128',
381 'uploader': 'Jaime Marquínez Ferrándiz',
383 'description': 'md5:dca3ea23adb29ee387127bc4ddfce63f',
386 'format': 'best[protocol=https]',
387 'videopassword': 'youtube-dl',
391 'url': 'http://vimeo.com/channels/keypeele/75629013',
392 'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
396 'title': 'Key & Peele: Terrorist Interrogation',
397 'description': 'md5:8678b246399b070816b12313e8b4eb5c',
398 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/atencio',
399 'uploader_id': 'atencio',
400 'uploader': 'Peter Atencio',
401 'channel_id': 'keypeele',
402 'channel_url': r
're:https?://(?:www\.)?vimeo\.com/channels/keypeele',
403 'timestamp': 1380339469,
404 'upload_date': '20130928',
407 'expected_warnings': ['Unable to download JSON metadata'],
410 'url': 'http://vimeo.com/76979871',
411 'note': 'Video with subtitles',
415 'title': 'The New Vimeo Player (You Know, For Videos)',
416 'description': 'md5:2ec900bf97c3f389378a96aee11260ea',
417 'timestamp': 1381846109,
418 'upload_date': '20131015',
419 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/staff',
420 'uploader_id': 'staff',
421 'uploader': 'Vimeo Staff',
426 # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
427 'url': 'https://player.vimeo.com/video/98044508',
428 'note': 'The js code contains assignments to the same variable as the config',
432 'title': 'Pier Solar OUYA Official Trailer',
433 'uploader': 'Tulio Gonçalves',
434 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user28849593',
435 'uploader_id': 'user28849593',
439 # contains original format
440 'url': 'https://vimeo.com/33951933',
441 'md5': '53c688fa95a55bf4b7293d37a89c5c53',
445 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
446 'uploader': 'The DMCI',
447 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/dmci',
448 'uploader_id': 'dmci',
449 'timestamp': 1324343742,
450 'upload_date': '20111220',
451 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
455 'note': 'Contains original format not accessible in webpage',
456 'url': 'https://vimeo.com/393756517',
457 'md5': 'c464af248b592190a5ffbb5d33f382b0',
461 'timestamp': 1582642091,
462 'uploader_id': 'frameworkla',
463 'title': 'Straight To Hell - Sabrina: Netflix',
464 'uploader': 'Framework Studio',
465 'description': 'md5:f2edc61af3ea7a5592681ddbb683db73',
466 'upload_date': '20200225',
468 'expected_warnings': ['Unable to download JSON metadata'],
471 # only available via https://vimeo.com/channels/tributes/6213729 and
472 # not via https://vimeo.com/6213729
473 'url': 'https://vimeo.com/channels/tributes/6213729',
477 'title': 'Vimeo Tribute: The Shining',
478 'uploader': 'Casey Donahue',
479 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/caseydonahue',
480 'uploader_id': 'caseydonahue',
481 'channel_url': r
're:https?://(?:www\.)?vimeo\.com/channels/tributes',
482 'channel_id': 'tributes',
483 'timestamp': 1250886430,
484 'upload_date': '20090821',
485 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6',
488 'skip_download': True,
490 'expected_warnings': ['Unable to download JSON metadata'],
493 # redirects to ondemand extractor and should be passed through it
494 # for successful extraction
495 'url': 'https://vimeo.com/73445910',
499 'title': 'The Reluctant Revolutionary',
500 'uploader': '10Ft Films',
501 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/tenfootfilms',
502 'uploader_id': 'tenfootfilms',
503 'description': 'md5:0fa704e05b04f91f40b7f3ca2e801384',
504 'upload_date': '20130830',
505 'timestamp': 1377853339,
508 'skip_download': True,
510 'expected_warnings': ['Unable to download JSON metadata'],
511 'skip': 'this page is no longer available.',
514 'url': 'http://player.vimeo.com/video/68375962',
515 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
519 'title': 'youtube-dl password protected test video',
520 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user18948128',
521 'uploader_id': 'user18948128',
522 'uploader': 'Jaime Marquínez Ferrándiz',
526 'format': 'best[protocol=https]',
527 'videopassword': 'youtube-dl',
531 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741',
532 'only_matching': True,
535 'url': 'https://vimeo.com/109815029',
536 'note': 'Video not completely processed, "failed" seed status',
537 'only_matching': True,
540 'url': 'https://vimeo.com/groups/travelhd/videos/22439234',
541 'only_matching': True,
544 'url': 'https://vimeo.com/album/2632481/video/79010983',
545 'only_matching': True,
548 'url': 'https://vimeo.com/showcase/3253534/video/119195465',
549 'note': 'A video in a password protected album (showcase)',
553 'title': 'youtube-dl test video \'ä"BaW_jenozKc',
554 'uploader': 'Philipp Hagemeister',
555 'uploader_id': 'user20132939',
556 'description': 'md5:fa7b6c6d8db0bdc353893df2f111855b',
557 'upload_date': '20150209',
558 'timestamp': 1423518307,
561 'format': 'best[protocol=https]',
562 'videopassword': 'youtube-dl',
566 # source file returns 403: Forbidden
567 'url': 'https://vimeo.com/7809605',
568 'only_matching': True,
571 'url': 'https://vimeo.com/160743502/abd0e13fb4',
572 'only_matching': True,
575 # requires passing unlisted_hash(a52724358e) to load_download_config request
576 'url': 'https://vimeo.com/392479337/a52724358e',
577 'only_matching': True,
579 # https://gettingthingsdone.com/workflowmap/
580 # vimeo embed with check-password page protected by Referer header
584 def _smuggle_referrer(url
, referrer_url
):
585 return smuggle_url(url
, {'http_headers': {'Referer': referrer_url}
})
588 def _extract_urls(url
, webpage
):
590 # Look for embedded (iframe) Vimeo player
591 for mobj
in re
.finditer(
592 r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//player\
.vimeo\
.com
/video
/\d
+.*?
)\
1',
594 urls.append(VimeoIE._smuggle_referrer(unescapeHTML(mobj.group('url
')), url))
596 # Look for embedded (swf embed) Vimeo player
597 r'<embed
[^
>]+?src
=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1',
598 # Look more for non-standard embedded Vimeo player
599 r'<video[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:www\
.)?vimeo\
.com
/[0-9]+)\
1',
601 for embed_re in PLAIN_EMBED_RE:
602 for mobj in re.finditer(embed_re, webpage):
603 urls.append(mobj.group('url
'))
607 def _extract_url(url, webpage):
608 urls = VimeoIE._extract_urls(url, webpage)
609 return urls[0] if urls else None
611 def _verify_player_video_password(self, url, video_id, headers):
612 password = self._get_video_password()
613 data = urlencode_postdata({
614 'password
': base64.b64encode(password.encode()),
616 headers = merge_dicts(headers, {
617 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
619 checked = self._download_json(
620 url + '/check
-password
', video_id,
621 'Verifying the password
', data=data, headers=headers)
623 raise ExtractorError('Wrong video password
', expected=True)
626 def _real_initialize(self):
629 def _try_album_password(self, url):
630 album_id = self._search_regex(
631 r'vimeo\
.com
/(?
:album|showcase
)/([^
/]+)', url, 'album
id', default=None)
634 viewer = self._download_json(
635 'https
://vimeo
.com
/_rv
/viewer
', album_id, fatal=False)
637 webpage = self._download_webpage(url, album_id)
638 viewer = self._parse_json(self._search_regex(
639 r'bootstrap_data\s
*=\s
*({.+?}
)</script
>',
640 webpage, 'bootstrap data
'), album_id)['viewer
']
642 album = self._download_json(
643 'https
://api
.vimeo
.com
/albums
/' + album_id,
644 album_id, headers={'Authorization': 'jwt ' + jwt},
645 query={'fields': 'description,name,privacy'})
646 if try_get(album, lambda x: x['privacy
']['view
']) == 'password
':
647 password = self.get_param('videopassword
')
649 raise ExtractorError(
650 'This album
is protected by a password
, use the
--video
-password option
',
652 self._set_vimeo_cookie('vuid
', viewer['vuid
'])
655 'https
://vimeo
.com
/showcase
/%s/auth
' % album_id,
656 album_id, 'Verifying the password
', data=urlencode_postdata({
657 'password
': password,
658 'token
': viewer['xsrft
'],
660 'X
-Requested
-With
': 'XMLHttpRequest
',
662 except ExtractorError as e:
663 if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
664 raise ExtractorError('Wrong password
', expected=True)
667 def _real_extract(self, url):
668 url, data = unsmuggle_url(url, {})
669 headers = std_headers.copy()
670 if 'http_headers
' in data:
671 headers.update(data['http_headers
'])
672 if 'Referer
' not in headers:
673 headers['Referer
'] = url
675 # Extract ID from URL
676 video_id, unlisted_hash = self._match_valid_url(url).groups()
678 token = self._download_json(
679 'https
://vimeo
.com
/_rv
/jwt
', video_id, headers={
680 'X
-Requested
-With
': 'XMLHttpRequest
'
682 video = self._download_json(
683 'https
://api
.vimeo
.com
/videos
/%s:%s' % (video_id, unlisted_hash),
685 'Authorization
': 'jwt
' + token,
687 'fields
': 'config_url
,created_time
,description
,license
,metadata
.connections
.comments
.total
,metadata
.connections
.likes
.total
,release_time
,stats
.plays
',
689 info = self._parse_config(self._download_json(
690 video['config_url
'], video_id), video_id)
691 self._vimeo_sort_formats(info['formats
'])
692 get_timestamp = lambda x: parse_iso8601(video.get(x + '_time
'))
694 'description
': video.get('description
'),
695 'license
': video.get('license
'),
696 'release_timestamp
': get_timestamp('release
'),
697 'timestamp
': get_timestamp('created
'),
698 'view_count
': int_or_none(try_get(video, lambda x: x['stats
']['plays
'])),
700 connections = try_get(
701 video, lambda x: x['metadata
']['connections
'], dict) or {}
702 for k in ('comment
', 'like
'):
703 info[k + '_count
'] = int_or_none(try_get(connections, lambda x: x[k + 's
']['total
']))
707 is_pro = 'vimeopro
.com
/' in url
708 is_player = '://player
.vimeo
.com
/video
/' in url
710 # some videos require portfolio_id to be present in player url
711 # https://github.com/ytdl-org/youtube-dl/issues/20070
712 url = self._extract_url(url, self._download_webpage(url, video_id))
714 url = 'https
://vimeo
.com
/' + video_id
716 url = 'https
://player
.vimeo
.com
/video
/' + video_id
717 elif any(p in url for p in ('play_redirect_hls
', 'moogaloop
.swf
')):
718 url = 'https
://vimeo
.com
/' + video_id
720 self._try_album_password(url)
722 # Retrieve video webpage to extract further information
723 webpage, urlh = self._download_webpage_handle(
724 url, video_id, headers=headers)
725 redirect_url = urlh.geturl()
726 except ExtractorError as ee:
727 if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
728 errmsg = ee.cause.read()
729 if b'Because of its privacy settings
, this video cannot be played here
' in errmsg:
730 raise ExtractorError(
731 'Cannot download embed
-only video without embedding
'
732 'URL
. Please call yt
-dlp
with the URL of the page
'
733 'that embeds this video
.',
737 # Now we begin extracting as much information as we can from what we
738 # retrieved. First we extract the information common to all extractors,
739 # and latter we extract those that are Vimeo specific.
740 self.report_extraction(video_id)
742 vimeo_config = self._extract_vimeo_config(webpage, video_id, default=None)
744 seed_status = vimeo_config.get('seed_status
', {})
745 if seed_status.get('state
') == 'failed
':
746 raise ExtractorError(
747 '%s said
: %s' % (self.IE_NAME, seed_status['title
']),
752 video_description = None
754 # Extract the config JSON
757 config_url = self._html_search_regex(
758 r' data
-config
-url
="(.+?)"', webpage,
759 'config URL
', default=None)
761 # Sometimes new react-based page is served instead of old one that require
762 # different config URL extraction approach (see
763 # https://github.com/ytdl-org/youtube-dl/pull/7209)
764 page_config = self._parse_json(self._search_regex(
765 r'vimeo\
.(?
:clip|vod_title
)_page_config\s
*=\s
*({.+?}
);',
766 webpage, 'page config
'), video_id)
767 config_url = page_config['player
']['config_url
']
768 cc_license = page_config.get('cc_license
')
770 page_config, lambda x: x['clip
']['uploaded_on
'],
772 video_description = clean_html(dict_get(
773 page_config, ('description
', 'description_html_escaped
')))
774 config = self._download_json(config_url, video_id)
775 except RegexNotFoundError:
776 # For pro videos or player.vimeo.com urls
777 # We try to find out to which variable is assigned the config dic
778 m_variable_name = re.search(r'(\w
)\
.video\
.id', webpage)
779 if m_variable_name is not None:
780 config_re = [r'%s=({[^}
].+?
});' % re.escape(m_variable_name.group(1))]
782 config_re = [r' = {config:({.+?}
),assets
:', r'(?
:[abc
])=({.+?}
);']
783 config_re.append(r'\bvar\s
+r\s
*=\s
*({.+?}
)\s
*;')
784 config_re.append(r'\bconfig\s
*=\s
*({.+?}
)\s
*;')
785 config = self._search_regex(config_re, webpage, 'info section
',
787 config = json.loads(config)
788 except Exception as e:
789 if re.search('The creator of this video has
not given you permission to embed it on this domain
.', webpage):
790 raise ExtractorError('The author has restricted the access to this video
, try with the
"--referer" option
')
792 if re.search(r'<form
[^
>]+?
id="pw_form"', webpage) is not None:
793 if '_video_password_verified
' in data:
794 raise ExtractorError('video password verification failed
!')
795 video_password = self._get_video_password()
796 token, vuid = self._extract_xsrft_and_vuid(webpage)
797 self._verify_video_password(
798 redirect_url, video_id, video_password, token, vuid)
799 return self._real_extract(
800 smuggle_url(redirect_url, {'_video_password_verified': 'verified'}))
802 raise ExtractorError('Unable to extract info section
',
805 if config.get('view
') == 4:
806 config = self._verify_player_video_password(redirect_url, video_id, headers)
808 video = config.get('video
') or {}
809 vod = video.get('vod
') or {}
812 if '>You rented this title
.<' in webpage:
814 if config.get('user
', {}).get('purchased
'):
816 for purchase_option in vod.get('purchase_options
', []):
817 if purchase_option.get('purchased
'):
819 label = purchase_option.get('label_string
')
820 if label and (label.startswith('You rented this
') or label.endswith(' remaining
')):
824 if is_rented() and vod.get('is_trailer
'):
825 feature_id = vod.get('feature_id
')
826 if feature_id and not data.get('force_feature_id
', False):
827 return self.url_result(smuggle_url(
828 'https
://player
.vimeo
.com
/player
/%s' % feature_id,
829 {'force_feature_id': True}), 'Vimeo
')
831 # Extract video description
832 if not video_description:
833 video_description = self._html_search_regex(
834 r'(?s
)<div\s
+class="[^"]*description
[^
"]*"[^
>]*>(.*?
)</div
>',
835 webpage, 'description
', default=None)
836 if not video_description:
837 video_description = self._html_search_meta(
838 'description
', webpage, default=None)
839 if not video_description and is_pro:
840 orig_webpage = self._download_webpage(
842 note='Downloading webpage
for description
',
845 video_description = self._html_search_meta(
846 'description
', orig_webpage, default=None)
847 if not video_description and not is_player:
848 self.report_warning('Cannot find video description
')
850 # Extract upload date
852 timestamp = self._search_regex(
853 r'<time
[^
>]+datetime
="([^"]+)"', webpage,
854 'timestamp', default=None)
857 view_count = int(self._search_regex(r'UserPlays:(\d+)', webpage, 'view count'))
858 like_count = int(self._search_regex(r'UserLikes:(\d+)', webpage, 'like count'))
859 comment_count = int(self._search_regex(r'UserComments:(\d+)', webpage, 'comment count'))
860 except RegexNotFoundError:
861 # This info is only available in vimeo.com/{id} urls
868 source_format = self._extract_original_format(
869 'https://vimeo.com/' + video_id, video_id, video.get('unlisted_hash'))
871 formats.append(source_format)
873 info_dict_config = self._parse_config(config, video_id)
874 formats.extend(info_dict_config['formats'])
875 self._vimeo_sort_formats(formats)
877 json_ld = self._search_json_ld(webpage, video_id, default={})
880 cc_license = self._search_regex(
881 r'<link[^>]+rel=["\']license
["\'][^>]+href=(["\'])(?P
<license
>(?
:(?
!\
1).)+)\
1',
882 webpage, 'license
', default=None, group='license
')
884 channel_id = self._search_regex(
885 r'vimeo\
.com
/channels
/([^
/]+)', url, 'channel
id', default=None)
886 channel_url = 'https
://vimeo
.com
/channels
/%s' % channel_id if channel_id else None
890 'timestamp
': unified_timestamp(timestamp),
891 'description
': video_description,
893 'view_count
': view_count,
894 'like_count
': like_count,
895 'comment_count
': comment_count,
896 'license
': cc_license,
897 'channel_id
': channel_id,
898 'channel_url
': channel_url,
901 info_dict = merge_dicts(info_dict, info_dict_config, json_ld)
906 class VimeoOndemandIE(VimeoIE):
907 IE_NAME = 'vimeo
:ondemand
'
908 _VALID_URL = r'https?
://(?
:www\
.)?vimeo\
.com
/ondemand
/([^
/]+/)?
(?P
<id>[^
/?
#&]+)'
910 # ondemand video not available via https://vimeo.com/id
911 'url': 'https://vimeo.com/ondemand/20704',
912 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35',
916 'title': 'המעבדה - במאי יותם פלדמן',
917 'uploader': 'גם סרטים',
918 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/gumfilms',
919 'uploader_id': 'gumfilms',
920 'description': 'md5:4c027c965e439de4baab621e48b60791',
921 'upload_date': '20140906',
922 'timestamp': 1410032453,
925 'format': 'best[protocol=https]',
927 'expected_warnings': ['Unable to download JSON metadata'],
929 # requires Referer to be passed along with og:video:url
930 'url': 'https://vimeo.com/ondemand/36938/126682985',
934 'title': 'Rävlock, rätt läte på rätt plats',
935 'uploader': 'Lindroth & Norin',
936 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/lindrothnorin',
937 'uploader_id': 'lindrothnorin',
938 'description': 'md5:c3c46a90529612c8279fb6af803fc0df',
939 'upload_date': '20150502',
940 'timestamp': 1430586422,
943 'skip_download': True,
945 'expected_warnings': ['Unable to download JSON metadata'],
947 'url': 'https://vimeo.com/ondemand/nazmaalik',
948 'only_matching': True,
950 'url': 'https://vimeo.com/ondemand/141692381',
951 'only_matching': True,
953 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832',
954 'only_matching': True,
958 class VimeoChannelIE(VimeoBaseInfoExtractor
):
959 IE_NAME
= 'vimeo:channel'
960 _VALID_URL
= r
'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
961 _MORE_PAGES_INDICATOR
= r
'<a.+?rel="next"'
963 _TITLE_RE
= r
'<link rel="alternate"[^>]+?title="(.*?)"'
965 'url': 'https://vimeo.com/channels/tributes',
968 'title': 'Vimeo Tributes',
970 'playlist_mincount': 25,
972 _BASE_URL_TEMPL
= 'https://vimeo.com/channels/%s'
974 def _page_url(self
, base_url
, pagenum
):
975 return '%s/videos/page:%d/' % (base_url
, pagenum
)
977 def _extract_list_title(self
, webpage
):
978 return self
._TITLE
or self
._html
_search
_regex
(
979 self
._TITLE
_RE
, webpage
, 'list title', fatal
=False)
981 def _title_and_entries(self
, list_id
, base_url
):
982 for pagenum
in itertools
.count(1):
983 page_url
= self
._page
_url
(base_url
, pagenum
)
984 webpage
= self
._download
_webpage
(
986 'Downloading page %s' % pagenum
)
989 yield self
._extract
_list
_title
(webpage
)
991 # Try extracting href first since not all videos are available via
992 # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729)
994 r
'id="clip_(\d+)"[^>]*>\s*<a[^>]+href="(/(?:[^/]+/)*\1)(?:[^>]+\btitle="([^"]+)")?', webpage
)
996 for video_id
, video_url
, video_title
in clips
:
997 yield self
.url_result(
998 compat_urlparse
.urljoin(base_url
, video_url
),
999 VimeoIE
.ie_key(), video_id
=video_id
, video_title
=video_title
)
1000 # More relaxed fallback
1002 for video_id
in re
.findall(r
'id=["\']clip_(\d
+)', webpage):
1003 yield self.url_result(
1004 'https
://vimeo
.com
/%s' % video_id,
1005 VimeoIE.ie_key(), video_id=video_id)
1007 if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
1010 def _extract_videos(self, list_id, base_url):
1011 title_and_entries = self._title_and_entries(list_id, base_url)
1012 list_title = next(title_and_entries)
1013 return self.playlist_result(title_and_entries, list_id, list_title)
1015 def _real_extract(self, url):
1016 channel_id = self._match_id(url)
1017 return self._extract_videos(channel_id, self._BASE_URL_TEMPL % channel_id)
1020 class VimeoUserIE(VimeoChannelIE):
1021 IE_NAME = 'vimeo
:user
'
1022 _VALID_URL = r'https
://vimeo\
.com
/(?
!(?
:[0-9]+|watchlater
)(?
:$|
[?
#/]))(?P<id>[^/]+)(?:/videos|[#?]|$)'
1023 _TITLE_RE
= r
'<a[^>]+?class="user">([^<>]+?)</a>'
1025 'url': 'https://vimeo.com/nkistudio/videos',
1030 'playlist_mincount': 66,
1032 _BASE_URL_TEMPL
= 'https://vimeo.com/%s'
1035 class VimeoAlbumIE(VimeoBaseInfoExtractor
):
1036 IE_NAME
= 'vimeo:album'
1037 _VALID_URL
= r
'https://vimeo\.com/(?:album|showcase)/(?P<id>\d+)(?:$|[?#]|/(?!video))'
1038 _TITLE_RE
= r
'<header id="page_header">\n\s*<h1>(.*?)</h1>'
1040 'url': 'https://vimeo.com/album/2632481',
1043 'title': 'Staff Favorites: November 2013',
1045 'playlist_mincount': 13,
1047 'note': 'Password-protected album',
1048 'url': 'https://vimeo.com/album/3253534',
1053 'playlist_count': 1,
1055 'videopassword': 'youtube-dl',
1060 def _fetch_page(self
, album_id
, authorization
, hashed_pass
, page
):
1063 'fields': 'link,uri',
1065 'per_page': self
._PAGE
_SIZE
,
1068 query
['_hashed_pass'] = hashed_pass
1070 videos
= self
._download
_json
(
1071 'https://api.vimeo.com/albums/%s/videos' % album_id
,
1072 album_id
, 'Downloading page %d' % api_page
, query
=query
, headers
={
1073 'Authorization': 'jwt ' + authorization
,
1075 except ExtractorError
as e
:
1076 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
1078 for video
in videos
:
1079 link
= video
.get('link')
1082 uri
= video
.get('uri')
1083 video_id
= self
._search
_regex
(r
'/videos/(\d+)', uri
, 'video_id', default
=None) if uri
else None
1084 yield self
.url_result(link
, VimeoIE
.ie_key(), video_id
)
1086 def _real_extract(self
, url
):
1087 album_id
= self
._match
_id
(url
)
1088 viewer
= self
._download
_json
(
1089 'https://vimeo.com/_rv/viewer', album_id
, fatal
=False)
1091 webpage
= self
._download
_webpage
(url
, album_id
)
1092 viewer
= self
._parse
_json
(self
._search
_regex
(
1093 r
'bootstrap_data\s*=\s*({.+?})</script>',
1094 webpage
, 'bootstrap data'), album_id
)['viewer']
1096 album
= self
._download
_json
(
1097 'https://api.vimeo.com/albums/' + album_id
,
1098 album_id
, headers
={'Authorization': 'jwt ' + jwt}
,
1099 query
={'fields': 'description,name,privacy'}
)
1101 if try_get(album
, lambda x
: x
['privacy']['view']) == 'password':
1102 password
= self
.get_param('videopassword')
1104 raise ExtractorError(
1105 'This album is protected by a password, use the --video-password option',
1107 self
._set
_vimeo
_cookie
('vuid', viewer
['vuid'])
1109 hashed_pass
= self
._download
_json
(
1110 'https://vimeo.com/showcase/%s/auth' % album_id
,
1111 album_id
, 'Verifying the password', data
=urlencode_postdata({
1112 'password': password
,
1113 'token': viewer
['xsrft'],
1115 'X-Requested-With': 'XMLHttpRequest',
1117 except ExtractorError
as e
:
1118 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 401:
1119 raise ExtractorError('Wrong password', expected
=True)
1121 entries
= OnDemandPagedList(functools
.partial(
1122 self
._fetch
_page
, album_id
, jwt
, hashed_pass
), self
._PAGE
_SIZE
)
1123 return self
.playlist_result(
1124 entries
, album_id
, album
.get('name'), album
.get('description'))
1127 class VimeoGroupsIE(VimeoChannelIE
):
1128 IE_NAME
= 'vimeo:group'
1129 _VALID_URL
= r
'https://vimeo\.com/groups/(?P<id>[^/]+)(?:/(?!videos?/\d+)|$)'
1131 'url': 'https://vimeo.com/groups/kattykay',
1134 'title': 'Katty Kay',
1136 'playlist_mincount': 27,
1138 _BASE_URL_TEMPL
= 'https://vimeo.com/groups/%s'
1141 class VimeoReviewIE(VimeoBaseInfoExtractor
):
1142 IE_NAME
= 'vimeo:review'
1143 IE_DESC
= 'Review pages on vimeo'
1144 _VALID_URL
= r
'(?P<url>https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)/[0-9a-f]{10})'
1146 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
1147 'md5': 'c507a72f780cacc12b2248bb4006d253',
1151 'title': "DICK HARDWICK 'Comedian'",
1152 'uploader': 'Richard Hardwick',
1153 'uploader_id': 'user21297594',
1154 'description': "Comedian Dick Hardwick's five minute demo filmed in front of a live theater audience.\nEdit by Doug Mattocks",
1156 'expected_warnings': ['Unable to download JSON metadata'],
1158 'note': 'video player needs Referer',
1159 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
1160 'md5': '6295fdab8f4bf6a002d058b2c6dce276',
1164 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
1165 'uploader': 'DevWeek Events',
1167 'thumbnail': r
're:^https?://.*\.jpg$',
1168 'uploader_id': 'user22258446',
1170 'skip': 'video gone',
1172 'note': 'Password protected',
1173 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde',
1177 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1',
1179 'uploader_id': 'user37284429',
1182 'videopassword': 'holygrail',
1184 'skip': 'video gone',
1187 def _real_initialize(self
):
1190 def _real_extract(self
, url
):
1191 page_url
, video_id
= self
._match
_valid
_url
(url
).groups()
1192 data
= self
._download
_json
(
1193 page_url
.replace('/review/', '/review/data/'), video_id
)
1194 if data
.get('isLocked') is True:
1195 video_password
= self
._get
_video
_password
()
1196 viewer
= self
._download
_json
(
1197 'https://vimeo.com/_rv/viewer', video_id
)
1198 webpage
= self
._verify
_video
_password
(
1199 'https://vimeo.com/' + video_id
, video_id
,
1200 video_password
, viewer
['xsrft'], viewer
['vuid'])
1201 clip_page_config
= self
._parse
_json
(self
._search
_regex
(
1202 r
'window\.vimeo\.clip_page_config\s*=\s*({.+?});',
1203 webpage
, 'clip page config'), video_id
)
1204 config_url
= clip_page_config
['player']['config_url']
1205 clip_data
= clip_page_config
.get('clip') or {}
1207 clip_data
= data
['clipData']
1208 config_url
= clip_data
['configUrl']
1209 config
= self
._download
_json
(config_url
, video_id
)
1210 info_dict
= self
._parse
_config
(config
, video_id
)
1211 source_format
= self
._extract
_original
_format
(
1212 page_url
+ '/action', video_id
)
1214 info_dict
['formats'].append(source_format
)
1215 self
._vimeo
_sort
_formats
(info_dict
['formats'])
1216 info_dict
['description'] = clean_html(clip_data
.get('description'))
1220 class VimeoWatchLaterIE(VimeoChannelIE
):
1221 IE_NAME
= 'vimeo:watchlater'
1222 IE_DESC
= 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)'
1223 _VALID_URL
= r
'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater'
1224 _TITLE
= 'Watch Later'
1225 _LOGIN_REQUIRED
= True
1227 'url': 'https://vimeo.com/watchlater',
1228 'only_matching': True,
1231 def _real_initialize(self
):
1234 def _page_url(self
, base_url
, pagenum
):
1235 url
= '%s/page:%d/' % (base_url
, pagenum
)
1236 request
= sanitized_Request(url
)
1237 # Set the header to get a partial html page with the ids,
1238 # the normal page doesn't contain them.
1239 request
.add_header('X-Requested-With', 'XMLHttpRequest')
1242 def _real_extract(self
, url
):
1243 return self
._extract
_videos
('watchlater', 'https://vimeo.com/watchlater')
1246 class VimeoLikesIE(VimeoChannelIE
):
1247 _VALID_URL
= r
'https://(?:www\.)?vimeo\.com/(?P<id>[^/]+)/likes/?(?:$|[?#]|sort:)'
1248 IE_NAME
= 'vimeo:likes'
1249 IE_DESC
= 'Vimeo user likes'
1251 'url': 'https://vimeo.com/user755559/likes/',
1252 'playlist_mincount': 293,
1255 'title': 'urza’s Likes',
1258 'url': 'https://vimeo.com/stormlapse/likes',
1259 'only_matching': True,
1262 def _page_url(self
, base_url
, pagenum
):
1263 return '%s/page:%d/' % (base_url
, pagenum
)
1265 def _real_extract(self
, url
):
1266 user_id
= self
._match
_id
(url
)
1267 return self
._extract
_videos
(user_id
, 'https://vimeo.com/%s/likes' % user_id
)
1270 class VHXEmbedIE(VimeoBaseInfoExtractor
):
1271 IE_NAME
= 'vhx:embed'
1272 _VALID_URL
= r
'https?://embed\.vhx\.tv/videos/(?P<id>\d+)'
1275 def _extract_url(webpage
):
1277 r
'<iframe[^>]+src="(https?://embed\.vhx\.tv/videos/\d+[^"]*)"', webpage
)
1278 return unescapeHTML(mobj
.group(1)) if mobj
else None
1280 def _real_extract(self
, url
):
1281 video_id
= self
._match
_id
(url
)
1282 webpage
= self
._download
_webpage
(url
, video_id
)
1283 config_url
= self
._parse
_json
(self
._search
_regex
(
1284 r
'window\.OTTData\s*=\s*({.+})', webpage
,
1285 'ott data'), video_id
, js_to_json
)['config_url']
1286 config
= self
._download
_json
(config_url
, video_id
)
1287 info
= self
._parse
_config
(config
, video_id
)
1288 info
['id'] = video_id
1289 self
._vimeo
_sort
_formats
(info
['formats'])