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',
224 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
225 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
226 'note': 'Vimeo Pro video (#1197)',
230 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/openstreetmapus',
231 'uploader_id': 'openstreetmapus',
232 'uploader': 'OpenStreetMap US',
233 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
234 'description': 'md5:fd69a7b8d8c34a4e1d2ec2e4afd6ec30',
239 'url': 'http://player.vimeo.com/video/54469442',
240 'md5': '619b811a4417aa4abe78dc653becf511',
241 'note': 'Videos that embed the url in the player page',
245 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
246 'uploader': 'The BLN & Business of Software',
247 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/theblnbusinessofsoftware',
248 'uploader_id': 'theblnbusinessofsoftware',
254 'url': 'http://vimeo.com/68375962',
255 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
256 'note': 'Video protected with password',
260 'title': 'youtube-dl password protected test video',
261 'upload_date': '20130614',
262 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128',
263 'uploader_id': 'user18948128',
264 'uploader': 'Jaime Marquínez Ferrándiz',
266 'description': 'md5:dca3ea23adb29ee387127bc4ddfce63f',
269 'videopassword': 'youtube-dl',
273 'url': 'http://vimeo.com/channels/keypeele/75629013',
274 'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
278 'title': 'Key & Peele: Terrorist Interrogation',
279 'description': 'md5:8678b246399b070816b12313e8b4eb5c',
280 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/atencio',
281 'uploader_id': 'atencio',
282 'uploader': 'Peter Atencio',
283 'upload_date': '20130927',
288 'url': 'http://vimeo.com/76979871',
289 'note': 'Video with subtitles',
293 'title': 'The New Vimeo Player (You Know, For Videos)',
294 'description': 'md5:2ec900bf97c3f389378a96aee11260ea',
295 'upload_date': '20131015',
296 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/staff',
297 'uploader_id': 'staff',
298 'uploader': 'Vimeo Staff',
303 # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
304 'url': 'https://player.vimeo.com/video/98044508',
305 'note': 'The js code contains assignments to the same variable as the config',
309 'title': 'Pier Solar OUYA Official Trailer',
310 'uploader': 'Tulio Gonçalves',
311 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593',
312 'uploader_id': 'user28849593',
316 # contains original format
317 'url': 'https://vimeo.com/33951933',
318 'md5': '53c688fa95a55bf4b7293d37a89c5c53',
322 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
323 'uploader': 'The DMCI',
324 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/dmci',
325 'uploader_id': 'dmci',
326 'upload_date': '20111220',
327 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
331 # only available via https://vimeo.com/channels/tributes/6213729 and
332 # not via https://vimeo.com/6213729
333 'url': 'https://vimeo.com/channels/tributes/6213729',
337 'title': 'Vimeo Tribute: The Shining',
338 'uploader': 'Casey Donahue',
339 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/caseydonahue',
340 'uploader_id': 'caseydonahue',
341 'upload_date': '20090821',
342 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6',
345 'skip_download': True,
347 'expected_warnings': ['Unable to download JSON metadata'],
350 # redirects to ondemand extractor and should be passed through it
351 # for successful extraction
352 'url': 'https://vimeo.com/73445910',
356 'title': 'The Reluctant Revolutionary',
357 'uploader': '10Ft Films',
358 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/tenfootfilms',
359 'uploader_id': 'tenfootfilms',
362 'skip_download': True,
366 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741',
367 'only_matching': True,
370 'url': 'https://vimeo.com/109815029',
371 'note': 'Video not completely processed, "failed" seed status',
372 'only_matching': True,
375 'url': 'https://vimeo.com/groups/travelhd/videos/22439234',
376 'only_matching': True,
379 'url': 'https://vimeo.com/album/2632481/video/79010983',
380 'only_matching': True,
383 # source file returns 403: Forbidden
384 'url': 'https://vimeo.com/7809605',
385 'only_matching': True,
388 'url': 'https://vimeo.com/160743502/abd0e13fb4',
389 'only_matching': True,
394 def _smuggle_referrer(url, referrer_url):
395 return smuggle_url(url, {'http_headers': {'Referer': referrer_url}})
398 def _extract_urls(url, webpage):
400 # Look for embedded (iframe) Vimeo player
401 for mobj in re.finditer(
402 r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/.+?)\1',
404 urls.append(VimeoIE._smuggle_referrer(unescapeHTML(mobj.group('url')), url))
406 # Look for embedded (swf embed) Vimeo player
407 r'<embed[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1',
408 # Look more for non-standard embedded Vimeo player
409 r'<video[^>]+src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/[0-9]+)\1',
411 for embed_re in PLAIN_EMBED_RE:
412 for mobj in re.finditer(embed_re, webpage):
413 urls.append(mobj.group('url'))
417 def _extract_url(url, webpage):
418 urls = VimeoIE._extract_urls(url, webpage)
419 return urls[0] if urls else None
421 def _verify_player_video_password(self, url, video_id):
422 password = self._downloader.params.get('videopassword')
424 raise ExtractorError('This video is protected by a password, use the --video-password option')
425 data = urlencode_postdata({'password': password})
426 pass_url = url + '/check-password'
427 password_request = sanitized_Request(pass_url, data)
428 password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
429 password_request.add_header('Referer', url)
430 return self._download_json(
431 password_request, video_id,
432 'Verifying the password', 'Wrong password')
434 def _real_initialize(self):
437 def _real_extract(self, url):
438 url, data = unsmuggle_url(url, {})
439 headers = std_headers.copy()
440 if 'http_headers' in data:
441 headers.update(data['http_headers'])
442 if 'Referer' not in headers:
443 headers['Referer'] = url
445 # Extract ID from URL
446 mobj = re.match(self._VALID_URL, url)
447 video_id = mobj.group('id')
449 if mobj.group('pro') or mobj.group('player'):
450 url = 'https://player.vimeo.com/video/' + video_id
451 elif any(p in url for p in ('play_redirect_hls', 'moogaloop.swf')):
452 url = 'https://vimeo.com/' + video_id
454 # Retrieve video webpage to extract further information
455 request = sanitized_Request(url, headers=headers)
457 webpage, urlh = self._download_webpage_handle(request, video_id)
458 # Some URLs redirect to ondemand can't be extracted with
459 # this extractor right away thus should be passed through
460 # ondemand extractor (e.g. https://vimeo.com/73445910)
461 if VimeoOndemandIE.suitable(urlh.geturl()):
462 return self.url_result(urlh.geturl(), VimeoOndemandIE.ie_key())
463 except ExtractorError as ee:
464 if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
465 errmsg = ee.cause.read()
466 if b'Because of its privacy settings, this video cannot be played here' in errmsg:
467 raise ExtractorError(
468 'Cannot download embed-only video without embedding '
469 'URL. Please call youtube-dl with the URL of the page '
470 'that embeds this video.',
474 # Now we begin extracting as much information as we can from what we
475 # retrieved. First we extract the information common to all extractors,
476 # and latter we extract those that are Vimeo specific.
477 self.report_extraction(video_id)
479 vimeo_config = self._search_regex(
480 r'vimeo\.config\s*=\s*(?:({.+?})|_extend\([^,]+,\s+({.+?})\));', webpage,
481 'vimeo config', default=None)
483 seed_status = self._parse_json(vimeo_config, video_id).get('seed_status', {})
484 if seed_status.get('state') == 'failed':
485 raise ExtractorError(
486 '%s said: %s' % (self.IE_NAME, seed_status['title']),
489 # Extract the config JSON
492 config_url = self._html_search_regex(
493 r' data-config-url="(.+?)"', webpage,
494 'config URL', default=None)
496 # Sometimes new react-based page is served instead of old one that require
497 # different config URL extraction approach (see
498 # https://github.com/rg3/youtube-dl/pull/7209)
499 vimeo_clip_page_config = self._search_regex(
500 r'vimeo\.clip_page_config\s*=\s*({.+?});', webpage,
501 'vimeo clip page config')
502 config_url = self._parse_json(
503 vimeo_clip_page_config, video_id)['player']['config_url']
504 config_json = self._download_webpage(config_url, video_id)
505 config = json.loads(config_json)
506 except RegexNotFoundError:
507 # For pro videos or player.vimeo.com urls
508 # We try to find out to which variable is assigned the config dic
509 m_variable_name = re.search(r'(\w)\.video\.id', webpage)
510 if m_variable_name is not None:
511 config_re = r'%s=({[^}].+?});' % re.escape(m_variable_name.group(1))
513 config_re = [r' = {config:({.+?}),assets:', r'(?:[abc])=({.+?});']
514 config = self._search_regex(config_re, webpage, 'info section',
516 config = json.loads(config)
517 except Exception as e:
518 if re.search('The creator of this video has not given you permission to embed it on this domain.', webpage):
519 raise ExtractorError('The author has restricted the access to this video, try with the "--referer" option')
521 if re.search(r'<form[^>]+?id="pw_form"', webpage) is not None:
522 if '_video_password_verified' in data:
523 raise ExtractorError('video password verification failed!')
524 self._verify_video_password(url, video_id, webpage)
525 return self._real_extract(
526 smuggle_url(url, {'_video_password_verified': 'verified'}))
528 raise ExtractorError('Unable to extract info section',
531 if config.get('view') == 4:
532 config = self._verify_player_video_password(url, video_id)
535 if '>You rented this title.<' in webpage:
537 if config.get('user', {}).get('purchased'):
540 config, lambda x: x['video']['vod']['purchase_options'][0]['label_string'], compat_str)
541 if label and label.startswith('You rented this'):
546 feature_id = config.get('video', {}).get('vod', {}).get('feature_id')
547 if feature_id and not data.get('force_feature_id', False):
548 return self.url_result(smuggle_url(
549 'https://player.vimeo.com/player/%s' % feature_id,
550 {'force_feature_id': True}), 'Vimeo')
552 # Extract video description
554 video_description = self._html_search_regex(
555 r'(?s)<div\s+class="[^"]*description[^"]*"[^>]*>(.*?)</div>',
556 webpage, 'description', default=None)
557 if not video_description:
558 video_description = self._html_search_meta(
559 'description', webpage, default=None)
560 if not video_description and mobj.group('pro'):
561 orig_webpage = self._download_webpage(
563 note='Downloading webpage for description',
566 video_description = self._html_search_meta(
567 'description', orig_webpage, default=None)
568 if not video_description and not mobj.group('player'):
569 self._downloader.report_warning('Cannot find video description')
571 # Extract upload date
572 video_upload_date = None
573 mobj = re.search(r'<time[^>]+datetime="([^"]+)"', webpage)
575 video_upload_date = unified_strdate(mobj.group(1))
578 view_count = int(self._search_regex(r'UserPlays:(\d+)', webpage, 'view count'))
579 like_count = int(self._search_regex(r'UserLikes:(\d+)', webpage, 'like count'))
580 comment_count = int(self._search_regex(r'UserComments:(\d+)', webpage, 'comment count'))
581 except RegexNotFoundError:
582 # This info is only available in vimeo.com/{id} urls
588 download_request = sanitized_Request('https://vimeo.com/%s?action=load_download_config' % video_id, headers={
589 'X-Requested-With': 'XMLHttpRequest'})
590 download_data = self._download_json(download_request, video_id, fatal=False)
592 source_file = download_data.get('source_file')
593 if isinstance(source_file, dict):
594 download_url = source_file.get('download_url')
595 if download_url and not source_file.get('is_cold') and not source_file.get('is_defrosting'):
596 source_name = source_file.get('public_name', 'Original')
597 if self._is_valid_url(download_url, video_id, '%s video' % source_name):
598 ext = source_file.get('extension', determine_ext(download_url)).lower()
602 'width': int_or_none(source_file.get('width')),
603 'height': int_or_none(source_file.get('height')),
604 'filesize': parse_filesize(source_file.get('size')),
605 'format_id': source_name,
609 info_dict = self._parse_config(config, video_id)
610 formats.extend(info_dict['formats'])
611 self._vimeo_sort_formats(formats)
615 'upload_date': video_upload_date,
616 'description': video_description,
618 'view_count': view_count,
619 'like_count': like_count,
620 'comment_count': comment_count,
626 class VimeoOndemandIE(VimeoBaseInfoExtractor):
627 IE_NAME = 'vimeo:ondemand'
628 _VALID_URL = r'https?://(?:www\.)?vimeo\.com/ondemand/(?P<id>[^/?#&]+)'
630 # ondemand video not available via https://vimeo.com/id
631 'url': 'https://vimeo.com/ondemand/20704',
632 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35',
636 'title': 'המעבדה - במאי יותם פלדמן',
637 'uploader': 'גם סרטים',
638 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/gumfilms',
639 'uploader_id': 'gumfilms',
642 'format': 'best[protocol=https]',
645 # requires Referer to be passed along with og:video:url
646 'url': 'https://vimeo.com/ondemand/36938/126682985',
650 'title': 'Rävlock, rätt läte på rätt plats',
651 'uploader': 'Lindroth & Norin',
652 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user14430847',
653 'uploader_id': 'user14430847',
656 'skip_download': True,
659 'url': 'https://vimeo.com/ondemand/nazmaalik',
660 'only_matching': True,
662 'url': 'https://vimeo.com/ondemand/141692381',
663 'only_matching': True,
665 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832',
666 'only_matching': True,
669 def _real_extract(self, url):
670 video_id = self._match_id(url)
671 webpage = self._download_webpage(url, video_id)
672 return self.url_result(
673 # Some videos require Referer to be passed along with og:video:url
674 # similarly to generic vimeo embeds (e.g.
675 # https://vimeo.com/ondemand/36938/126682985).
676 VimeoIE._smuggle_referrer(self._og_search_video_url(webpage), url),
680 class VimeoChannelIE(VimeoBaseInfoExtractor):
681 IE_NAME = 'vimeo:channel'
682 _VALID_URL = r'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
683 _MORE_PAGES_INDICATOR = r'<a.+?rel="next"'
685 _TITLE_RE = r'<link rel="alternate"[^>]+?title="(.*?)"'
687 'url': 'https://vimeo.com/channels/tributes',
690 'title': 'Vimeo Tributes',
692 'playlist_mincount': 25,
695 def _page_url(self, base_url, pagenum):
696 return '%s/videos/page:%d/' % (base_url, pagenum)
698 def _extract_list_title(self, webpage):
699 return self._TITLE or self._html_search_regex(self._TITLE_RE, webpage, 'list title')
701 def _login_list_password(self, page_url, list_id, webpage):
702 login_form = self._search_regex(
703 r'(?s)<form[^>]+?id="pw_form"(.*?)</form>',
704 webpage, 'login form', default=None)
708 password = self._downloader.params.get('videopassword')
710 raise ExtractorError('This album is protected by a password, use the --video-password option', expected=True)
711 fields = self._hidden_inputs(login_form)
712 token, vuid = self._extract_xsrft_and_vuid(webpage)
713 fields['token'] = token
714 fields['password'] = password
715 post = urlencode_postdata(fields)
716 password_path = self._search_regex(
717 r'action="([^"]+)"', login_form, 'password URL')
718 password_url = compat_urlparse.urljoin(page_url, password_path)
719 password_request = sanitized_Request(password_url, post)
720 password_request.add_header('Content-type', 'application/x-www-form-urlencoded')
721 self._set_vimeo_cookie('vuid', vuid)
722 self._set_vimeo_cookie('xsrft', token)
724 return self._download_webpage(
725 password_request, list_id,
726 'Verifying the password', 'Wrong password')
728 def _title_and_entries(self, list_id, base_url):
729 for pagenum in itertools.count(1):
730 page_url = self._page_url(base_url, pagenum)
731 webpage = self._download_webpage(
733 'Downloading page %s' % pagenum)
736 webpage = self._login_list_password(page_url, list_id, webpage)
737 yield self._extract_list_title(webpage)
739 # Try extracting href first since not all videos are available via
740 # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729)
742 r'id="clip_(\d+)"[^>]*>\s*<a[^>]+href="(/(?:[^/]+/)*\1)(?:[^>]+\btitle="([^"]+)")?', webpage)
744 for video_id, video_url, video_title in clips:
745 yield self.url_result(
746 compat_urlparse.urljoin(base_url, video_url),
747 VimeoIE.ie_key(), video_id=video_id, video_title=video_title)
748 # More relaxed fallback
750 for video_id in re.findall(r'id=["\']clip_(\d+)', webpage):
751 yield self.url_result(
752 'https://vimeo.com/%s' % video_id,
753 VimeoIE.ie_key(), video_id=video_id)
755 if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
758 def _extract_videos(self, list_id, base_url):
759 title_and_entries = self._title_and_entries(list_id, base_url)
760 list_title = next(title_and_entries)
761 return self.playlist_result(title_and_entries, list_id, list_title)
763 def _real_extract(self, url):
764 mobj = re.match(self._VALID_URL, url)
765 channel_id = mobj.group('id')
766 return self._extract_videos(channel_id, 'https://vimeo.com/channels/%s' % channel_id)
769 class VimeoUserIE(VimeoChannelIE):
770 IE_NAME = 'vimeo:user'
771 _VALID_URL = r'https://vimeo\.com/(?!(?:[0-9]+|watchlater)(?:$|[?#/]))(?P<name>[^/]+)(?:/videos|[#?]|$)'
772 _TITLE_RE = r'<a[^>]+?class="user">([^<>]+?)</a>'
774 'url': 'https://vimeo.com/nkistudio/videos',
779 'playlist_mincount': 66,
782 def _real_extract(self, url):
783 mobj = re.match(self._VALID_URL, url)
784 name = mobj.group('name')
785 return self._extract_videos(name, 'https://vimeo.com/%s' % name)
788 class VimeoAlbumIE(VimeoChannelIE):
789 IE_NAME = 'vimeo:album'
790 _VALID_URL = r'https://vimeo\.com/album/(?P<id>\d+)(?:$|[?#]|/(?!video))'
791 _TITLE_RE = r'<header id="page_header">\n\s*<h1>(.*?)</h1>'
793 'url': 'https://vimeo.com/album/2632481',
796 'title': 'Staff Favorites: November 2013',
798 'playlist_mincount': 13,
800 'note': 'Password-protected album',
801 'url': 'https://vimeo.com/album/3253534',
808 'videopassword': 'youtube-dl',
811 'url': 'https://vimeo.com/album/2632481/sort:plays/format:thumbnail',
812 'only_matching': True,
814 # TODO: respect page number
815 'url': 'https://vimeo.com/album/2632481/page:2/sort:plays/format:thumbnail',
816 'only_matching': True,
819 def _page_url(self, base_url, pagenum):
820 return '%s/page:%d/' % (base_url, pagenum)
822 def _real_extract(self, url):
823 album_id = self._match_id(url)
824 return self._extract_videos(album_id, 'https://vimeo.com/album/%s' % album_id)
827 class VimeoGroupsIE(VimeoAlbumIE):
828 IE_NAME = 'vimeo:group'
829 _VALID_URL = r'https://vimeo\.com/groups/(?P<name>[^/]+)(?:/(?!videos?/\d+)|$)'
831 'url': 'https://vimeo.com/groups/rolexawards',
834 'title': 'Rolex Awards for Enterprise',
836 'playlist_mincount': 73,
839 def _extract_list_title(self, webpage):
840 return self._og_search_title(webpage)
842 def _real_extract(self, url):
843 mobj = re.match(self._VALID_URL, url)
844 name = mobj.group('name')
845 return self._extract_videos(name, 'https://vimeo.com/groups/%s' % name)
848 class VimeoReviewIE(VimeoBaseInfoExtractor):
849 IE_NAME = 'vimeo:review'
850 IE_DESC = 'Review pages on vimeo'
851 _VALID_URL = r'https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)'
853 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
854 'md5': 'c507a72f780cacc12b2248bb4006d253',
858 'title': "DICK HARDWICK 'Comedian'",
859 'uploader': 'Richard Hardwick',
860 'uploader_id': 'user21297594',
863 'note': 'video player needs Referer',
864 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
865 'md5': '6295fdab8f4bf6a002d058b2c6dce276',
869 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
870 'uploader': 'DevWeek Events',
872 'thumbnail': r're:^https?://.*\.jpg$',
873 'uploader_id': 'user22258446',
876 'note': 'Password protected',
877 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde',
881 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1',
883 'uploader_id': 'user37284429',
886 'videopassword': 'holygrail',
888 'skip': 'video gone',
891 def _real_initialize(self):
894 def _get_config_url(self, webpage_url, video_id, video_password_verified=False):
895 webpage = self._download_webpage(webpage_url, video_id)
896 config_url = self._html_search_regex(
897 r'data-config-url=(["\'])(?P<url>(?:(?!\1).)+)\1', webpage,
898 'config URL', default=None, group='url')
900 data = self._parse_json(self._search_regex(
901 r'window\s*=\s*_extend\(window,\s*({.+?})\);', webpage, 'data',
902 default=NO_DEFAULT if video_password_verified else '{}'), video_id)
903 config_url = data.get('vimeo_esi', {}).get('config', {}).get('configUrl')
904 if config_url is None:
905 self._verify_video_password(webpage_url, video_id, webpage)
906 config_url = self._get_config_url(
907 webpage_url, video_id, video_password_verified=True)
910 def _real_extract(self, url):
911 video_id = self._match_id(url)
912 config_url = self._get_config_url(url, video_id)
913 config = self._download_json(config_url, video_id)
914 info_dict = self._parse_config(config, video_id)
915 self._vimeo_sort_formats(info_dict['formats'])
916 info_dict['id'] = video_id
920 class VimeoWatchLaterIE(VimeoChannelIE):
921 IE_NAME = 'vimeo:watchlater'
922 IE_DESC = 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)'
923 _VALID_URL = r'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater'
924 _TITLE = 'Watch Later'
925 _LOGIN_REQUIRED = True
927 'url': 'https://vimeo.com/watchlater',
928 'only_matching': True,
931 def _real_initialize(self):
934 def _page_url(self, base_url, pagenum):
935 url = '%s/page:%d/' % (base_url, pagenum)
936 request = sanitized_Request(url)
937 # Set the header to get a partial html page with the ids,
938 # the normal page doesn't contain them.
939 request.add_header('X-Requested-With', 'XMLHttpRequest')
942 def _real_extract(self, url):
943 return self._extract_videos('watchlater', 'https://vimeo.com/watchlater')
946 class VimeoLikesIE(InfoExtractor):
947 _VALID_URL = r'https://(?:www\.)?vimeo\.com/user(?P<id>[0-9]+)/likes/?(?:$|[?#]|sort:)'
948 IE_NAME = 'vimeo:likes'
949 IE_DESC = 'Vimeo user likes'
951 'url': 'https://vimeo.com/user755559/likes/',
952 'playlist_mincount': 293,
954 'id': 'user755559_likes',
955 'description': 'See all the videos urza likes',
956 'title': 'Videos urza likes',
960 def _real_extract(self, url):
961 user_id = self._match_id(url)
962 webpage = self._download_webpage(url, user_id)
963 page_count = self._int(
965 r'''(?x)<li><a\s+href="[^"]+"\s+data-page="([0-9]+)">
966 .*?</a></li>\s*<li\s+class="pagination_next">
967 ''', webpage, 'page count'),
968 'page count', fatal=True)
970 title = self._html_search_regex(
971 r'(?s)<h1>(.+?)</h1>', webpage, 'title', fatal=False)
972 description = self._html_search_meta('description', webpage)
975 page_url = 'https://vimeo.com/user%s/likes/page:%d/sort:date' % (
977 webpage = self._download_webpage(
979 note='Downloading page %d/%d' % (idx + 1, page_count))
980 video_list = self._search_regex(
981 r'(?s)<ol class="js-browse_list[^"]+"[^>]*>(.*?)</ol>',
982 webpage, 'video content')
984 r'<li[^>]*>\s*<a\s+href="([^"]+)"', video_list)
988 'url': compat_urlparse.urljoin(page_url, path),
991 pl = InAdvancePagedList(_get_page, page_count, PAGE_SIZE)
995 'id': 'user%s_likes' % user_id,
997 'description': description,