2 from __future__
import unicode_literals
9 from .common
import InfoExtractor
10 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 # Note: Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps
122 # at the same time without actual units specified.
123 self._sort_formats(formats, ('quality
', 'res
', 'fps
', 'hdr
:12', 'source
'))
125 def _parse_config(self, config, video_id):
126 video_data = config['video
']
127 video_title = video_data['title
']
128 live_event = video_data.get('live_event
') or {}
129 is_live = live_event.get('status
') == 'started
'
130 request = config.get('request
') or {}
135 config_files = video_data.get('files
') or request.get('files
') or {}
136 for f in (config_files.get('progressive
') or []):
137 video_url = f.get('url
')
142 'format_id
': 'http
-%s' % f.get('quality
'),
143 'source_preference
': 10,
144 'width
': int_or_none(f.get('width
')),
145 'height
': int_or_none(f.get('height
')),
146 'fps
': int_or_none(f.get('fps
')),
147 'tbr
': int_or_none(f.get('bitrate
')),
150 # TODO: fix handling of 308 status code returned for live archive manifest requests
151 sep_pattern = r'/sep
/video
/'
152 for files_type in ('hls
', 'dash
'):
153 for cdn_name, cdn_data in (try_get(config_files, lambda x: x[files_type]['cdns
']) or {}).items():
154 manifest_url = cdn_data.get('url
')
157 format_id = '%s-%s' % (files_type, cdn_name)
158 sep_manifest_urls = []
159 if re.search(sep_pattern, manifest_url):
160 for suffix, repl in (('', 'video
'), ('_sep
', 'sep
/video
')):
161 sep_manifest_urls.append((format_id + suffix, re.sub(
162 sep_pattern, '/%s/' % repl, manifest_url)))
164 sep_manifest_urls = [(format_id, manifest_url)]
165 for f_id, m_url in sep_manifest_urls:
166 if files_type == 'hls
':
167 fmts, subs = self._extract_m3u8_formats_and_subtitles(
168 m_url, video_id, 'mp4
', live=is_live, m3u8_id=f_id,
169 note='Downloading
%s m3u8 information
' % cdn_name,
172 self._merge_subtitles(subs, target=subtitles)
173 elif files_type == 'dash
':
174 if 'json
=1' in m_url:
175 real_m_url = (self._download_json(m_url, video_id, fatal=False) or {}).get('url
')
178 fmts, subs = self._extract_mpd_formats_and_subtitles(
179 m_url.replace('/master
.json
', '/master
.mpd
'), video_id, f_id,
180 'Downloading
%s MPD information
' % cdn_name,
183 self._merge_subtitles(subs, target=subtitles)
185 live_archive = live_event.get('archive
') or {}
186 live_archive_source_url = live_archive.get('source_url
')
187 if live_archive_source_url and live_archive.get('status
') == 'done
':
189 'format_id
': 'live
-archive
-source
',
190 'url
': live_archive_source_url,
194 for tt in (request.get('text_tracks
') or []):
195 subtitles.setdefault(tt['lang
'], []).append({
197 'url
': urljoin('https
://vimeo
.com
', tt['url
']),
202 for key, thumb in (video_data.get('thumbs
') or {}).items():
205 'width
': int_or_none(key),
208 thumbnail = video_data.get('thumbnail
')
214 owner = video_data.get('owner
') or {}
215 video_uploader_url = owner.get('url
')
217 duration = int_or_none(video_data.get('duration
'))
218 chapter_data = try_get(config, lambda x: x['embed
']['chapters
']) or []
220 'title
': current_chapter.get('title
'),
221 'start_time
': current_chapter.get('timecode
'),
222 'end_time
': next_chapter.get('timecode
'),
223 } for current_chapter, next_chapter in zip(chapter_data, chapter_data[1:] + [{'timecode': duration}])]
224 if chapters and chapters[0]['start_time
']: # Chapters may not start from 0
225 chapters[:0] = [{'title': '<Untitled>', 'start_time': 0, 'end_time': chapters[0]['start_time']}]
228 'id': str_or_none(video_data.get('id')) or video_id,
229 'title
': video_title,
230 'uploader
': owner.get('name
'),
231 'uploader_id
': video_uploader_url.split('/')[-1] if video_uploader_url else None,
232 'uploader_url
': video_uploader_url,
233 'thumbnails
': thumbnails,
234 'duration
': duration,
235 'chapters
': chapters or None,
237 'subtitles
': subtitles,
241 def _extract_original_format(self, url, video_id, unlisted_hash=None):
242 query = {'action': 'load_download_config'}
244 query['unlisted_hash
'] = unlisted_hash
245 download_data = self._download_json(
246 url, video_id, fatal=False, query=query,
247 headers={'X-Requested-With': 'XMLHttpRequest'},
248 expected_status=(403, 404)) or {}
249 source_file = download_data.get('source_file
')
250 download_url = try_get(source_file, lambda x: x['download_url
'])
251 if download_url and not source_file.get('is_cold
') and not source_file.get('is_defrosting
'):
252 source_name = source_file.get('public_name
', 'Original
')
253 if self._is_valid_url(download_url, video_id, '%s video
' % source_name):
255 source_file, lambda x: x['extension
'],
256 compat_str) or determine_ext(
257 download_url, None) or 'mp4
').lower()
261 'width
': int_or_none(source_file.get('width
')),
262 'height
': int_or_none(source_file.get('height
')),
263 'filesize
': parse_filesize(source_file.get('size
')),
264 'format_id
': source_name,
268 jwt_response = self._download_json(
269 'https
://vimeo
.com
/_rv
/viewer
', video_id, note='Downloading jwt token
', fatal=False) or {}
270 if not jwt_response.get('jwt
'):
272 headers = {'Authorization': 'jwt %s' % jwt_response['jwt']}
273 original_response = self._download_json(
274 f'https
://api
.vimeo
.com
/videos
/{video_id}
', video_id,
275 headers=headers, fatal=False, expected_status=(403, 404)) or {}
276 for download_data in original_response.get('download
') or []:
277 download_url = download_data.get('link
')
278 if not download_url or download_data.get('quality
') != 'source
':
280 ext = determine_ext(parse_qs(download_url).get('filename
', [''])[0].lower(), default_ext=None)
282 urlh = self._request_webpage(
283 HEADRequest(download_url), video_id, fatal=False, note='Determining source extension
')
284 ext = urlh and urlhandle_detect_ext(urlh)
287 'ext
': ext or 'unknown_video
',
288 'format_id
': download_data.get('public_name
', 'Original
'),
289 'width
': int_or_none(download_data.get('width
')),
290 'height
': int_or_none(download_data.get('height
')),
291 'fps
': int_or_none(download_data.get('fps
')),
292 'filesize
': int_or_none(download_data.get('size
')),
297 class VimeoIE(VimeoBaseInfoExtractor):
298 """Information extractor for vimeo.com."""
300 # _VALID_URL matches Vimeo URLs
301 _VALID_URL = r'''(?x)
311 (?!(?:channels|album|showcase)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/)
316 moogaloop\.swf)\?clip_id=
320 (?:/(?P<unlisted_hash>[\da-f]{10}))?
321 /?(?:[?&].*)?(?:[#].*)?$
326 'url
': 'http
://vimeo
.com
/56015672#at=0',
327 'md5': '8879b6cc097e987f02484baf890129e5',
331 'title': "youtube-dl test video - \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550",
332 'description': 'md5:2d3305bad981a06ff79f027f19865021',
333 'timestamp': 1355990239,
334 'upload_date': '20121220',
335 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user7108434',
336 'uploader_id': 'user7108434',
337 'uploader': 'Filippo Valsorda',
342 'format': 'best[protocol=https]',
346 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
347 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
348 'note': 'Vimeo Pro video (#1197)',
352 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/openstreetmapus',
353 'uploader_id': 'openstreetmapus',
354 'uploader': 'OpenStreetMap US',
355 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
356 'description': 'md5:2c362968038d4499f4d79f88458590c1',
358 'upload_date': '20130610',
359 'timestamp': 1370893156,
363 'format': 'best[protocol=https]',
367 'url': 'http://player.vimeo.com/video/54469442',
368 'md5': '619b811a4417aa4abe78dc653becf511',
369 'note': 'Videos that embed the url in the player page',
373 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
374 'uploader': 'Business of Software',
375 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/businessofsoftware',
376 'uploader_id': 'businessofsoftware',
381 'format': 'best[protocol=https]',
385 'url': 'http://vimeo.com/68375962',
386 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
387 'note': 'Video protected with password',
391 'title': 'youtube-dl password protected test video',
392 'timestamp': 1371200155,
393 'upload_date': '20130614',
394 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user18948128',
395 'uploader_id': 'user18948128',
396 'uploader': 'Jaime Marquínez Ferrándiz',
398 'description': 'md5:dca3ea23adb29ee387127bc4ddfce63f',
401 'format': 'best[protocol=https]',
402 'videopassword': 'youtube-dl',
406 'url': 'http://vimeo.com/channels/keypeele/75629013',
407 'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
411 'title': 'Key & Peele: Terrorist Interrogation',
412 'description': 'md5:8678b246399b070816b12313e8b4eb5c',
413 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/atencio',
414 'uploader_id': 'atencio',
415 'uploader': 'Peter Atencio',
416 'channel_id': 'keypeele',
417 'channel_url': r
're:https?://(?:www\.)?vimeo\.com/channels/keypeele',
418 'timestamp': 1380339469,
419 'upload_date': '20130928',
422 'params': {'format': 'http-1080p'}
,
425 'url': 'http://vimeo.com/76979871',
426 'note': 'Video with subtitles',
430 'title': 'The New Vimeo Player (You Know, For Videos)',
431 'description': 'md5:2ec900bf97c3f389378a96aee11260ea',
432 'timestamp': 1381846109,
433 'upload_date': '20131015',
434 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/staff',
435 'uploader_id': 'staff',
436 'uploader': 'Vimeo Staff',
439 'de': [{'ext': 'vtt'}
],
440 'en': [{'ext': 'vtt'}
],
441 'es': [{'ext': 'vtt'}
],
442 'fr': [{'ext': 'vtt'}
],
445 'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'],
448 # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
449 'url': 'https://player.vimeo.com/video/98044508',
450 'note': 'The js code contains assignments to the same variable as the config',
454 'title': 'Pier Solar OUYA Official Trailer',
455 'uploader': 'Tulio Gonçalves',
456 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user28849593',
457 'uploader_id': 'user28849593',
461 # contains original format
462 'url': 'https://vimeo.com/33951933',
463 'md5': '53c688fa95a55bf4b7293d37a89c5c53',
467 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
468 'uploader': 'The DMCI',
469 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/dmci',
470 'uploader_id': 'dmci',
471 'timestamp': 1324343742,
472 'upload_date': '20111220',
473 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
477 'note': 'Contains original format not accessible in webpage',
478 'url': 'https://vimeo.com/393756517',
479 'md5': 'c464af248b592190a5ffbb5d33f382b0',
483 'timestamp': 1582642091,
484 'uploader_id': 'frameworkla',
485 'title': 'Straight To Hell - Sabrina: Netflix',
486 'uploader': 'Framework Studio',
487 'description': 'md5:f2edc61af3ea7a5592681ddbb683db73',
488 'upload_date': '20200225',
492 # only available via https://vimeo.com/channels/tributes/6213729 and
493 # not via https://vimeo.com/6213729
494 'url': 'https://vimeo.com/channels/tributes/6213729',
498 'title': 'Vimeo Tribute: The Shining',
499 'uploader': 'Casey Donahue',
500 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/caseydonahue',
501 'uploader_id': 'caseydonahue',
502 'channel_url': r
're:https?://(?:www\.)?vimeo\.com/channels/tributes',
503 'channel_id': 'tributes',
504 'timestamp': 1250886430,
505 'upload_date': '20090821',
506 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6',
509 'skip_download': True,
513 # redirects to ondemand extractor and should be passed through it
514 # for successful extraction
515 'url': 'https://vimeo.com/73445910',
519 'title': 'The Reluctant Revolutionary',
520 'uploader': '10Ft Films',
521 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/tenfootfilms',
522 'uploader_id': 'tenfootfilms',
523 'description': 'md5:0fa704e05b04f91f40b7f3ca2e801384',
524 'upload_date': '20130830',
525 'timestamp': 1377853339,
528 'skip_download': True,
530 'skip': 'this page is no longer available.',
533 'url': 'http://player.vimeo.com/video/68375962',
534 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
538 'title': 'youtube-dl password protected test video',
539 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user18948128',
540 'uploader_id': 'user18948128',
541 'uploader': 'Jaime Marquínez Ferrándiz',
545 'format': 'best[protocol=https]',
546 'videopassword': 'youtube-dl',
550 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741',
551 'only_matching': True,
554 'url': 'https://vimeo.com/109815029',
555 'note': 'Video not completely processed, "failed" seed status',
556 'only_matching': True,
559 'url': 'https://vimeo.com/groups/travelhd/videos/22439234',
560 'only_matching': True,
563 'url': 'https://vimeo.com/album/2632481/video/79010983',
564 'only_matching': True,
567 'url': 'https://vimeo.com/showcase/3253534/video/119195465',
568 'note': 'A video in a password protected album (showcase)',
572 'title': 'youtube-dl test video \'ä"BaW_jenozKc',
573 'uploader': 'Philipp Hagemeister',
574 'uploader_id': 'user20132939',
575 'description': 'md5:fa7b6c6d8db0bdc353893df2f111855b',
576 'upload_date': '20150209',
577 'timestamp': 1423518307,
580 'format': 'best[protocol=https]',
581 'videopassword': 'youtube-dl',
585 # source file returns 403: Forbidden
586 'url': 'https://vimeo.com/7809605',
587 'only_matching': True,
590 'note': 'Direct URL with hash',
591 'url': 'https://vimeo.com/160743502/abd0e13fb4',
595 'uploader': 'Julian Tryba',
596 'uploader_id': 'aliniamedia',
597 'title': 'Harrisville New Hampshire',
598 'timestamp': 1459259666,
599 'upload_date': '20160329',
601 'params': {'skip_download': True}
,
604 'url': 'https://vimeo.com/138909882',
608 'title': 'Eastnor Castle 2015 Firework Champions - The Promo!',
609 'description': 'md5:5967e090768a831488f6e74b7821b3c1',
610 'uploader_id': 'fireworkchampions',
611 'uploader': 'Firework Champions',
612 'upload_date': '20150910',
613 'timestamp': 1441901895,
616 'skip_download': True,
617 'format': 'Original',
621 'url': 'https://vimeo.com/channels/staffpicks/143603739',
625 'uploader': 'Karim Huu Do',
626 'timestamp': 1445846953,
627 'upload_date': '20151026',
628 'title': 'The Shoes - Submarine Feat. Blaine Harrison',
629 'uploader_id': 'karimhd',
630 'description': 'md5:8e2eea76de4504c2e8020a9bcfa1e843',
632 'params': {'skip_download': 'm3u8'}
,
635 # requires passing unlisted_hash(a52724358e) to load_download_config request
636 'url': 'https://vimeo.com/392479337/a52724358e',
637 'only_matching': True,
640 # similar, but all numeric: ID must be 581039021, not 9603038895
642 'url': 'https://vimeo.com/581039021/9603038895',
645 # these have to be provided but we don't care
647 'timestamp': 1627621014,
649 'uploader_id': 're:.+',
651 'upload_date': r
're:\d+',
654 'skip_download': True,
657 # https://gettingthingsdone.com/workflowmap/
658 # vimeo embed with check-password page protected by Referer header
662 def _smuggle_referrer(url
, referrer_url
):
663 return smuggle_url(url
, {'http_headers': {'Referer': referrer_url}
})
666 def _extract_urls(url
, webpage
):
668 # Look for embedded (iframe) Vimeo player
669 for mobj
in re
.finditer(
670 r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//player\
.vimeo\
.com
/video
/\d
+.*?
)\
1',
672 urls.append(VimeoIE._smuggle_referrer(unescapeHTML(mobj.group('url
')), url))
674 # Look for embedded (swf embed) Vimeo player
675 r'<embed
[^
>]+?src
=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1',
676 # Look more for non-standard embedded Vimeo player
677 r'<video[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:www\
.)?vimeo\
.com
/[0-9]+)\
1',
679 for embed_re in PLAIN_EMBED_RE:
680 for mobj in re.finditer(embed_re, webpage):
681 urls.append(mobj.group('url
'))
685 def _extract_url(url, webpage):
686 urls = VimeoIE._extract_urls(url, webpage)
687 return urls[0] if urls else None
689 def _verify_player_video_password(self, url, video_id, headers):
690 password = self._get_video_password()
691 data = urlencode_postdata({
692 'password
': base64.b64encode(password.encode()),
694 headers = merge_dicts(headers, {
695 'Content
-Type
': 'application
/x
-www
-form
-urlencoded
',
697 checked = self._download_json(
698 url + '/check
-password
', video_id,
699 'Verifying the password
', data=data, headers=headers)
701 raise ExtractorError('Wrong video password
', expected=True)
704 def _real_initialize(self):
707 def _extract_from_api(self, video_id, unlisted_hash=None):
708 token = self._download_json(
709 'https
://vimeo
.com
/_rv
/jwt
', video_id, headers={
710 'X
-Requested
-With
': 'XMLHttpRequest
'
712 api_url = 'https
://api
.vimeo
.com
/videos
/' + video_id
714 api_url += ':' + unlisted_hash
715 video = self._download_json(
716 api_url, video_id, headers={
717 'Authorization
': 'jwt
' + token,
719 'fields
': 'config_url
,created_time
,description
,license
,metadata
.connections
.comments
.total
,metadata
.connections
.likes
.total
,release_time
,stats
.plays
',
721 info = self._parse_config(self._download_json(
722 video['config_url
'], video_id), video_id)
723 self._vimeo_sort_formats(info['formats
'])
724 get_timestamp = lambda x: parse_iso8601(video.get(x + '_time
'))
726 'description
': video.get('description
'),
727 'license
': video.get('license
'),
728 'release_timestamp
': get_timestamp('release
'),
729 'timestamp
': get_timestamp('created
'),
730 'view_count
': int_or_none(try_get(video, lambda x: x['stats
']['plays
'])),
732 connections = try_get(
733 video, lambda x: x['metadata
']['connections
'], dict) or {}
734 for k in ('comment
', 'like
'):
735 info[k + '_count
'] = int_or_none(try_get(connections, lambda x: x[k + 's
']['total
']))
738 def _try_album_password(self, url):
739 album_id = self._search_regex(
740 r'vimeo\
.com
/(?
:album|showcase
)/([^
/]+)', url, 'album
id', default=None)
743 viewer = self._download_json(
744 'https
://vimeo
.com
/_rv
/viewer
', album_id, fatal=False)
746 webpage = self._download_webpage(url, album_id)
747 viewer = self._parse_json(self._search_regex(
748 r'bootstrap_data\s
*=\s
*({.+?}
)</script
>',
749 webpage, 'bootstrap data
'), album_id)['viewer
']
751 album = self._download_json(
752 'https
://api
.vimeo
.com
/albums
/' + album_id,
753 album_id, headers={'Authorization': 'jwt ' + jwt},
754 query={'fields': 'description,name,privacy'})
755 if try_get(album, lambda x: x['privacy
']['view
']) == 'password
':
756 password = self.get_param('videopassword
')
758 raise ExtractorError(
759 'This album
is protected by a password
, use the
--video
-password option
',
761 self._set_vimeo_cookie('vuid
', viewer['vuid
'])
764 'https
://vimeo
.com
/showcase
/%s/auth
' % album_id,
765 album_id, 'Verifying the password
', data=urlencode_postdata({
766 'password
': password,
767 'token
': viewer['xsrft
'],
769 'X
-Requested
-With
': 'XMLHttpRequest
',
771 except ExtractorError as e:
772 if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
773 raise ExtractorError('Wrong password
', expected=True)
776 def _real_extract(self, url):
777 url, data = unsmuggle_url(url, {})
778 headers = self.get_param('http_headers
').copy()
779 if 'http_headers
' in data:
780 headers.update(data['http_headers
'])
781 if 'Referer
' not in headers:
782 headers['Referer
'] = url
784 # Extract ID from URL
785 mobj = self._match_valid_url(url).groupdict()
786 video_id, unlisted_hash = mobj['id'], mobj.get('unlisted_hash
')
788 return self._extract_from_api(video_id, unlisted_hash)
791 is_pro = 'vimeopro
.com
/' in url
793 # some videos require portfolio_id to be present in player url
794 # https://github.com/ytdl-org/youtube-dl/issues/20070
795 url = self._extract_url(url, self._download_webpage(url, video_id))
797 url = 'https
://vimeo
.com
/' + video_id
798 elif any(p in url for p in ('play_redirect_hls
', 'moogaloop
.swf
')):
799 url = 'https
://vimeo
.com
/' + video_id
801 self._try_album_password(url)
803 # Retrieve video webpage to extract further information
804 webpage, urlh = self._download_webpage_handle(
805 url, video_id, headers=headers)
806 redirect_url = urlh.geturl()
807 except ExtractorError as ee:
808 if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
809 errmsg = ee.cause.read()
810 if b'Because of its privacy settings
, this video cannot be played here
' in errmsg:
811 raise ExtractorError(
812 'Cannot download embed
-only video without embedding
'
813 'URL
. Please call yt
-dlp
with the URL of the page
'
814 'that embeds this video
.',
818 if '://player
.vimeo
.com
/video
/' in url:
819 config = self._parse_json(self._search_regex(
820 r'\bconfig\s
*=\s
*({.+?}
)\s
*;', webpage, 'info section
'), video_id)
821 if config.get('view
') == 4:
822 config = self._verify_player_video_password(
823 redirect_url, video_id, headers)
824 info = self._parse_config(config, video_id)
825 self._vimeo_sort_formats(info['formats
'])
828 if re.search(r'<form
[^
>]+?
id="pw_form"', webpage):
829 video_password = self._get_video_password()
830 token, vuid = self._extract_xsrft_and_vuid(webpage)
831 webpage = self._verify_video_password(
832 redirect_url, video_id, video_password, token, vuid)
834 vimeo_config = self._extract_vimeo_config(webpage, video_id, default=None)
836 seed_status = vimeo_config.get('seed_status
') or {}
837 if seed_status.get('state
') == 'failed
':
838 raise ExtractorError(
839 '%s said
: %s' % (self.IE_NAME, seed_status['title
']),
844 video_description = None
848 channel_id = self._search_regex(
849 r'vimeo\
.com
/channels
/([^
/]+)', url, 'channel
id', default=None)
851 config_url = self._html_search_regex(
852 r'\bdata
-config
-url
="([^"]+)"', webpage, 'config URL', default=None)
853 video_description = clean_html(get_element_by_class('description', webpage))
855 'channel_id': channel_id,
856 'channel_url': 'https://vimeo.com/channels/' + channel_id,
859 page_config = self._parse_json(self._search_regex(
860 r'vimeo\.(?:clip|vod_title)_page_config\s*=\s*({.+?});',
861 webpage, 'page config', default='{}'), video_id, fatal=False)
863 return self._extract_from_api(video_id)
864 config_url = page_config['player']['config_url']
865 cc_license = page_config.get('cc_license')
866 clip = page_config.get('clip') or {}
867 timestamp = clip.get('uploaded_on')
868 video_description = clean_html(
869 clip.get('description') or page_config.get('description_html_escaped'))
870 config = self._download_json(config_url, video_id)
871 video = config.get('video') or {}
872 vod = video.get('vod') or {}
875 if '>You rented this title.<' in webpage:
877 if try_get(config, lambda x: x['user']['purchased']):
879 for purchase_option in (vod.get('purchase_options') or []):
880 if purchase_option.get('purchased'):
882 label = purchase_option.get('label_string')
883 if label and (label.startswith('You rented this') or label.endswith(' remaining')):
887 if is_rented() and vod.get('is_trailer'):
888 feature_id = vod.get('feature_id')
889 if feature_id and not data.get('force_feature_id', False):
890 return self.url_result(smuggle_url(
891 'https://player.vimeo.com/player/%s' % feature_id,
892 {'force_feature_id': True}), 'Vimeo')
894 if not video_description:
895 video_description = self._html_search_regex(
896 r'(?s)<div\s+class="[^
"]*description[^"]*"[^>]*>(.*?)</div>',
897 webpage, 'description', default=None)
898 if not video_description:
899 video_description = self._html_search_meta(
900 ['description', 'og:description', 'twitter:description'],
901 webpage, default=None)
902 if not video_description and is_pro:
903 orig_webpage = self._download_webpage(
905 note='Downloading webpage for description',
908 video_description = self._html_search_meta(
909 'description', orig_webpage, default=None)
910 if not video_description:
911 self.report_warning('Cannot find video description')
914 timestamp = self._search_regex(
915 r'<time[^>]+datetime="([^
"]+)"', webpage,
916 'timestamp
', default=None)
918 view_count = int_or_none(self._search_regex(r'UserPlays
:(\d
+)', webpage, 'view count
', default=None))
919 like_count = int_or_none(self._search_regex(r'UserLikes
:(\d
+)', webpage, 'like count
', default=None))
920 comment_count = int_or_none(self._search_regex(r'UserComments
:(\d
+)', webpage, 'comment count
', default=None))
924 source_format = self._extract_original_format(
925 'https
://vimeo
.com
/' + video_id, video_id, video.get('unlisted_hash
'))
927 formats.append(source_format)
929 info_dict_config = self._parse_config(config, video_id)
930 formats.extend(info_dict_config['formats
'])
931 self._vimeo_sort_formats(formats)
933 json_ld = self._search_json_ld(webpage, video_id, default={})
936 cc_license = self._search_regex(
937 r'<link
[^
>]+rel
=["\']license["\'][^
>]+href
=(["\'])(?P<license>(?:(?!\1).)+)\1',
938 webpage, 'license', default=None, group='license')
942 'timestamp': unified_timestamp(timestamp),
943 'description': video_description,
945 'view_count': view_count,
946 'like_count': like_count,
947 'comment_count': comment_count,
948 'license': cc_license,
951 return merge_dicts(info_dict, info_dict_config, json_ld)
954 class VimeoOndemandIE(VimeoIE):
955 IE_NAME = 'vimeo:ondemand'
956 _VALID_URL = r'https?://(?:www\.)?vimeo\.com/ondemand/(?:[^/]+/)?(?P<id>[^/?#&]+)'
958 # ondemand video not available via https://vimeo.com/id
959 'url': 'https://vimeo.com/ondemand/20704',
960 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35',
964 'title': 'המעבדה - במאי יותם פלדמן',
965 'uploader': 'גם סרטים',
966 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/gumfilms',
967 'uploader_id': 'gumfilms',
968 'description': 'md5:4c027c965e439de4baab621e48b60791',
969 'upload_date': '20140906',
970 'timestamp': 1410032453,
973 'format': 'best[protocol=https]',
975 'expected_warnings': ['Unable to download JSON metadata'],
977 # requires Referer to be passed along with og:video:url
978 'url': 'https://vimeo.com/ondemand/36938/126682985',
982 'title': 'Rävlock, rätt läte på rätt plats',
983 'uploader': 'Lindroth & Norin',
984 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/lindrothnorin',
985 'uploader_id': 'lindrothnorin',
986 'description': 'md5:c3c46a90529612c8279fb6af803fc0df',
987 'upload_date': '20150502',
988 'timestamp': 1430586422,
991 'skip_download': True,
993 'expected_warnings': ['Unable to download JSON metadata'],
995 'url': 'https://vimeo.com/ondemand/nazmaalik',
996 'only_matching': True,
998 'url': 'https://vimeo.com/ondemand/141692381',
999 'only_matching': True,
1001 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832',
1002 'only_matching': True,
1006 class VimeoChannelIE(VimeoBaseInfoExtractor):
1007 IE_NAME = 'vimeo:channel'
1008 _VALID_URL = r'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
1009 _MORE_PAGES_INDICATOR = r'<a.+?rel="next
"'
1011 _TITLE_RE = r'<link rel="alternate
"[^>]+?title="(.*?
)"'
1013 'url': 'https://vimeo.com/channels/tributes',
1016 'title': 'Vimeo Tributes',
1018 'playlist_mincount': 25,
1020 _BASE_URL_TEMPL = 'https://vimeo.com/channels/%s'
1022 def _page_url(self, base_url, pagenum):
1023 return '%s/videos/page:%d/' % (base_url, pagenum)
1025 def _extract_list_title(self, webpage):
1026 return self._TITLE or self._html_search_regex(
1027 self._TITLE_RE, webpage, 'list title', fatal=False)
1029 def _title_and_entries(self, list_id, base_url):
1030 for pagenum in itertools.count(1):
1031 page_url = self._page_url(base_url, pagenum)
1032 webpage = self._download_webpage(
1034 'Downloading page %s' % pagenum)
1037 yield self._extract_list_title(webpage)
1039 # Try extracting href first since not all videos are available via
1040 # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729)
1042 r'id="clip_(\d
+)"[^>]*>\s*<a[^>]+href="(/(?
:[^
/]+/)*\
1)(?
:[^
>]+\btitle
="([^"]+)")?', webpage)
1044 for video_id, video_url, video_title in clips:
1045 yield self.url_result(
1046 compat_urlparse.urljoin(base_url, video_url),
1047 VimeoIE.ie_key(), video_id=video_id, video_title=video_title)
1048 # More relaxed fallback
1050 for video_id in re.findall(r'id=["\']clip_(\d
+)', webpage):
1051 yield self.url_result(
1052 'https
://vimeo
.com
/%s' % video_id,
1053 VimeoIE.ie_key(), video_id=video_id)
1055 if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
1058 def _extract_videos(self, list_id, base_url):
1059 title_and_entries = self._title_and_entries(list_id, base_url)
1060 list_title = next(title_and_entries)
1061 return self.playlist_result(title_and_entries, list_id, list_title)
1063 def _real_extract(self, url):
1064 channel_id = self._match_id(url)
1065 return self._extract_videos(channel_id, self._BASE_URL_TEMPL % channel_id)
1068 class VimeoUserIE(VimeoChannelIE):
1069 IE_NAME = 'vimeo
:user
'
1070 _VALID_URL = r'https
://vimeo\
.com
/(?
!(?
:[0-9]+|watchlater
)(?
:$|
[?
#/]))(?P<id>[^/]+)(?:/videos|[#?]|$)'
1071 _TITLE_RE
= r
'<a[^>]+?class="user">([^<>]+?)</a>'
1073 'url': 'https://vimeo.com/nkistudio/videos',
1078 'playlist_mincount': 66,
1080 _BASE_URL_TEMPL
= 'https://vimeo.com/%s'
1083 class VimeoAlbumIE(VimeoBaseInfoExtractor
):
1084 IE_NAME
= 'vimeo:album'
1085 _VALID_URL
= r
'https://vimeo\.com/(?:album|showcase)/(?P<id>\d+)(?:$|[?#]|/(?!video))'
1086 _TITLE_RE
= r
'<header id="page_header">\n\s*<h1>(.*?)</h1>'
1088 'url': 'https://vimeo.com/album/2632481',
1091 'title': 'Staff Favorites: November 2013',
1093 'playlist_mincount': 13,
1095 'note': 'Password-protected album',
1096 'url': 'https://vimeo.com/album/3253534',
1101 'playlist_count': 1,
1103 'videopassword': 'youtube-dl',
1108 def _fetch_page(self
, album_id
, authorization
, hashed_pass
, page
):
1111 'fields': 'link,uri',
1113 'per_page': self
._PAGE
_SIZE
,
1116 query
['_hashed_pass'] = hashed_pass
1118 videos
= self
._download
_json
(
1119 'https://api.vimeo.com/albums/%s/videos' % album_id
,
1120 album_id
, 'Downloading page %d' % api_page
, query
=query
, headers
={
1121 'Authorization': 'jwt ' + authorization
,
1123 except ExtractorError
as e
:
1124 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 400:
1126 for video
in videos
:
1127 link
= video
.get('link')
1130 uri
= video
.get('uri')
1131 video_id
= self
._search
_regex
(r
'/videos/(\d+)', uri
, 'video_id', default
=None) if uri
else None
1132 yield self
.url_result(link
, VimeoIE
.ie_key(), video_id
)
1134 def _real_extract(self
, url
):
1135 album_id
= self
._match
_id
(url
)
1136 viewer
= self
._download
_json
(
1137 'https://vimeo.com/_rv/viewer', album_id
, fatal
=False)
1139 webpage
= self
._download
_webpage
(url
, album_id
)
1140 viewer
= self
._parse
_json
(self
._search
_regex
(
1141 r
'bootstrap_data\s*=\s*({.+?})</script>',
1142 webpage
, 'bootstrap data'), album_id
)['viewer']
1144 album
= self
._download
_json
(
1145 'https://api.vimeo.com/albums/' + album_id
,
1146 album_id
, headers
={'Authorization': 'jwt ' + jwt}
,
1147 query
={'fields': 'description,name,privacy'}
)
1149 if try_get(album
, lambda x
: x
['privacy']['view']) == 'password':
1150 password
= self
.get_param('videopassword')
1152 raise ExtractorError(
1153 'This album is protected by a password, use the --video-password option',
1155 self
._set
_vimeo
_cookie
('vuid', viewer
['vuid'])
1157 hashed_pass
= self
._download
_json
(
1158 'https://vimeo.com/showcase/%s/auth' % album_id
,
1159 album_id
, 'Verifying the password', data
=urlencode_postdata({
1160 'password': password
,
1161 'token': viewer
['xsrft'],
1163 'X-Requested-With': 'XMLHttpRequest',
1165 except ExtractorError
as e
:
1166 if isinstance(e
.cause
, compat_HTTPError
) and e
.cause
.code
== 401:
1167 raise ExtractorError('Wrong password', expected
=True)
1169 entries
= OnDemandPagedList(functools
.partial(
1170 self
._fetch
_page
, album_id
, jwt
, hashed_pass
), self
._PAGE
_SIZE
)
1171 return self
.playlist_result(
1172 entries
, album_id
, album
.get('name'), album
.get('description'))
1175 class VimeoGroupsIE(VimeoChannelIE
):
1176 IE_NAME
= 'vimeo:group'
1177 _VALID_URL
= r
'https://vimeo\.com/groups/(?P<id>[^/]+)(?:/(?!videos?/\d+)|$)'
1179 'url': 'https://vimeo.com/groups/meetup',
1182 'title': 'Vimeo Meetup!',
1184 'playlist_mincount': 27,
1186 _BASE_URL_TEMPL
= 'https://vimeo.com/groups/%s'
1189 class VimeoReviewIE(VimeoBaseInfoExtractor
):
1190 IE_NAME
= 'vimeo:review'
1191 IE_DESC
= 'Review pages on vimeo'
1192 _VALID_URL
= r
'(?P<url>https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)/[0-9a-f]{10})'
1194 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
1195 'md5': 'c507a72f780cacc12b2248bb4006d253',
1199 'title': "DICK HARDWICK 'Comedian'",
1200 'uploader': 'Richard Hardwick',
1201 'uploader_id': 'user21297594',
1202 'description': "Comedian Dick Hardwick's five minute demo filmed in front of a live theater audience.\nEdit by Doug Mattocks",
1205 'note': 'video player needs Referer',
1206 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
1207 'md5': '6295fdab8f4bf6a002d058b2c6dce276',
1211 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
1212 'uploader': 'DevWeek Events',
1214 'thumbnail': r
're:^https?://.*\.jpg$',
1215 'uploader_id': 'user22258446',
1217 'skip': 'video gone',
1219 'note': 'Password protected',
1220 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde',
1224 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1',
1226 'uploader_id': 'user37284429',
1229 'videopassword': 'holygrail',
1231 'skip': 'video gone',
1234 def _real_initialize(self
):
1237 def _real_extract(self
, url
):
1238 page_url
, video_id
= self
._match
_valid
_url
(url
).groups()
1239 data
= self
._download
_json
(
1240 page_url
.replace('/review/', '/review/data/'), video_id
)
1241 if data
.get('isLocked') is True:
1242 video_password
= self
._get
_video
_password
()
1243 viewer
= self
._download
_json
(
1244 'https://vimeo.com/_rv/viewer', video_id
)
1245 webpage
= self
._verify
_video
_password
(
1246 'https://vimeo.com/' + video_id
, video_id
,
1247 video_password
, viewer
['xsrft'], viewer
['vuid'])
1248 clip_page_config
= self
._parse
_json
(self
._search
_regex
(
1249 r
'window\.vimeo\.clip_page_config\s*=\s*({.+?});',
1250 webpage
, 'clip page config'), video_id
)
1251 config_url
= clip_page_config
['player']['config_url']
1252 clip_data
= clip_page_config
.get('clip') or {}
1254 clip_data
= data
['clipData']
1255 config_url
= clip_data
['configUrl']
1256 config
= self
._download
_json
(config_url
, video_id
)
1257 info_dict
= self
._parse
_config
(config
, video_id
)
1258 source_format
= self
._extract
_original
_format
(
1259 page_url
+ '/action', video_id
)
1261 info_dict
['formats'].append(source_format
)
1262 self
._vimeo
_sort
_formats
(info_dict
['formats'])
1263 info_dict
['description'] = clean_html(clip_data
.get('description'))
1267 class VimeoWatchLaterIE(VimeoChannelIE
):
1268 IE_NAME
= 'vimeo:watchlater'
1269 IE_DESC
= 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)'
1270 _VALID_URL
= r
'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater'
1271 _TITLE
= 'Watch Later'
1272 _LOGIN_REQUIRED
= True
1274 'url': 'https://vimeo.com/watchlater',
1275 'only_matching': True,
1278 def _real_initialize(self
):
1281 def _page_url(self
, base_url
, pagenum
):
1282 url
= '%s/page:%d/' % (base_url
, pagenum
)
1283 request
= sanitized_Request(url
)
1284 # Set the header to get a partial html page with the ids,
1285 # the normal page doesn't contain them.
1286 request
.add_header('X-Requested-With', 'XMLHttpRequest')
1289 def _real_extract(self
, url
):
1290 return self
._extract
_videos
('watchlater', 'https://vimeo.com/watchlater')
1293 class VimeoLikesIE(VimeoChannelIE
):
1294 _VALID_URL
= r
'https://(?:www\.)?vimeo\.com/(?P<id>[^/]+)/likes/?(?:$|[?#]|sort:)'
1295 IE_NAME
= 'vimeo:likes'
1296 IE_DESC
= 'Vimeo user likes'
1298 'url': 'https://vimeo.com/user755559/likes/',
1299 'playlist_mincount': 293,
1302 'title': 'urza’s Likes',
1305 'url': 'https://vimeo.com/stormlapse/likes',
1306 'only_matching': True,
1309 def _page_url(self
, base_url
, pagenum
):
1310 return '%s/page:%d/' % (base_url
, pagenum
)
1312 def _real_extract(self
, url
):
1313 user_id
= self
._match
_id
(url
)
1314 return self
._extract
_videos
(user_id
, 'https://vimeo.com/%s/likes' % user_id
)
1317 class VHXEmbedIE(VimeoBaseInfoExtractor
):
1318 IE_NAME
= 'vhx:embed'
1319 _VALID_URL
= r
'https?://embed\.vhx\.tv/videos/(?P<id>\d+)'
1322 def _extract_url(webpage
):
1324 r
'<iframe[^>]+src="(https?://embed\.vhx\.tv/videos/\d+[^"]*)"', webpage
)
1325 return unescapeHTML(mobj
.group(1)) if mobj
else None
1327 def _real_extract(self
, url
):
1328 video_id
= self
._match
_id
(url
)
1329 webpage
= self
._download
_webpage
(url
, video_id
)
1330 config_url
= self
._parse
_json
(self
._search
_regex
(
1331 r
'window\.OTTData\s*=\s*({.+})', webpage
,
1332 'ott data'), video_id
, js_to_json
)['config_url']
1333 config
= self
._download
_json
(config_url
, video_id
)
1334 info
= self
._parse
_config
(config
, video_id
)
1335 info
['id'] = video_id
1336 self
._vimeo
_sort
_formats
(info
['formats'])