2 from __future__
import unicode_literals
9 from .common
import InfoExtractor
10 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 # Note: Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps
123 # at the same time without actual units specified.
124 self._sort_formats(formats, ('quality
', 'res
', 'fps
', 'hdr
:12', 'source
'))
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
'
131 request = config.get('request
') or {}
136 config_files = video_data.get('files
') or request.get('files
') or {}
137 for f in (config_files.get('progressive
') or []):
138 video_url = f.get('url
')
143 'format_id
': 'http
-%s' % f.get('quality
'),
144 'source_preference
': 10,
145 'width
': int_or_none(f.get('width
')),
146 'height
': int_or_none(f.get('height
')),
147 'fps
': int_or_none(f.get('fps
')),
148 'tbr
': int_or_none(f.get('bitrate
')),
151 # TODO: fix handling of 308 status code returned for live archive manifest requests
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
')
158 format_id = '%s-%s' % (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, '/%s/' % repl, manifest_url)))
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
',
170 'm3u8
' if is_live else 'm3u8_native
', m3u8_id=f_id,
171 note='Downloading
%s m3u8 information
' % cdn_name,
174 self._merge_subtitles(subs, target=subtitles)
175 elif files_type == 'dash
':
176 if 'json
=1' in m_url:
177 real_m_url = (self._download_json(m_url, video_id, fatal=False) or {}).get('url
')
180 fmts, subs = self._extract_mpd_formats_and_subtitles(
181 m_url.replace('/master
.json
', '/master
.mpd
'), video_id, f_id,
182 'Downloading
%s MPD information
' % cdn_name,
185 self._merge_subtitles(subs, target=subtitles)
187 live_archive = live_event.get('archive
') or {}
188 live_archive_source_url = live_archive.get('source_url
')
189 if live_archive_source_url and live_archive.get('status
') == 'done
':
191 'format_id
': 'live
-archive
-source
',
192 'url
': live_archive_source_url,
196 for tt in (request.get('text_tracks
') or []):
197 subtitles.setdefault(tt['lang
'], []).append({
199 'url
': urljoin('https
://vimeo
.com
', tt['url
']),
204 for key, thumb in (video_data.get('thumbs
') or {}).items():
207 'width
': int_or_none(key),
210 thumbnail = video_data.get('thumbnail
')
216 owner = video_data.get('owner
') or {}
217 video_uploader_url = owner.get('url
')
219 duration = int_or_none(video_data.get('duration
'))
220 chapter_data = try_get(config, lambda x: x['embed
']['chapters
']) or []
222 'title
': current_chapter.get('title
'),
223 'start_time
': current_chapter.get('timecode
'),
224 'end_time
': next_chapter.get('timecode
'),
225 } for current_chapter, next_chapter in zip(chapter_data, chapter_data[1:] + [{'timecode': duration}])]
226 if chapters and chapters[0]['start_time
']: # Chapters may not start from 0
227 chapters[:0] = [{'title': '<Untitled>', 'start_time': 0, 'end_time': chapters[0]['start_time']}]
230 'id': str_or_none(video_data.get('id')) or video_id,
231 'title
': video_title,
232 'uploader
': owner.get('name
'),
233 'uploader_id
': video_uploader_url.split('/')[-1] if video_uploader_url else None,
234 'uploader_url
': video_uploader_url,
235 'thumbnails
': thumbnails,
236 'duration
': duration,
237 'chapters
': chapters or None,
239 'subtitles
': subtitles,
243 def _extract_original_format(self, url, video_id, unlisted_hash=None):
244 query = {'action': 'load_download_config'}
246 query['unlisted_hash
'] = unlisted_hash
247 download_data = self._download_json(
248 url, video_id, fatal=False, query=query,
249 headers={'X-Requested-With': 'XMLHttpRequest'},
250 expected_status=(403, 404)) or {}
251 source_file = download_data.get('source_file
')
252 download_url = try_get(source_file, lambda x: x['download_url
'])
253 if download_url and not source_file.get('is_cold
') and not source_file.get('is_defrosting
'):
254 source_name = source_file.get('public_name
', 'Original
')
255 if self._is_valid_url(download_url, video_id, '%s video
' % source_name):
257 source_file, lambda x: x['extension
'],
258 compat_str) or determine_ext(
259 download_url, None) or 'mp4
').lower()
263 'width
': int_or_none(source_file.get('width
')),
264 'height
': int_or_none(source_file.get('height
')),
265 'filesize
': parse_filesize(source_file.get('size
')),
266 'format_id
': source_name,
270 jwt_response = self._download_json(
271 'https
://vimeo
.com
/_rv
/viewer
', video_id, note='Downloading jwt token
', fatal=False) or {}
272 if not jwt_response.get('jwt
'):
274 headers = {'Authorization': 'jwt %s' % jwt_response['jwt']}
275 original_response = self._download_json(
276 f'https
://api
.vimeo
.com
/videos
/{video_id}
', video_id,
277 headers=headers, fatal=False, expected_status=(403, 404)) or {}
278 for download_data in original_response.get('download
') or []:
279 download_url = download_data.get('link
')
280 if not download_url or download_data.get('quality
') != 'source
':
282 ext = determine_ext(parse_qs(download_url).get('filename
', [''])[0].lower(), default_ext=None)
284 urlh = self._request_webpage(
285 HEADRequest(download_url), video_id, fatal=False, note='Determining source extension
')
286 ext = urlh and urlhandle_detect_ext(urlh)
289 'ext
': ext or 'unknown_video
',
290 'format_id
': download_data.get('public_name
', 'Original
'),
291 'width
': int_or_none(download_data.get('width
')),
292 'height
': int_or_none(download_data.get('height
')),
293 'fps
': int_or_none(download_data.get('fps
')),
294 'filesize
': int_or_none(download_data.get('size
')),
299 class VimeoIE(VimeoBaseInfoExtractor):
300 """Information extractor for vimeo.com."""
302 # _VALID_URL matches Vimeo URLs
303 _VALID_URL = r'''(?x)
313 (?!(?:channels|album|showcase)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/)
318 moogaloop\.swf)\?clip_id=
322 (?:/(?P<unlisted_hash>[\da-f]{10}))?
323 /?(?:[?&].*)?(?:[#].*)?$
328 'url
': 'http
://vimeo
.com
/56015672#at=0',
329 'md5': '8879b6cc097e987f02484baf890129e5',
333 'title': "youtube-dl test video - \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550",
334 'description': 'md5:2d3305bad981a06ff79f027f19865021',
335 'timestamp': 1355990239,
336 'upload_date': '20121220',
337 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user7108434',
338 'uploader_id': 'user7108434',
339 'uploader': 'Filippo Valsorda',
344 'format': 'best[protocol=https]',
348 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
349 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
350 'note': 'Vimeo Pro video (#1197)',
354 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/openstreetmapus',
355 'uploader_id': 'openstreetmapus',
356 'uploader': 'OpenStreetMap US',
357 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
358 'description': 'md5:2c362968038d4499f4d79f88458590c1',
360 'upload_date': '20130610',
361 'timestamp': 1370893156,
365 'format': 'best[protocol=https]',
369 'url': 'http://player.vimeo.com/video/54469442',
370 'md5': '619b811a4417aa4abe78dc653becf511',
371 'note': 'Videos that embed the url in the player page',
375 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
376 'uploader': 'Business of Software',
377 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/businessofsoftware',
378 'uploader_id': 'businessofsoftware',
383 'format': 'best[protocol=https]',
387 'url': 'http://vimeo.com/68375962',
388 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
389 'note': 'Video protected with password',
393 'title': 'youtube-dl password protected test video',
394 'timestamp': 1371200155,
395 'upload_date': '20130614',
396 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user18948128',
397 'uploader_id': 'user18948128',
398 'uploader': 'Jaime Marquínez Ferrándiz',
400 'description': 'md5:dca3ea23adb29ee387127bc4ddfce63f',
403 'format': 'best[protocol=https]',
404 'videopassword': 'youtube-dl',
408 'url': 'http://vimeo.com/channels/keypeele/75629013',
409 'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
413 'title': 'Key & Peele: Terrorist Interrogation',
414 'description': 'md5:8678b246399b070816b12313e8b4eb5c',
415 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/atencio',
416 'uploader_id': 'atencio',
417 'uploader': 'Peter Atencio',
418 'channel_id': 'keypeele',
419 'channel_url': r
're:https?://(?:www\.)?vimeo\.com/channels/keypeele',
420 'timestamp': 1380339469,
421 'upload_date': '20130928',
424 'params': {'format': 'http-1080p'}
,
427 'url': 'http://vimeo.com/76979871',
428 'note': 'Video with subtitles',
432 'title': 'The New Vimeo Player (You Know, For Videos)',
433 'description': 'md5:2ec900bf97c3f389378a96aee11260ea',
434 'timestamp': 1381846109,
435 'upload_date': '20131015',
436 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/staff',
437 'uploader_id': 'staff',
438 'uploader': 'Vimeo Staff',
441 'de': [{'ext': 'vtt'}
],
442 'en': [{'ext': 'vtt'}
],
443 'es': [{'ext': 'vtt'}
],
444 'fr': [{'ext': 'vtt'}
],
447 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'],
450 # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
451 'url': 'https://player.vimeo.com/video/98044508',
452 'note': 'The js code contains assignments to the same variable as the config',
456 'title': 'Pier Solar OUYA Official Trailer',
457 'uploader': 'Tulio Gonçalves',
458 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user28849593',
459 'uploader_id': 'user28849593',
463 # contains original format
464 'url': 'https://vimeo.com/33951933',
465 'md5': '53c688fa95a55bf4b7293d37a89c5c53',
469 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
470 'uploader': 'The DMCI',
471 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/dmci',
472 'uploader_id': 'dmci',
473 'timestamp': 1324343742,
474 'upload_date': '20111220',
475 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
479 'note': 'Contains original format not accessible in webpage',
480 'url': 'https://vimeo.com/393756517',
481 'md5': 'c464af248b592190a5ffbb5d33f382b0',
485 'timestamp': 1582642091,
486 'uploader_id': 'frameworkla',
487 'title': 'Straight To Hell - Sabrina: Netflix',
488 'uploader': 'Framework Studio',
489 'description': 'md5:f2edc61af3ea7a5592681ddbb683db73',
490 'upload_date': '20200225',
494 # only available via https://vimeo.com/channels/tributes/6213729 and
495 # not via https://vimeo.com/6213729
496 'url': 'https://vimeo.com/channels/tributes/6213729',
500 'title': 'Vimeo Tribute: The Shining',
501 'uploader': 'Casey Donahue',
502 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/caseydonahue',
503 'uploader_id': 'caseydonahue',
504 'channel_url': r
're:https?://(?:www\.)?vimeo\.com/channels/tributes',
505 'channel_id': 'tributes',
506 'timestamp': 1250886430,
507 'upload_date': '20090821',
508 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6',
511 'skip_download': True,
515 # redirects to ondemand extractor and should be passed through it
516 # for successful extraction
517 'url': 'https://vimeo.com/73445910',
521 'title': 'The Reluctant Revolutionary',
522 'uploader': '10Ft Films',
523 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/tenfootfilms',
524 'uploader_id': 'tenfootfilms',
525 'description': 'md5:0fa704e05b04f91f40b7f3ca2e801384',
526 'upload_date': '20130830',
527 'timestamp': 1377853339,
530 'skip_download': True,
532 'skip': 'this page is no longer available.',
535 'url': 'http://player.vimeo.com/video/68375962',
536 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
540 'title': 'youtube-dl password protected test video',
541 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user18948128',
542 'uploader_id': 'user18948128',
543 'uploader': 'Jaime Marquínez Ferrándiz',
547 'format': 'best[protocol=https]',
548 'videopassword': 'youtube-dl',
552 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741',
553 'only_matching': True,
556 'url': 'https://vimeo.com/109815029',
557 'note': 'Video not completely processed, "failed" seed status',
558 'only_matching': True,
561 'url': 'https://vimeo.com/groups/travelhd/videos/22439234',
562 'only_matching': True,
565 'url': 'https://vimeo.com/album/2632481/video/79010983',
566 'only_matching': True,
569 'url': 'https://vimeo.com/showcase/3253534/video/119195465',
570 'note': 'A video in a password protected album (showcase)',
574 'title': 'youtube-dl test video \'ä"BaW_jenozKc',
575 'uploader': 'Philipp Hagemeister',
576 'uploader_id': 'user20132939',
577 'description': 'md5:fa7b6c6d8db0bdc353893df2f111855b',
578 'upload_date': '20150209',
579 'timestamp': 1423518307,
582 'format': 'best[protocol=https]',
583 'videopassword': 'youtube-dl',
587 # source file returns 403: Forbidden
588 'url': 'https://vimeo.com/7809605',
589 'only_matching': True,
592 'note': 'Direct URL with hash',
593 'url': 'https://vimeo.com/160743502/abd0e13fb4',
597 'uploader': 'Julian Tryba',
598 'uploader_id': 'aliniamedia',
599 'title': 'Harrisville New Hampshire',
600 'timestamp': 1459259666,
601 'upload_date': '20160329',
603 'params': {'skip_download': True}
,
606 'url': 'https://vimeo.com/138909882',
610 'title': 'Eastnor Castle 2015 Firework Champions - The Promo!',
611 'description': 'md5:5967e090768a831488f6e74b7821b3c1',
612 'uploader_id': 'fireworkchampions',
613 'uploader': 'Firework Champions',
614 'upload_date': '20150910',
615 'timestamp': 1441901895,
618 'skip_download': True,
619 'format': 'Original',
623 'url': 'https://vimeo.com/channels/staffpicks/143603739',
627 'uploader': 'Karim Huu Do',
628 'timestamp': 1445846953,
629 'upload_date': '20151026',
630 'title': 'The Shoes - Submarine Feat. Blaine Harrison',
631 'uploader_id': 'karimhd',
632 'description': 'md5:8e2eea76de4504c2e8020a9bcfa1e843',
634 'params': {'skip_download': 'm3u8'}
,
637 # requires passing unlisted_hash(a52724358e) to load_download_config request
638 'url': 'https://vimeo.com/392479337/a52724358e',
639 'only_matching': True,
641 # https://gettingthingsdone.com/workflowmap/
642 # vimeo embed with check-password page protected by Referer header
646 def _smuggle_referrer(url
, referrer_url
):
647 return smuggle_url(url
, {'http_headers': {'Referer': referrer_url}
})
650 def _extract_urls(url
, webpage
):
652 # Look for embedded (iframe) Vimeo player
653 for mobj
in re
.finditer(
654 r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//player\
.vimeo\
.com
/video
/\d
+.*?
)\
1',
656 urls.append(VimeoIE._smuggle_referrer(unescapeHTML(mobj.group('url
')), url))
658 # Look for embedded (swf embed) Vimeo player
659 r'<embed
[^
>]+?src
=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1',
660 # Look more for non-standard embedded Vimeo player
661 r'<video[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:www\
.)?vimeo\
.com
/[0-9]+)\
1',
663 for embed_re in PLAIN_EMBED_RE:
664 for mobj in re.finditer(embed_re, webpage):
665 urls.append(mobj.group('url
'))
669 def _extract_url(url, webpage):
670 urls = VimeoIE._extract_urls(url, webpage)
671 return urls[0] if urls else None
673 def _verify_player_video_password(self, url, video_id, headers):
674 password = self._get_video_password()
675 data = urlencode_postdata({
676 'password
': base64.b64encode(password.encode()),
678 headers = merge_dicts(headers, {
679 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
681 checked = self._download_json(
682 url + '/check
-password
', video_id,
683 'Verifying the password
', data=data, headers=headers)
685 raise ExtractorError('Wrong video password
', expected=True)
688 def _real_initialize(self):
691 def _extract_from_api(self, video_id, unlisted_hash=None):
692 token = self._download_json(
693 'https
://vimeo
.com
/_rv
/jwt
', video_id, headers={
694 'X
-Requested
-With
': 'XMLHttpRequest
'
696 api_url = 'https
://api
.vimeo
.com
/videos
/' + video_id
698 api_url += ':' + unlisted_hash
699 video = self._download_json(
700 api_url, video_id, headers={
701 'Authorization
': 'jwt
' + token,
703 'fields
': 'config_url
,created_time
,description
,license
,metadata
.connections
.comments
.total
,metadata
.connections
.likes
.total
,release_time
,stats
.plays
',
705 info = self._parse_config(self._download_json(
706 video['config_url
'], video_id), video_id)
707 self._vimeo_sort_formats(info['formats
'])
708 get_timestamp = lambda x: parse_iso8601(video.get(x + '_time
'))
710 'description
': video.get('description
'),
711 'license
': video.get('license
'),
712 'release_timestamp
': get_timestamp('release
'),
713 'timestamp
': get_timestamp('created
'),
714 'view_count
': int_or_none(try_get(video, lambda x: x['stats
']['plays
'])),
716 connections = try_get(
717 video, lambda x: x['metadata
']['connections
'], dict) or {}
718 for k in ('comment
', 'like
'):
719 info[k + '_count
'] = int_or_none(try_get(connections, lambda x: x[k + 's
']['total
']))
722 def _try_album_password(self, url):
723 album_id = self._search_regex(
724 r'vimeo\
.com
/(?
:album|showcase
)/([^
/]+)', url, 'album
id', default=None)
727 viewer = self._download_json(
728 'https
://vimeo
.com
/_rv
/viewer
', album_id, fatal=False)
730 webpage = self._download_webpage(url, album_id)
731 viewer = self._parse_json(self._search_regex(
732 r'bootstrap_data\s
*=\s
*({.+?}
)</script
>',
733 webpage, 'bootstrap data
'), album_id)['viewer
']
735 album = self._download_json(
736 'https
://api
.vimeo
.com
/albums
/' + album_id,
737 album_id, headers={'Authorization': 'jwt ' + jwt},
738 query={'fields': 'description,name,privacy'})
739 if try_get(album, lambda x: x['privacy
']['view
']) == 'password
':
740 password = self.get_param('videopassword
')
742 raise ExtractorError(
743 'This album
is protected by a password
, use the
--video
-password option
',
745 self._set_vimeo_cookie('vuid
', viewer['vuid
'])
748 'https
://vimeo
.com
/showcase
/%s/auth
' % album_id,
749 album_id, 'Verifying the password
', data=urlencode_postdata({
750 'password
': password,
751 'token
': viewer['xsrft
'],
753 'X
-Requested
-With
': 'XMLHttpRequest
',
755 except ExtractorError as e:
756 if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
757 raise ExtractorError('Wrong password
', expected=True)
760 def _real_extract(self, url):
761 url, data = unsmuggle_url(url, {})
762 headers = std_headers.copy()
763 if 'http_headers
' in data:
764 headers.update(data['http_headers
'])
765 if 'Referer
' not in headers:
766 headers['Referer
'] = url
768 # Extract ID from URL
769 mobj = self._match_valid_url(url).groupdict()
770 video_id, unlisted_hash = mobj['id'], mobj.get('unlisted_hash
')
772 return self._extract_from_api(video_id, unlisted_hash)
775 is_pro = 'vimeopro
.com
/' in url
777 # some videos require portfolio_id to be present in player url
778 # https://github.com/ytdl-org/youtube-dl/issues/20070
779 url = self._extract_url(url, self._download_webpage(url, video_id))
781 url = 'https
://vimeo
.com
/' + video_id
782 elif any(p in url for p in ('play_redirect_hls
', 'moogaloop
.swf
')):
783 url = 'https
://vimeo
.com
/' + video_id
785 self._try_album_password(url)
787 # Retrieve video webpage to extract further information
788 webpage, urlh = self._download_webpage_handle(
789 url, video_id, headers=headers)
790 redirect_url = urlh.geturl()
791 except ExtractorError as ee:
792 if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
793 errmsg = ee.cause.read()
794 if b'Because of its privacy settings
, this video cannot be played here
' in errmsg:
795 raise ExtractorError(
796 'Cannot download embed
-only video without embedding
'
797 'URL
. Please call yt
-dlp
with the URL of the page
'
798 'that embeds this video
.',
802 if '://player
.vimeo
.com
/video
/' in url:
803 config = self._parse_json(self._search_regex(
804 r'\bconfig\s
*=\s
*({.+?}
)\s
*;', webpage, 'info section
'), video_id)
805 if config.get('view
') == 4:
806 config = self._verify_player_video_password(
807 redirect_url, video_id, headers)
808 info = self._parse_config(config, video_id)
809 self._vimeo_sort_formats(info['formats
'])
812 if re.search(r'<form
[^
>]+?
id="pw_form"', webpage):
813 video_password = self._get_video_password()
814 token, vuid = self._extract_xsrft_and_vuid(webpage)
815 webpage = self._verify_video_password(
816 redirect_url, video_id, video_password, token, vuid)
818 vimeo_config = self._extract_vimeo_config(webpage, video_id, default=None)
820 seed_status = vimeo_config.get('seed_status
') or {}
821 if seed_status.get('state
') == 'failed
':
822 raise ExtractorError(
823 '%s said
: %s' % (self.IE_NAME, seed_status['title
']),
828 video_description = None
832 channel_id = self._search_regex(
833 r'vimeo\
.com
/channels
/([^
/]+)', url, 'channel
id', default=None)
835 config_url = self._html_search_regex(
836 r'\bdata
-config
-url
="([^"]+)"', webpage, 'config URL', default=None)
837 video_description = clean_html(get_element_by_class('description', webpage))
839 'channel_id': channel_id,
840 'channel_url': 'https://vimeo.com/channels/' + channel_id,
843 page_config = self._parse_json(self._search_regex(
844 r'vimeo\.(?:clip|vod_title)_page_config\s*=\s*({.+?});',
845 webpage, 'page config', default='{}'), video_id, fatal=False)
847 return self._extract_from_api(video_id)
848 config_url = page_config['player']['config_url']
849 cc_license = page_config.get('cc_license')
850 clip = page_config.get('clip') or {}
851 timestamp = clip.get('uploaded_on')
852 video_description = clean_html(
853 clip.get('description') or page_config.get('description_html_escaped'))
854 config = self._download_json(config_url, video_id)
855 video = config.get('video') or {}
856 vod = video.get('vod') or {}
859 if '>You rented this title.<' in webpage:
861 if try_get(config, lambda x: x['user']['purchased']):
863 for purchase_option in (vod.get('purchase_options') or []):
864 if purchase_option.get('purchased'):
866 label = purchase_option.get('label_string')
867 if label and (label.startswith('You rented this') or label.endswith(' remaining')):
871 if is_rented() and vod.get('is_trailer'):
872 feature_id = vod.get('feature_id')
873 if feature_id and not data.get('force_feature_id', False):
874 return self.url_result(smuggle_url(
875 'https://player.vimeo.com/player/%s' % feature_id,
876 {'force_feature_id': True}), 'Vimeo')
878 if not video_description:
879 video_description = self._html_search_regex(
880 r'(?s)<div\s+class="[^
"]*description[^"]*"[^>]*>(.*?)</div>',
881 webpage, 'description', default=None)
882 if not video_description:
883 video_description = self._html_search_meta(
884 ['description', 'og:description', 'twitter:description'],
885 webpage, default=None)
886 if not video_description and is_pro:
887 orig_webpage = self._download_webpage(
889 note='Downloading webpage for description',
892 video_description = self._html_search_meta(
893 'description', orig_webpage, default=None)
894 if not video_description:
895 self.report_warning('Cannot find video description')
898 timestamp = self._search_regex(
899 r'<time[^>]+datetime="([^
"]+)"', webpage,
900 'timestamp
', default=None)
902 view_count = int_or_none(self._search_regex(r'UserPlays
:(\d
+)', webpage, 'view count
', default=None))
903 like_count = int_or_none(self._search_regex(r'UserLikes
:(\d
+)', webpage, 'like count
', default=None))
904 comment_count = int_or_none(self._search_regex(r'UserComments
:(\d
+)', webpage, 'comment count
', default=None))
908 source_format = self._extract_original_format(
909 'https
://vimeo
.com
/' + video_id, video_id, video.get('unlisted_hash
'))
911 formats.append(source_format)
913 info_dict_config = self._parse_config(config, video_id)
914 formats.extend(info_dict_config['formats
'])
915 self._vimeo_sort_formats(formats)
917 json_ld = self._search_json_ld(webpage, video_id, default={})
920 cc_license = self._search_regex(
921 r'<link
[^
>]+rel
=["\']license["\'][^
>]+href
=(["\'])(?P<license>(?:(?!\1).)+)\1',
922 webpage, 'license', default=None, group='license')
926 'timestamp': unified_timestamp(timestamp),
927 'description': video_description,
929 'view_count': view_count,
930 'like_count': like_count,
931 'comment_count': comment_count,
932 'license': cc_license,
935 return merge_dicts(info_dict, info_dict_config, json_ld)
938 class VimeoOndemandIE(VimeoIE):
939 IE_NAME = 'vimeo:ondemand'
940 _VALID_URL = r'https?://(?:www\.)?vimeo\.com/ondemand/(?:[^/]+/)?(?P<id>[^/?#&]+)'
942 # ondemand video not available via https://vimeo.com/id
943 'url': 'https://vimeo.com/ondemand/20704',
944 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35',
948 'title': 'המעבדה - במאי יותם פלדמן',
949 'uploader': 'גם סרטים',
950 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/gumfilms',
951 'uploader_id': 'gumfilms',
952 'description': 'md5:4c027c965e439de4baab621e48b60791',
953 'upload_date': '20140906',
954 'timestamp': 1410032453,
957 'format': 'best[protocol=https]',
959 'expected_warnings': ['Unable to download JSON metadata'],
961 # requires Referer to be passed along with og:video:url
962 'url': 'https://vimeo.com/ondemand/36938/126682985',
966 'title': 'Rävlock, rätt läte på rätt plats',
967 'uploader': 'Lindroth & Norin',
968 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/lindrothnorin',
969 'uploader_id': 'lindrothnorin',
970 'description': 'md5:c3c46a90529612c8279fb6af803fc0df',
971 'upload_date': '20150502',
972 'timestamp': 1430586422,
975 'skip_download': True,
977 'expected_warnings': ['Unable to download JSON metadata'],
979 'url': 'https://vimeo.com/ondemand/nazmaalik',
980 'only_matching': True,
982 'url': 'https://vimeo.com/ondemand/141692381',
983 'only_matching': True,
985 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832',
986 'only_matching': True,
990 class VimeoChannelIE(VimeoBaseInfoExtractor):
991 IE_NAME = 'vimeo:channel'
992 _VALID_URL = r'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
993 _MORE_PAGES_INDICATOR = r'<a.+?rel="next
"'
995 _TITLE_RE = r'<link rel="alternate
"[^>]+?title="(.*?
)"'
997 'url': 'https://vimeo.com/channels/tributes',
1000 'title': 'Vimeo Tributes',
1002 'playlist_mincount': 25,
1004 _BASE_URL_TEMPL = 'https://vimeo.com/channels/%s'
1006 def _page_url(self, base_url, pagenum):
1007 return '%s/videos/page:%d/' % (base_url, pagenum)
1009 def _extract_list_title(self, webpage):
1010 return self._TITLE or self._html_search_regex(
1011 self._TITLE_RE, webpage, 'list title', fatal=False)
1013 def _title_and_entries(self, list_id, base_url):
1014 for pagenum in itertools.count(1):
1015 page_url = self._page_url(base_url, pagenum)
1016 webpage = self._download_webpage(
1018 'Downloading page %s' % pagenum)
1021 yield self._extract_list_title(webpage)
1023 # Try extracting href first since not all videos are available via
1024 # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729)
1026 r'id="clip_(\d
+)"[^>]*>\s*<a[^>]+href="(/(?
:[^
/]+/)*\
1)(?
:[^
>]+\btitle
="([^"]+)")?', webpage)
1028 for video_id, video_url, video_title in clips:
1029 yield self.url_result(
1030 compat_urlparse.urljoin(base_url, video_url),
1031 VimeoIE.ie_key(), video_id=video_id, video_title=video_title)
1032 # More relaxed fallback
1034 for video_id in re.findall(r'id=["\']clip_(\d
+)', webpage):
1035 yield self.url_result(
1036 'https
://vimeo
.com
/%s' % video_id,
1037 VimeoIE.ie_key(), video_id=video_id)
1039 if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
1042 def _extract_videos(self, list_id, base_url):
1043 title_and_entries = self._title_and_entries(list_id, base_url)
1044 list_title = next(title_and_entries)
1045 return self.playlist_result(title_and_entries, list_id, list_title)
1047 def _real_extract(self, url):
1048 channel_id = self._match_id(url)
1049 return self._extract_videos(channel_id, self._BASE_URL_TEMPL % channel_id)
1052 class VimeoUserIE(VimeoChannelIE):
1053 IE_NAME = 'vimeo
:user
'
1054 _VALID_URL = r'https
://vimeo\
.com
/(?
!(?
:[0-9]+|watchlater
)(?
:$|
[?
#/]))(?P<id>[^/]+)(?:/videos|[#?]|$)'
1055 _TITLE_RE
= r
'<a[^>]+?class="user">([^<>]+?)</a>'
1057 'url': 'https://vimeo.com/nkistudio/videos',
1062 'playlist_mincount': 66,
1064 _BASE_URL_TEMPL
= 'https://vimeo.com/%s'
1067 class VimeoAlbumIE(VimeoBaseInfoExtractor
):
1068 IE_NAME
= 'vimeo:album'
1069 _VALID_URL
= r
'https://vimeo\.com/(?:album|showcase)/(?P<id>\d+)(?:$|[?#]|/(?!video))'
1070 _TITLE_RE
= r
'<header id="page_header">\n\s*<h1>(.*?)</h1>'
1072 'url': 'https://vimeo.com/album/2632481',
1075 'title': 'Staff Favorites: November 2013',
1077 'playlist_mincount': 13,
1079 'note': 'Password-protected album',
1080 'url': 'https://vimeo.com/album/3253534',
1085 'playlist_count': 1,
1087 'videopassword': 'youtube-dl',
1092 def _fetch_page(self
, album_id
, authorization
, hashed_pass
, page
):
1095 'fields': 'link,uri',
1097 'per_page': self
._PAGE
_SIZE
,
1100 query
['_hashed_pass'] = hashed_pass
1102 videos
= self
._download
_json
(
1103 'https://api.vimeo.com/albums/%s/videos' % album_id
,
1104 album_id
, 'Downloading page %d' % api_page
, query
=query
, headers
={
1105 'Authorization': 'jwt ' + authorization
,
1107 except ExtractorError
as e
:
1108 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
1110 for video
in videos
:
1111 link
= video
.get('link')
1114 uri
= video
.get('uri')
1115 video_id
= self
._search
_regex
(r
'/videos/(\d+)', uri
, 'video_id', default
=None) if uri
else None
1116 yield self
.url_result(link
, VimeoIE
.ie_key(), video_id
)
1118 def _real_extract(self
, url
):
1119 album_id
= self
._match
_id
(url
)
1120 viewer
= self
._download
_json
(
1121 'https://vimeo.com/_rv/viewer', album_id
, fatal
=False)
1123 webpage
= self
._download
_webpage
(url
, album_id
)
1124 viewer
= self
._parse
_json
(self
._search
_regex
(
1125 r
'bootstrap_data\s*=\s*({.+?})</script>',
1126 webpage
, 'bootstrap data'), album_id
)['viewer']
1128 album
= self
._download
_json
(
1129 'https://api.vimeo.com/albums/' + album_id
,
1130 album_id
, headers
={'Authorization': 'jwt ' + jwt}
,
1131 query
={'fields': 'description,name,privacy'}
)
1133 if try_get(album
, lambda x
: x
['privacy']['view']) == 'password':
1134 password
= self
.get_param('videopassword')
1136 raise ExtractorError(
1137 'This album is protected by a password, use the --video-password option',
1139 self
._set
_vimeo
_cookie
('vuid', viewer
['vuid'])
1141 hashed_pass
= self
._download
_json
(
1142 'https://vimeo.com/showcase/%s/auth' % album_id
,
1143 album_id
, 'Verifying the password', data
=urlencode_postdata({
1144 'password': password
,
1145 'token': viewer
['xsrft'],
1147 'X-Requested-With': 'XMLHttpRequest',
1149 except ExtractorError
as e
:
1150 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 401:
1151 raise ExtractorError('Wrong password', expected
=True)
1153 entries
= OnDemandPagedList(functools
.partial(
1154 self
._fetch
_page
, album_id
, jwt
, hashed_pass
), self
._PAGE
_SIZE
)
1155 return self
.playlist_result(
1156 entries
, album_id
, album
.get('name'), album
.get('description'))
1159 class VimeoGroupsIE(VimeoChannelIE
):
1160 IE_NAME
= 'vimeo:group'
1161 _VALID_URL
= r
'https://vimeo\.com/groups/(?P<id>[^/]+)(?:/(?!videos?/\d+)|$)'
1163 'url': 'https://vimeo.com/groups/meetup',
1166 'title': 'Vimeo Meetup!',
1168 'playlist_mincount': 27,
1170 _BASE_URL_TEMPL
= 'https://vimeo.com/groups/%s'
1173 class VimeoReviewIE(VimeoBaseInfoExtractor
):
1174 IE_NAME
= 'vimeo:review'
1175 IE_DESC
= 'Review pages on vimeo'
1176 _VALID_URL
= r
'(?P<url>https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)/[0-9a-f]{10})'
1178 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
1179 'md5': 'c507a72f780cacc12b2248bb4006d253',
1183 'title': "DICK HARDWICK 'Comedian'",
1184 'uploader': 'Richard Hardwick',
1185 'uploader_id': 'user21297594',
1186 'description': "Comedian Dick Hardwick's five minute demo filmed in front of a live theater audience.\nEdit by Doug Mattocks",
1189 'note': 'video player needs Referer',
1190 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
1191 'md5': '6295fdab8f4bf6a002d058b2c6dce276',
1195 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
1196 'uploader': 'DevWeek Events',
1198 'thumbnail': r
're:^https?://.*\.jpg$',
1199 'uploader_id': 'user22258446',
1201 'skip': 'video gone',
1203 'note': 'Password protected',
1204 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde',
1208 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1',
1210 'uploader_id': 'user37284429',
1213 'videopassword': 'holygrail',
1215 'skip': 'video gone',
1218 def _real_initialize(self
):
1221 def _real_extract(self
, url
):
1222 page_url
, video_id
= self
._match
_valid
_url
(url
).groups()
1223 data
= self
._download
_json
(
1224 page_url
.replace('/review/', '/review/data/'), video_id
)
1225 if data
.get('isLocked') is True:
1226 video_password
= self
._get
_video
_password
()
1227 viewer
= self
._download
_json
(
1228 'https://vimeo.com/_rv/viewer', video_id
)
1229 webpage
= self
._verify
_video
_password
(
1230 'https://vimeo.com/' + video_id
, video_id
,
1231 video_password
, viewer
['xsrft'], viewer
['vuid'])
1232 clip_page_config
= self
._parse
_json
(self
._search
_regex
(
1233 r
'window\.vimeo\.clip_page_config\s*=\s*({.+?});',
1234 webpage
, 'clip page config'), video_id
)
1235 config_url
= clip_page_config
['player']['config_url']
1236 clip_data
= clip_page_config
.get('clip') or {}
1238 clip_data
= data
['clipData']
1239 config_url
= clip_data
['configUrl']
1240 config
= self
._download
_json
(config_url
, video_id
)
1241 info_dict
= self
._parse
_config
(config
, video_id
)
1242 source_format
= self
._extract
_original
_format
(
1243 page_url
+ '/action', video_id
)
1245 info_dict
['formats'].append(source_format
)
1246 self
._vimeo
_sort
_formats
(info_dict
['formats'])
1247 info_dict
['description'] = clean_html(clip_data
.get('description'))
1251 class VimeoWatchLaterIE(VimeoChannelIE
):
1252 IE_NAME
= 'vimeo:watchlater'
1253 IE_DESC
= 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)'
1254 _VALID_URL
= r
'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater'
1255 _TITLE
= 'Watch Later'
1256 _LOGIN_REQUIRED
= True
1258 'url': 'https://vimeo.com/watchlater',
1259 'only_matching': True,
1262 def _real_initialize(self
):
1265 def _page_url(self
, base_url
, pagenum
):
1266 url
= '%s/page:%d/' % (base_url
, pagenum
)
1267 request
= sanitized_Request(url
)
1268 # Set the header to get a partial html page with the ids,
1269 # the normal page doesn't contain them.
1270 request
.add_header('X-Requested-With', 'XMLHttpRequest')
1273 def _real_extract(self
, url
):
1274 return self
._extract
_videos
('watchlater', 'https://vimeo.com/watchlater')
1277 class VimeoLikesIE(VimeoChannelIE
):
1278 _VALID_URL
= r
'https://(?:www\.)?vimeo\.com/(?P<id>[^/]+)/likes/?(?:$|[?#]|sort:)'
1279 IE_NAME
= 'vimeo:likes'
1280 IE_DESC
= 'Vimeo user likes'
1282 'url': 'https://vimeo.com/user755559/likes/',
1283 'playlist_mincount': 293,
1286 'title': 'urza’s Likes',
1289 'url': 'https://vimeo.com/stormlapse/likes',
1290 'only_matching': True,
1293 def _page_url(self
, base_url
, pagenum
):
1294 return '%s/page:%d/' % (base_url
, pagenum
)
1296 def _real_extract(self
, url
):
1297 user_id
= self
._match
_id
(url
)
1298 return self
._extract
_videos
(user_id
, 'https://vimeo.com/%s/likes' % user_id
)
1301 class VHXEmbedIE(VimeoBaseInfoExtractor
):
1302 IE_NAME
= 'vhx:embed'
1303 _VALID_URL
= r
'https?://embed\.vhx\.tv/videos/(?P<id>\d+)'
1306 def _extract_url(webpage
):
1308 r
'<iframe[^>]+src="(https?://embed\.vhx\.tv/videos/\d+[^"]*)"', webpage
)
1309 return unescapeHTML(mobj
.group(1)) if mobj
else None
1311 def _real_extract(self
, url
):
1312 video_id
= self
._match
_id
(url
)
1313 webpage
= self
._download
_webpage
(url
, video_id
)
1314 config_url
= self
._parse
_json
(self
._search
_regex
(
1315 r
'window\.OTTData\s*=\s*({.+})', webpage
,
1316 'ott data'), video_id
, js_to_json
)['config_url']
1317 config
= self
._download
_json
(config_url
, video_id
)
1318 info
= self
._parse
_config
(config
, video_id
)
1319 info
['id'] = video_id
1320 self
._vimeo
_sort
_formats
(info
['formats'])