2 from __future__ import unicode_literals
8 from .common import InfoExtractor
33 class VimeoBaseInfoExtractor(InfoExtractor):
34 _NETRC_MACHINE = 'vimeo'
35 _LOGIN_REQUIRED = False
36 _LOGIN_URL = 'https://vimeo.com/log_in'
39 (username, password) = self._get_login_info()
41 if self._LOGIN_REQUIRED:
42 raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
45 webpage = self._download_webpage(self._LOGIN_URL, None, False)
46 token, vuid = self._extract_xsrft_and_vuid(webpage)
47 data = urlencode_postdata({
54 login_request = sanitized_Request(self._LOGIN_URL, data)
55 login_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
56 login_request.add_header('Referer', self._LOGIN_URL)
57 self._set_vimeo_cookie('vuid', vuid)
58 self._download_webpage(login_request, None, False, 'Wrong login info')
60 def _verify_video_password(self, url, video_id, webpage):
61 password = self._downloader.params.get('videopassword')
63 raise ExtractorError('This video is protected by a password, use the --video-password option', expected=True)
64 token, vuid = self._extract_xsrft_and_vuid(webpage)
65 data = urlencode_postdata({
69 if url.startswith('http://'):
70 # vimeo only supports https now, but the user can give an http url
71 url = url.replace('http://', 'https://')
72 password_request = sanitized_Request(url + '/password', data)
73 password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
74 password_request.add_header('Referer', url)
75 self._set_vimeo_cookie('vuid', vuid)
76 return self._download_webpage(
77 password_request, video_id,
78 'Verifying the password', 'Wrong password')
80 def _extract_xsrft_and_vuid(self, webpage):
81 xsrft = self._search_regex(
82 r'(?:(?P<q1>["\'])xsrft(?P=q1)\s*:|xsrft\s*[=:])\s*(?P<q>["\'])(?P<xsrft>.+?)(?P=q)',
83 webpage, 'login token', group='xsrft')
84 vuid = self._search_regex(
85 r'["\']vuid["\']\s*:\s*(["\'])(?P<vuid>.+?)\1',
86 webpage, 'vuid', group='vuid')
89 def _set_vimeo_cookie(self, name, value):
90 self._set_cookie('vimeo.com', name, value)
92 def _vimeo_sort_formats(self, formats):
93 # Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps
94 # at the same time without actual units specified. This lead to wrong sorting.
95 self._sort_formats(formats, field_preference=('preference', 'height', 'width', 'fps', 'tbr', 'format_id'))
97 def _parse_config(self, config, video_id):
98 video_data = config['video']
100 video_title = video_data['title']
102 # Extract uploader, uploader_url and uploader_id
103 video_uploader = video_data.get('owner', {}).get('name')
104 video_uploader_url = video_data.get('owner', {}).get('url')
105 video_uploader_id = video_uploader_url.split('/')[-1] if video_uploader_url else None
107 # Extract video thumbnail
108 video_thumbnail = video_data.get('thumbnail')
109 if video_thumbnail is None:
110 video_thumbs = video_data.get('thumbs')
111 if video_thumbs and isinstance(video_thumbs, dict):
112 _, video_thumbnail = sorted((int(width if width.isdigit() else 0), t_url) for (width, t_url) in video_thumbs.items())[-1]
114 # Extract video duration
115 video_duration = int_or_none(video_data.get('duration'))
118 config_files = video_data.get('files') or config['request'].get('files', {})
119 for f in config_files.get('progressive', []):
120 video_url = f.get('url')
125 'format_id': 'http-%s' % f.get('quality'),
126 'width': int_or_none(f.get('width')),
127 'height': int_or_none(f.get('height')),
128 'fps': int_or_none(f.get('fps')),
129 'tbr': int_or_none(f.get('bitrate')),
132 for files_type in ('hls', 'dash'):
133 for cdn_name, cdn_data in config_files.get(files_type, {}).get('cdns', {}).items():
134 manifest_url = cdn_data.get('url')
137 format_id = '%s-%s' % (files_type, cdn_name)
138 if files_type == 'hls':
139 formats.extend(self._extract_m3u8_formats(
140 manifest_url, video_id, 'mp4',
141 'm3u8_native', m3u8_id=format_id,
142 note='Downloading %s m3u8 information' % cdn_name,
144 elif files_type == 'dash':
145 mpd_pattern = r'/%s/(?:sep/)?video/' % video_id
146 mpd_manifest_urls = []
147 if re.search(mpd_pattern, manifest_url):
148 for suffix, repl in (('', 'video'), ('_sep', 'sep/video')):
149 mpd_manifest_urls.append((format_id + suffix, re.sub(
150 mpd_pattern, '/%s/%s/' % (video_id, repl), manifest_url)))
152 mpd_manifest_urls = [(format_id, manifest_url)]
153 for f_id, m_url in mpd_manifest_urls:
154 formats.extend(self._extract_mpd_formats(
155 m_url.replace('/master.json', '/master.mpd'), video_id, f_id,
156 'Downloading %s MPD information' % cdn_name,
160 text_tracks = config['request'].get('text_tracks')
162 for tt in text_tracks:
163 subtitles[tt['lang']] = [{
165 'url': 'https://vimeo.com' + tt['url'],
169 'title': video_title,
170 'uploader': video_uploader,
171 'uploader_id': video_uploader_id,
172 'uploader_url': video_uploader_url,
173 'thumbnail': video_thumbnail,
174 'duration': video_duration,
176 'subtitles': subtitles,
180 class VimeoIE(VimeoBaseInfoExtractor):
181 """Information extractor for vimeo.com."""
183 # _VALID_URL matches Vimeo URLs
184 _VALID_URL = r'''(?x)
193 vimeo(?P<pro>pro)?\.com/
194 (?!(?:channels|album)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/)
199 moogaloop\.swf)\?clip_id=
204 /?(?:[?&].*)?(?:[#].*)?$
209 'url': 'http://vimeo.com/56015672#at=0',
210 'md5': '8879b6cc097e987f02484baf890129e5',
214 'title': "youtube-dl test video - \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550",
215 'description': 'md5:2d3305bad981a06ff79f027f19865021',
216 'upload_date': '20121220',
217 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user7108434',
218 'uploader_id': 'user7108434',
219 'uploader': 'Filippo Valsorda',
225 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
226 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
227 'note': 'Vimeo Pro video (#1197)',
231 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/openstreetmapus',
232 'uploader_id': 'openstreetmapus',
233 'uploader': 'OpenStreetMap US',
234 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
235 'description': 'md5:fd69a7b8d8c34a4e1d2ec2e4afd6ec30',
240 'url': 'http://player.vimeo.com/video/54469442',
241 'md5': '619b811a4417aa4abe78dc653becf511',
242 'note': 'Videos that embed the url in the player page',
246 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
247 'uploader': 'The BLN & Business of Software',
248 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/theblnbusinessofsoftware',
249 'uploader_id': 'theblnbusinessofsoftware',
255 'url': 'http://vimeo.com/68375962',
256 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
257 'note': 'Video protected with password',
261 'title': 'youtube-dl password protected test video',
262 'upload_date': '20130614',
263 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128',
264 'uploader_id': 'user18948128',
265 'uploader': 'Jaime Marquínez Ferrándiz',
267 'description': 'md5:dca3ea23adb29ee387127bc4ddfce63f',
270 'videopassword': 'youtube-dl',
274 'url': 'http://vimeo.com/channels/keypeele/75629013',
275 'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
279 'title': 'Key & Peele: Terrorist Interrogation',
280 'description': 'md5:8678b246399b070816b12313e8b4eb5c',
281 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/atencio',
282 'uploader_id': 'atencio',
283 'uploader': 'Peter Atencio',
284 'upload_date': '20130927',
289 'url': 'http://vimeo.com/76979871',
290 'note': 'Video with subtitles',
294 'title': 'The New Vimeo Player (You Know, For Videos)',
295 'description': 'md5:2ec900bf97c3f389378a96aee11260ea',
296 'upload_date': '20131015',
297 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/staff',
298 'uploader_id': 'staff',
299 'uploader': 'Vimeo Staff',
304 # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
305 'url': 'https://player.vimeo.com/video/98044508',
306 'note': 'The js code contains assignments to the same variable as the config',
310 'title': 'Pier Solar OUYA Official Trailer',
311 'uploader': 'Tulio Gonçalves',
312 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593',
313 'uploader_id': 'user28849593',
317 # contains original format
318 'url': 'https://vimeo.com/33951933',
319 'md5': '53c688fa95a55bf4b7293d37a89c5c53',
323 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
324 'uploader': 'The DMCI',
325 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/dmci',
326 'uploader_id': 'dmci',
327 'upload_date': '20111220',
328 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
332 # only available via https://vimeo.com/channels/tributes/6213729 and
333 # not via https://vimeo.com/6213729
334 'url': 'https://vimeo.com/channels/tributes/6213729',
338 'title': 'Vimeo Tribute: The Shining',
339 'uploader': 'Casey Donahue',
340 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/caseydonahue',
341 'uploader_id': 'caseydonahue',
342 'upload_date': '20090821',
343 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6',
346 'skip_download': True,
348 'expected_warnings': ['Unable to download JSON metadata'],
351 # redirects to ondemand extractor and should be passed through it
352 # for successful extraction
353 'url': 'https://vimeo.com/73445910',
357 'title': 'The Reluctant Revolutionary',
358 'uploader': '10Ft Films',
359 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/tenfootfilms',
360 'uploader_id': 'tenfootfilms',
363 'skip_download': True,
367 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741',
368 'only_matching': True,
371 'url': 'https://vimeo.com/109815029',
372 'note': 'Video not completely processed, "failed" seed status',
373 'only_matching': True,
376 'url': 'https://vimeo.com/groups/travelhd/videos/22439234',
377 'only_matching': True,
380 'url': 'https://vimeo.com/album/2632481/video/79010983',
381 'only_matching': True,
384 # source file returns 403: Forbidden
385 'url': 'https://vimeo.com/7809605',
386 'only_matching': True,
389 'url': 'https://vimeo.com/160743502/abd0e13fb4',
390 'only_matching': True,
395 def _smuggle_referrer(url, referrer_url):
396 return smuggle_url(url, {'http_headers': {'Referer': referrer_url}})
399 def _extract_urls(url, webpage):
401 # Look for embedded (iframe) Vimeo player
402 for mobj in re.finditer(
403 r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/.+?)\1',
405 urls.append(VimeoIE._smuggle_referrer(unescapeHTML(mobj.group('url')), url))
407 # Look for embedded (swf embed) Vimeo player
408 r'<embed[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1',
409 # Look more for non-standard embedded Vimeo player
410 r'<video[^>]+src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/[0-9]+)\1',
412 for embed_re in PLAIN_EMBED_RE:
413 for mobj in re.finditer(embed_re, webpage):
414 urls.append(mobj.group('url'))
418 def _extract_url(url, webpage):
419 urls = VimeoIE._extract_urls(url, webpage)
420 return urls[0] if urls else None
422 def _verify_player_video_password(self, url, video_id):
423 password = self._downloader.params.get('videopassword')
425 raise ExtractorError('This video is protected by a password, use the --video-password option')
426 data = urlencode_postdata({'password': password})
427 pass_url = url + '/check-password'
428 password_request = sanitized_Request(pass_url, data)
429 password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
430 password_request.add_header('Referer', url)
431 return self._download_json(
432 password_request, video_id,
433 'Verifying the password', 'Wrong password')
435 def _real_initialize(self):
438 def _real_extract(self, url):
439 url, data = unsmuggle_url(url, {})
440 headers = std_headers.copy()
441 if 'http_headers' in data:
442 headers.update(data['http_headers'])
443 if 'Referer' not in headers:
444 headers['Referer'] = url
446 # Extract ID from URL
447 mobj = re.match(self._VALID_URL, url)
448 video_id = mobj.group('id')
450 if mobj.group('pro') or mobj.group('player'):
451 url = 'https://player.vimeo.com/video/' + video_id
452 elif any(p in url for p in ('play_redirect_hls', 'moogaloop.swf')):
453 url = 'https://vimeo.com/' + video_id
455 # Retrieve video webpage to extract further information
456 request = sanitized_Request(url, headers=headers)
458 webpage, urlh = self._download_webpage_handle(request, video_id)
459 # Some URLs redirect to ondemand can't be extracted with
460 # this extractor right away thus should be passed through
461 # ondemand extractor (e.g. https://vimeo.com/73445910)
462 if VimeoOndemandIE.suitable(urlh.geturl()):
463 return self.url_result(urlh.geturl(), VimeoOndemandIE.ie_key())
464 except ExtractorError as ee:
465 if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
466 errmsg = ee.cause.read()
467 if b'Because of its privacy settings, this video cannot be played here' in errmsg:
468 raise ExtractorError(
469 'Cannot download embed-only video without embedding '
470 'URL. Please call youtube-dl with the URL of the page '
471 'that embeds this video.',
475 # Now we begin extracting as much information as we can from what we
476 # retrieved. First we extract the information common to all extractors,
477 # and latter we extract those that are Vimeo specific.
478 self.report_extraction(video_id)
480 vimeo_config = self._search_regex(
481 r'vimeo\.config\s*=\s*(?:({.+?})|_extend\([^,]+,\s+({.+?})\));', webpage,
482 'vimeo config', default=None)
484 seed_status = self._parse_json(vimeo_config, video_id).get('seed_status', {})
485 if seed_status.get('state') == 'failed':
486 raise ExtractorError(
487 '%s said: %s' % (self.IE_NAME, seed_status['title']),
492 # Extract the config JSON
495 config_url = self._html_search_regex(
496 r' data-config-url="(.+?)"', webpage,
497 'config URL', default=None)
499 # Sometimes new react-based page is served instead of old one that require
500 # different config URL extraction approach (see
501 # https://github.com/rg3/youtube-dl/pull/7209)
502 vimeo_clip_page_config = self._search_regex(
503 r'vimeo\.clip_page_config\s*=\s*({.+?});', webpage,
504 'vimeo clip page config')
505 page_config = self._parse_json(vimeo_clip_page_config, video_id)
506 config_url = page_config['player']['config_url']
507 cc_license = page_config.get('cc_license')
508 config_json = self._download_webpage(config_url, video_id)
509 config = json.loads(config_json)
510 except RegexNotFoundError:
511 # For pro videos or player.vimeo.com urls
512 # We try to find out to which variable is assigned the config dic
513 m_variable_name = re.search(r'(\w)\.video\.id', webpage)
514 if m_variable_name is not None:
515 config_re = r'%s=({[^}].+?});' % re.escape(m_variable_name.group(1))
517 config_re = [r' = {config:({.+?}),assets:', r'(?:[abc])=({.+?});']
518 config = self._search_regex(config_re, webpage, 'info section',
520 config = json.loads(config)
521 except Exception as e:
522 if re.search('The creator of this video has not given you permission to embed it on this domain.', webpage):
523 raise ExtractorError('The author has restricted the access to this video, try with the "--referer" option')
525 if re.search(r'<form[^>]+?id="pw_form"', webpage) is not None:
526 if '_video_password_verified' in data:
527 raise ExtractorError('video password verification failed!')
528 self._verify_video_password(url, video_id, webpage)
529 return self._real_extract(
530 smuggle_url(url, {'_video_password_verified': 'verified'}))
532 raise ExtractorError('Unable to extract info section',
535 if config.get('view') == 4:
536 config = self._verify_player_video_password(url, video_id)
539 if '>You rented this title.<' in webpage:
541 if config.get('user', {}).get('purchased'):
544 config, lambda x: x['video']['vod']['purchase_options'][0]['label_string'], compat_str)
545 if label and label.startswith('You rented this'):
550 feature_id = config.get('video', {}).get('vod', {}).get('feature_id')
551 if feature_id and not data.get('force_feature_id', False):
552 return self.url_result(smuggle_url(
553 'https://player.vimeo.com/player/%s' % feature_id,
554 {'force_feature_id': True}), 'Vimeo')
556 # Extract video description
558 video_description = self._html_search_regex(
559 r'(?s)<div\s+class="[^"]*description[^"]*"[^>]*>(.*?)</div>',
560 webpage, 'description', default=None)
561 if not video_description:
562 video_description = self._html_search_meta(
563 'description', webpage, default=None)
564 if not video_description and mobj.group('pro'):
565 orig_webpage = self._download_webpage(
567 note='Downloading webpage for description',
570 video_description = self._html_search_meta(
571 'description', orig_webpage, default=None)
572 if not video_description and not mobj.group('player'):
573 self._downloader.report_warning('Cannot find video description')
575 # Extract upload date
576 video_upload_date = None
577 mobj = re.search(r'<time[^>]+datetime="([^"]+)"', webpage)
579 video_upload_date = unified_strdate(mobj.group(1))
582 view_count = int(self._search_regex(r'UserPlays:(\d+)', webpage, 'view count'))
583 like_count = int(self._search_regex(r'UserLikes:(\d+)', webpage, 'like count'))
584 comment_count = int(self._search_regex(r'UserComments:(\d+)', webpage, 'comment count'))
585 except RegexNotFoundError:
586 # This info is only available in vimeo.com/{id} urls
592 download_request = sanitized_Request('https://vimeo.com/%s?action=load_download_config' % video_id, headers={
593 'X-Requested-With': 'XMLHttpRequest'})
594 download_data = self._download_json(download_request, video_id, fatal=False)
596 source_file = download_data.get('source_file')
597 if isinstance(source_file, dict):
598 download_url = source_file.get('download_url')
599 if download_url and not source_file.get('is_cold') and not source_file.get('is_defrosting'):
600 source_name = source_file.get('public_name', 'Original')
601 if self._is_valid_url(download_url, video_id, '%s video' % source_name):
602 ext = source_file.get('extension', determine_ext(download_url)).lower()
606 'width': int_or_none(source_file.get('width')),
607 'height': int_or_none(source_file.get('height')),
608 'filesize': parse_filesize(source_file.get('size')),
609 'format_id': source_name,
613 info_dict = self._parse_config(config, video_id)
614 formats.extend(info_dict['formats'])
615 self._vimeo_sort_formats(formats)
618 cc_license = self._search_regex(
619 r'<link[^>]+rel=["\']license["\'][^>]+href=(["\'])(?P<license>(?:(?!\1).)+)\1',
620 webpage, 'license', default=None, group='license')
625 'upload_date': video_upload_date,
626 'description': video_description,
628 'view_count': view_count,
629 'like_count': like_count,
630 'comment_count': comment_count,
631 'license': cc_license,
637 class VimeoOndemandIE(VimeoBaseInfoExtractor):
638 IE_NAME = 'vimeo:ondemand'
639 _VALID_URL = r'https?://(?:www\.)?vimeo\.com/ondemand/(?P<id>[^/?#&]+)'
641 # ondemand video not available via https://vimeo.com/id
642 'url': 'https://vimeo.com/ondemand/20704',
643 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35',
647 'title': 'המעבדה - במאי יותם פלדמן',
648 'uploader': 'גם סרטים',
649 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/gumfilms',
650 'uploader_id': 'gumfilms',
653 'format': 'best[protocol=https]',
656 # requires Referer to be passed along with og:video:url
657 'url': 'https://vimeo.com/ondemand/36938/126682985',
661 'title': 'Rävlock, rätt läte på rätt plats',
662 'uploader': 'Lindroth & Norin',
663 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user14430847',
664 'uploader_id': 'user14430847',
667 'skip_download': True,
670 'url': 'https://vimeo.com/ondemand/nazmaalik',
671 'only_matching': True,
673 'url': 'https://vimeo.com/ondemand/141692381',
674 'only_matching': True,
676 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832',
677 'only_matching': True,
680 def _real_extract(self, url):
681 video_id = self._match_id(url)
682 webpage = self._download_webpage(url, video_id)
683 return self.url_result(
684 # Some videos require Referer to be passed along with og:video:url
685 # similarly to generic vimeo embeds (e.g.
686 # https://vimeo.com/ondemand/36938/126682985).
687 VimeoIE._smuggle_referrer(self._og_search_video_url(webpage), url),
691 class VimeoChannelIE(VimeoBaseInfoExtractor):
692 IE_NAME = 'vimeo:channel'
693 _VALID_URL = r'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
694 _MORE_PAGES_INDICATOR = r'<a.+?rel="next"'
696 _TITLE_RE = r'<link rel="alternate"[^>]+?title="(.*?)"'
698 'url': 'https://vimeo.com/channels/tributes',
701 'title': 'Vimeo Tributes',
703 'playlist_mincount': 25,
706 def _page_url(self, base_url, pagenum):
707 return '%s/videos/page:%d/' % (base_url, pagenum)
709 def _extract_list_title(self, webpage):
710 return self._TITLE or self._html_search_regex(self._TITLE_RE, webpage, 'list title')
712 def _login_list_password(self, page_url, list_id, webpage):
713 login_form = self._search_regex(
714 r'(?s)<form[^>]+?id="pw_form"(.*?)</form>',
715 webpage, 'login form', default=None)
719 password = self._downloader.params.get('videopassword')
721 raise ExtractorError('This album is protected by a password, use the --video-password option', expected=True)
722 fields = self._hidden_inputs(login_form)
723 token, vuid = self._extract_xsrft_and_vuid(webpage)
724 fields['token'] = token
725 fields['password'] = password
726 post = urlencode_postdata(fields)
727 password_path = self._search_regex(
728 r'action="([^"]+)"', login_form, 'password URL')
729 password_url = compat_urlparse.urljoin(page_url, password_path)
730 password_request = sanitized_Request(password_url, post)
731 password_request.add_header('Content-type', 'application/x-www-form-urlencoded')
732 self._set_vimeo_cookie('vuid', vuid)
733 self._set_vimeo_cookie('xsrft', token)
735 return self._download_webpage(
736 password_request, list_id,
737 'Verifying the password', 'Wrong password')
739 def _title_and_entries(self, list_id, base_url):
740 for pagenum in itertools.count(1):
741 page_url = self._page_url(base_url, pagenum)
742 webpage = self._download_webpage(
744 'Downloading page %s' % pagenum)
747 webpage = self._login_list_password(page_url, list_id, webpage)
748 yield self._extract_list_title(webpage)
750 # Try extracting href first since not all videos are available via
751 # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729)
753 r'id="clip_(\d+)"[^>]*>\s*<a[^>]+href="(/(?:[^/]+/)*\1)(?:[^>]+\btitle="([^"]+)")?', webpage)
755 for video_id, video_url, video_title in clips:
756 yield self.url_result(
757 compat_urlparse.urljoin(base_url, video_url),
758 VimeoIE.ie_key(), video_id=video_id, video_title=video_title)
759 # More relaxed fallback
761 for video_id in re.findall(r'id=["\']clip_(\d+)', webpage):
762 yield self.url_result(
763 'https://vimeo.com/%s' % video_id,
764 VimeoIE.ie_key(), video_id=video_id)
766 if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
769 def _extract_videos(self, list_id, base_url):
770 title_and_entries = self._title_and_entries(list_id, base_url)
771 list_title = next(title_and_entries)
772 return self.playlist_result(title_and_entries, list_id, list_title)
774 def _real_extract(self, url):
775 mobj = re.match(self._VALID_URL, url)
776 channel_id = mobj.group('id')
777 return self._extract_videos(channel_id, 'https://vimeo.com/channels/%s' % channel_id)
780 class VimeoUserIE(VimeoChannelIE):
781 IE_NAME = 'vimeo:user'
782 _VALID_URL = r'https://vimeo\.com/(?!(?:[0-9]+|watchlater)(?:$|[?#/]))(?P<name>[^/]+)(?:/videos|[#?]|$)'
783 _TITLE_RE = r'<a[^>]+?class="user">([^<>]+?)</a>'
785 'url': 'https://vimeo.com/nkistudio/videos',
790 'playlist_mincount': 66,
793 def _real_extract(self, url):
794 mobj = re.match(self._VALID_URL, url)
795 name = mobj.group('name')
796 return self._extract_videos(name, 'https://vimeo.com/%s' % name)
799 class VimeoAlbumIE(VimeoChannelIE):
800 IE_NAME = 'vimeo:album'
801 _VALID_URL = r'https://vimeo\.com/album/(?P<id>\d+)(?:$|[?#]|/(?!video))'
802 _TITLE_RE = r'<header id="page_header">\n\s*<h1>(.*?)</h1>'
804 'url': 'https://vimeo.com/album/2632481',
807 'title': 'Staff Favorites: November 2013',
809 'playlist_mincount': 13,
811 'note': 'Password-protected album',
812 'url': 'https://vimeo.com/album/3253534',
819 'videopassword': 'youtube-dl',
822 'url': 'https://vimeo.com/album/2632481/sort:plays/format:thumbnail',
823 'only_matching': True,
825 # TODO: respect page number
826 'url': 'https://vimeo.com/album/2632481/page:2/sort:plays/format:thumbnail',
827 'only_matching': True,
830 def _page_url(self, base_url, pagenum):
831 return '%s/page:%d/' % (base_url, pagenum)
833 def _real_extract(self, url):
834 album_id = self._match_id(url)
835 return self._extract_videos(album_id, 'https://vimeo.com/album/%s' % album_id)
838 class VimeoGroupsIE(VimeoAlbumIE):
839 IE_NAME = 'vimeo:group'
840 _VALID_URL = r'https://vimeo\.com/groups/(?P<name>[^/]+)(?:/(?!videos?/\d+)|$)'
842 'url': 'https://vimeo.com/groups/rolexawards',
845 'title': 'Rolex Awards for Enterprise',
847 'playlist_mincount': 73,
850 def _extract_list_title(self, webpage):
851 return self._og_search_title(webpage)
853 def _real_extract(self, url):
854 mobj = re.match(self._VALID_URL, url)
855 name = mobj.group('name')
856 return self._extract_videos(name, 'https://vimeo.com/groups/%s' % name)
859 class VimeoReviewIE(VimeoBaseInfoExtractor):
860 IE_NAME = 'vimeo:review'
861 IE_DESC = 'Review pages on vimeo'
862 _VALID_URL = r'https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)'
864 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
865 'md5': 'c507a72f780cacc12b2248bb4006d253',
869 'title': "DICK HARDWICK 'Comedian'",
870 'uploader': 'Richard Hardwick',
871 'uploader_id': 'user21297594',
874 'note': 'video player needs Referer',
875 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
876 'md5': '6295fdab8f4bf6a002d058b2c6dce276',
880 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
881 'uploader': 'DevWeek Events',
883 'thumbnail': r're:^https?://.*\.jpg$',
884 'uploader_id': 'user22258446',
887 'note': 'Password protected',
888 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde',
892 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1',
894 'uploader_id': 'user37284429',
897 'videopassword': 'holygrail',
899 'skip': 'video gone',
902 def _real_initialize(self):
905 def _get_config_url(self, webpage_url, video_id, video_password_verified=False):
906 webpage = self._download_webpage(webpage_url, video_id)
907 config_url = self._html_search_regex(
908 r'data-config-url=(["\'])(?P<url>(?:(?!\1).)+)\1', webpage,
909 'config URL', default=None, group='url')
911 data = self._parse_json(self._search_regex(
912 r'window\s*=\s*_extend\(window,\s*({.+?})\);', webpage, 'data',
913 default=NO_DEFAULT if video_password_verified else '{}'), video_id)
914 config_url = data.get('vimeo_esi', {}).get('config', {}).get('configUrl')
915 if config_url is None:
916 self._verify_video_password(webpage_url, video_id, webpage)
917 config_url = self._get_config_url(
918 webpage_url, video_id, video_password_verified=True)
921 def _real_extract(self, url):
922 video_id = self._match_id(url)
923 config_url = self._get_config_url(url, video_id)
924 config = self._download_json(config_url, video_id)
925 info_dict = self._parse_config(config, video_id)
926 self._vimeo_sort_formats(info_dict['formats'])
927 info_dict['id'] = video_id
931 class VimeoWatchLaterIE(VimeoChannelIE):
932 IE_NAME = 'vimeo:watchlater'
933 IE_DESC = 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)'
934 _VALID_URL = r'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater'
935 _TITLE = 'Watch Later'
936 _LOGIN_REQUIRED = True
938 'url': 'https://vimeo.com/watchlater',
939 'only_matching': True,
942 def _real_initialize(self):
945 def _page_url(self, base_url, pagenum):
946 url = '%s/page:%d/' % (base_url, pagenum)
947 request = sanitized_Request(url)
948 # Set the header to get a partial html page with the ids,
949 # the normal page doesn't contain them.
950 request.add_header('X-Requested-With', 'XMLHttpRequest')
953 def _real_extract(self, url):
954 return self._extract_videos('watchlater', 'https://vimeo.com/watchlater')
957 class VimeoLikesIE(InfoExtractor):
958 _VALID_URL = r'https://(?:www\.)?vimeo\.com/user(?P<id>[0-9]+)/likes/?(?:$|[?#]|sort:)'
959 IE_NAME = 'vimeo:likes'
960 IE_DESC = 'Vimeo user likes'
962 'url': 'https://vimeo.com/user755559/likes/',
963 'playlist_mincount': 293,
965 'id': 'user755559_likes',
966 'description': 'See all the videos urza likes',
967 'title': 'Videos urza likes',
971 def _real_extract(self, url):
972 user_id = self._match_id(url)
973 webpage = self._download_webpage(url, user_id)
974 page_count = self._int(
976 r'''(?x)<li><a\s+href="[^"]+"\s+data-page="([0-9]+)">
977 .*?</a></li>\s*<li\s+class="pagination_next">
978 ''', webpage, 'page count'),
979 'page count', fatal=True)
981 title = self._html_search_regex(
982 r'(?s)<h1>(.+?)</h1>', webpage, 'title', fatal=False)
983 description = self._html_search_meta('description', webpage)
986 page_url = 'https://vimeo.com/user%s/likes/page:%d/sort:date' % (
988 webpage = self._download_webpage(
990 note='Downloading page %d/%d' % (idx + 1, page_count))
991 video_list = self._search_regex(
992 r'(?s)<ol class="js-browse_list[^"]+"[^>]*>(.*?)</ol>',
993 webpage, 'video content')
995 r'<li[^>]*>\s*<a\s+href="([^"]+)"', video_list)
999 'url': compat_urlparse.urljoin(page_url, path),
1002 pl = InAdvancePagedList(_get_page, page_count, PAGE_SIZE)
1005 '_type': 'playlist',
1006 'id': 'user%s_likes' % user_id,
1008 'description': description,