]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vimeo.py
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 'timestamp': 1355990239,
217 'upload_date': '20121220',
218 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user7108434',
219 'uploader_id': 'user7108434',
220 'uploader': 'Filippo Valsorda',
226 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
227 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
228 'note': 'Vimeo Pro video (#1197)',
232 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/openstreetmapus',
233 'uploader_id': 'openstreetmapus',
234 'uploader': 'OpenStreetMap US',
235 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
236 'description': 'md5:fd69a7b8d8c34a4e1d2ec2e4afd6ec30',
241 'url': 'http://player.vimeo.com/video/54469442',
242 'md5': '619b811a4417aa4abe78dc653becf511',
243 'note': 'Videos that embed the url in the player page',
247 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
248 'uploader': 'The BLN & Business of Software',
249 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/theblnbusinessofsoftware',
250 'uploader_id': 'theblnbusinessofsoftware',
256 'url': 'http://vimeo.com/68375962',
257 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
258 'note': 'Video protected with password',
262 'title': 'youtube-dl password protected test video',
263 'timestamp': 1371200155,
264 'upload_date': '20130614',
265 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user18948128',
266 'uploader_id': 'user18948128',
267 'uploader': 'Jaime MarquĆnez FerrĆ”ndiz',
269 'description': 'md5:dca3ea23adb29ee387127bc4ddfce63f',
272 'videopassword': 'youtube-dl',
276 'url': 'http://vimeo.com/channels/keypeele/75629013',
277 'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
281 'title': 'Key & Peele: Terrorist Interrogation',
282 'description': 'md5:8678b246399b070816b12313e8b4eb5c',
283 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/atencio',
284 'uploader_id': 'atencio',
285 'uploader': 'Peter Atencio',
286 'timestamp': 1380339469,
287 'upload_date': '20130928',
292 'url': 'http://vimeo.com/76979871',
293 'note': 'Video with subtitles',
297 'title': 'The New Vimeo Player (You Know, For Videos)',
298 'description': 'md5:2ec900bf97c3f389378a96aee11260ea',
299 'timestamp': 1381846109,
300 'upload_date': '20131015',
301 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/staff',
302 'uploader_id': 'staff',
303 'uploader': 'Vimeo Staff',
308 # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
309 'url': 'https://player.vimeo.com/video/98044508',
310 'note': 'The js code contains assignments to the same variable as the config',
314 'title': 'Pier Solar OUYA Official Trailer',
315 'uploader': 'Tulio GonƧalves',
316 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user28849593',
317 'uploader_id': 'user28849593',
321 # contains original format
322 'url': 'https://vimeo.com/33951933',
323 'md5': '53c688fa95a55bf4b7293d37a89c5c53',
327 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
328 'uploader': 'The DMCI',
329 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/dmci',
330 'uploader_id': 'dmci',
331 'timestamp': 1324343742,
332 'upload_date': '20111220',
333 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
337 # only available via https://vimeo.com/channels/tributes/6213729 and
338 # not via https://vimeo.com/6213729
339 'url': 'https://vimeo.com/channels/tributes/6213729',
343 'title': 'Vimeo Tribute: The Shining',
344 'uploader': 'Casey Donahue',
345 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/caseydonahue',
346 'uploader_id': 'caseydonahue',
347 'timestamp': 1250886430,
348 'upload_date': '20090821',
349 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6',
352 'skip_download': True,
354 'expected_warnings': ['Unable to download JSON metadata'],
357 # redirects to ondemand extractor and should be passed through it
358 # for successful extraction
359 'url': 'https://vimeo.com/73445910',
363 'title': 'The Reluctant Revolutionary',
364 'uploader': '10Ft Films',
365 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/tenfootfilms',
366 'uploader_id': 'tenfootfilms',
369 'skip_download': True,
373 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741',
374 'only_matching': True,
377 'url': 'https://vimeo.com/109815029',
378 'note': 'Video not completely processed, "failed" seed status',
379 'only_matching': True,
382 'url': 'https://vimeo.com/groups/travelhd/videos/22439234',
383 'only_matching': True,
386 'url': 'https://vimeo.com/album/2632481/video/79010983',
387 'only_matching': True,
390 # source file returns 403: Forbidden
391 'url': 'https://vimeo.com/7809605',
392 'only_matching': True,
395 'url': 'https://vimeo.com/160743502/abd0e13fb4',
396 'only_matching': True,
401 def _smuggle_referrer(url
, referrer_url
):
402 return smuggle_url(url
, {'http_headers': {'Referer': referrer_url
}})
405 def _extract_urls(url
, webpage
):
407 # Look for embedded (iframe) Vimeo player
408 for mobj
in re
.finditer(
409 r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//player\
.vimeo\
.com
/video
/.+?
)\
1',
411 urls.append(VimeoIE._smuggle_referrer(unescapeHTML(mobj.group('url
')), url))
413 # Look for embedded (swf embed) Vimeo player
414 r'<embed
[^
>]+?src
=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1',
415 # Look more for non-standard embedded Vimeo player
416 r'<video[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//(?
:www\
.)?vimeo\
.com
/[0-9]+)\
1',
418 for embed_re in PLAIN_EMBED_RE:
419 for mobj in re.finditer(embed_re, webpage):
420 urls.append(mobj.group('url
'))
424 def _extract_url(url, webpage):
425 urls = VimeoIE._extract_urls(url, webpage)
426 return urls[0] if urls else None
428 def _verify_player_video_password(self, url, video_id):
429 password = self._downloader.params.get('videopassword
')
431 raise ExtractorError('This video
is protected by a password
, use the
--video
-password option
')
432 data = urlencode_postdata({'password
': password})
433 pass_url = url + '/check
-password
'
434 password_request = sanitized_Request(pass_url, data)
435 password_request.add_header('Content
-Type
', 'application
/x
-www
-form
-urlencoded
')
436 password_request.add_header('Referer
', url)
437 return self._download_json(
438 password_request, video_id,
439 'Verifying the password
', 'Wrong password
')
441 def _real_initialize(self):
444 def _real_extract(self, url):
445 url, data = unsmuggle_url(url, {})
446 headers = std_headers.copy()
447 if 'http_headers
' in data:
448 headers.update(data['http_headers
'])
449 if 'Referer
' not in headers:
450 headers['Referer
'] = url
452 # Extract ID from URL
453 mobj = re.match(self._VALID_URL, url)
454 video_id = mobj.group('id')
456 if mobj.group('pro
') or mobj.group('player
'):
457 url = 'https
://player
.vimeo
.com
/video
/' + video_id
458 elif any(p in url for p in ('play_redirect_hls
', 'moogaloop
.swf
')):
459 url = 'https
://vimeo
.com
/' + video_id
461 # Retrieve video webpage to extract further information
462 request = sanitized_Request(url, headers=headers)
464 webpage, urlh = self._download_webpage_handle(request, video_id)
465 # Some URLs redirect to ondemand can't be extracted
with
466 # this extractor right away thus should be passed through
467 # ondemand extractor (e.g. https://vimeo.com/73445910)
468 if VimeoOndemandIE
.suitable(urlh
.geturl()):
469 return self
.url_result(urlh
.geturl(), VimeoOndemandIE
.ie_key())
470 except ExtractorError
as ee
:
471 if isinstance(ee
.cause
, compat_HTTPError
) and ee
.cause
.code
== 403:
472 errmsg
= ee
.cause
.read()
473 if b
'Because of its privacy settings, this video cannot be played here' in errmsg
:
474 raise ExtractorError(
475 'Cannot download embed-only video without embedding '
476 'URL. Please call youtube-dl with the URL of the page '
477 'that embeds this video.',
481 # Now we begin extracting as much information as we can from what we
482 # retrieved. First we extract the information common to all extractors,
483 # and latter we extract those that are Vimeo specific.
484 self
.report_extraction(video_id
)
486 vimeo_config
= self
._search
_regex
(
487 r
'vimeo\.config\s*=\s*(?:({.+?})|_extend\([^,]+,\s+({.+?})\));', webpage
,
488 'vimeo config', default
=None)
490 seed_status
= self
._parse
_json
(vimeo_config
, video_id
).get('seed_status', {})
491 if seed_status
.get('state') == 'failed':
492 raise ExtractorError(
493 '%s said: %s' % (self
.IE_NAME
, seed_status
['title']),
499 # Extract the config JSON
502 config_url
= self
._html
_search
_regex
(
503 r
' data-config-url="(.+?)"', webpage
,
504 'config URL', default
=None)
506 # Sometimes new react-based page is served instead of old one that require
507 # different config URL extraction approach (see
508 # https://github.com/rg3/youtube-dl/pull/7209)
509 vimeo_clip_page_config
= self
._search
_regex
(
510 r
'vimeo\.clip_page_config\s*=\s*({.+?});', webpage
,
511 'vimeo clip page config')
512 page_config
= self
._parse
_json
(vimeo_clip_page_config
, video_id
)
513 config_url
= page_config
['player']['config_url']
514 cc_license
= page_config
.get('cc_license')
516 page_config
, lambda x
: x
['clip']['uploaded_on'],
518 config_json
= self
._download
_webpage
(config_url
, video_id
)
519 config
= json
.loads(config_json
)
520 except RegexNotFoundError
:
521 # For pro videos or player.vimeo.com urls
522 # We try to find out to which variable is assigned the config dic
523 m_variable_name
= re
.search(r
'(\w)\.video\.id', webpage
)
524 if m_variable_name
is not None:
525 config_re
= r
'%s=({[^}].+?});' % re
.escape(m_variable_name
.group(1))
527 config_re
= [r
' = {config:({.+?}),assets:', r
'(?:[abc])=({.+?});']
528 config
= self
._search
_regex
(config_re
, webpage
, 'info section',
530 config
= json
.loads(config
)
531 except Exception as e
:
532 if re
.search('The creator of this video has not given you permission to embed it on this domain.', webpage
):
533 raise ExtractorError('The author has restricted the access to this video, try with the "--referer" option')
535 if re
.search(r
'<form[^>]+?id="pw_form"', webpage
) is not None:
536 if '_video_password_verified' in data
:
537 raise ExtractorError('video password verification failed!')
538 self
._verify
_video
_password
(url
, video_id
, webpage
)
539 return self
._real
_extract
(
540 smuggle_url(url
, {'_video_password_verified': 'verified'}))
542 raise ExtractorError('Unable to extract info section',
545 if config
.get('view') == 4:
546 config
= self
._verify
_player
_video
_password
(url
, video_id
)
549 if '>You rented this title.<' in webpage
:
551 if config
.get('user', {}).get('purchased'):
554 config
, lambda x
: x
['video']['vod']['purchase_options'][0]['label_string'], compat_str
)
555 if label
and label
.startswith('You rented this'):
560 feature_id
= config
.get('video', {}).get('vod', {}).get('feature_id')
561 if feature_id
and not data
.get('force_feature_id', False):
562 return self
.url_result(smuggle_url(
563 'https://player.vimeo.com/player/%s' % feature_id
,
564 {'force_feature_id': True}), 'Vimeo')
566 # Extract video description
568 video_description
= self
._html
_search
_regex
(
569 r
'(?s)<div\s+class="[^"]*description[^"]*"[^>]*>(.*?)</div>',
570 webpage
, 'description', default
=None)
571 if not video_description
:
572 video_description
= self
._html
_search
_meta
(
573 'description', webpage
, default
=None)
574 if not video_description
and mobj
.group('pro'):
575 orig_webpage
= self
._download
_webpage
(
577 note
='Downloading webpage for description',
580 video_description
= self
._html
_search
_meta
(
581 'description', orig_webpage
, default
=None)
582 if not video_description
and not mobj
.group('player'):
583 self
._downloader
.report_warning('Cannot find video description')
585 # Extract upload date
587 timestamp
= self
._search
_regex
(
588 r
'<time[^>]+datetime="([^"]+)"', webpage
,
589 'timestamp', default
=None)
592 view_count
= int(self
._search
_regex
(r
'UserPlays:(\d+)', webpage
, 'view count'))
593 like_count
= int(self
._search
_regex
(r
'UserLikes:(\d+)', webpage
, 'like count'))
594 comment_count
= int(self
._search
_regex
(r
'UserComments:(\d+)', webpage
, 'comment count'))
595 except RegexNotFoundError
:
596 # This info is only available in vimeo.com/{id} urls
602 download_request
= sanitized_Request('https://vimeo.com/%s?action=load_download_config' % video_id
, headers
={
603 'X-Requested-With': 'XMLHttpRequest'})
604 download_data
= self
._download
_json
(download_request
, video_id
, fatal
=False)
606 source_file
= download_data
.get('source_file')
607 if isinstance(source_file
, dict):
608 download_url
= source_file
.get('download_url')
609 if download_url
and not source_file
.get('is_cold') and not source_file
.get('is_defrosting'):
610 source_name
= source_file
.get('public_name', 'Original')
611 if self
._is
_valid
_url
(download_url
, video_id
, '%s video' % source_name
):
612 ext
= source_file
.get('extension', determine_ext(download_url
)).lower()
616 'width': int_or_none(source_file
.get('width')),
617 'height': int_or_none(source_file
.get('height')),
618 'filesize': parse_filesize(source_file
.get('size')),
619 'format_id': source_name
,
623 info_dict
= self
._parse
_config
(config
, video_id
)
624 formats
.extend(info_dict
['formats'])
625 self
._vimeo
_sort
_formats
(formats
)
628 cc_license
= self
._search
_regex
(
629 r
'<link[^>]+rel=["\']license
["\'][^>]+href=(["\'])(?P
<license
>(?
:(?
!\
1).)+)\
1',
630 webpage, 'license
', default=None, group='license
')
635 'timestamp
': unified_timestamp(timestamp),
636 'description
': video_description,
638 'view_count
': view_count,
639 'like_count
': like_count,
640 'comment_count
': comment_count,
641 'license
': cc_license,
647 class VimeoOndemandIE(VimeoBaseInfoExtractor):
648 IE_NAME = 'vimeo
:ondemand
'
649 _VALID_URL = r'https?
://(?
:www\
.)?vimeo\
.com
/ondemand
/(?P
<id>[^
/?
#&]+)'
651 # ondemand video not available via https://vimeo.com/id
652 'url': 'https://vimeo.com/ondemand/20704',
653 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35',
657 'title': '×××¢××× - ×××× ×××Ŗ× ×¤××××',
658 'uploader': '×× ×”×Ø×××',
659 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/gumfilms',
660 'uploader_id': 'gumfilms',
663 'format': 'best[protocol=https]',
666 # requires Referer to be passed along with og:video:url
667 'url': 'https://vimeo.com/ondemand/36938/126682985',
671 'title': 'RƤvlock, rƤtt lƤte pƄ rƤtt plats',
672 'uploader': 'Lindroth & Norin',
673 'uploader_url': r
're:https?://(?:www\.)?vimeo\.com/user14430847',
674 'uploader_id': 'user14430847',
677 'skip_download': True,
680 'url': 'https://vimeo.com/ondemand/nazmaalik',
681 'only_matching': True,
683 'url': 'https://vimeo.com/ondemand/141692381',
684 'only_matching': True,
686 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832',
687 'only_matching': True,
690 def _real_extract(self
, url
):
691 video_id
= self
._match
_id
(url
)
692 webpage
= self
._download
_webpage
(url
, video_id
)
693 return self
.url_result(
694 # Some videos require Referer to be passed along with og:video:url
695 # similarly to generic vimeo embeds (e.g.
696 # https://vimeo.com/ondemand/36938/126682985).
697 VimeoIE
._smuggle
_referrer
(self
._og
_search
_video
_url
(webpage
), url
),
701 class VimeoChannelIE(VimeoBaseInfoExtractor
):
702 IE_NAME
= 'vimeo:channel'
703 _VALID_URL
= r
'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
704 _MORE_PAGES_INDICATOR
= r
'<a.+?rel="next"'
706 _TITLE_RE
= r
'<link rel="alternate"[^>]+?title="(.*?)"'
708 'url': 'https://vimeo.com/channels/tributes',
711 'title': 'Vimeo Tributes',
713 'playlist_mincount': 25,
716 def _page_url(self
, base_url
, pagenum
):
717 return '%s/videos/page:%d/' % (base_url
, pagenum
)
719 def _extract_list_title(self
, webpage
):
720 return self
._TITLE
or self
._html
_search
_regex
(self
._TITLE
_RE
, webpage
, 'list title')
722 def _login_list_password(self
, page_url
, list_id
, webpage
):
723 login_form
= self
._search
_regex
(
724 r
'(?s)<form[^>]+?id="pw_form"(.*?)</form>',
725 webpage
, 'login form', default
=None)
729 password
= self
._downloader
.params
.get('videopassword')
731 raise ExtractorError('This album is protected by a password, use the --video-password option', expected
=True)
732 fields
= self
._hidden
_inputs
(login_form
)
733 token
, vuid
= self
._extract
_xsrft
_and
_vuid
(webpage
)
734 fields
['token'] = token
735 fields
['password'] = password
736 post
= urlencode_postdata(fields
)
737 password_path
= self
._search
_regex
(
738 r
'action="([^"]+)"', login_form
, 'password URL')
739 password_url
= compat_urlparse
.urljoin(page_url
, password_path
)
740 password_request
= sanitized_Request(password_url
, post
)
741 password_request
.add_header('Content-type', 'application/x-www-form-urlencoded')
742 self
._set
_vimeo
_cookie
('vuid', vuid
)
743 self
._set
_vimeo
_cookie
('xsrft', token
)
745 return self
._download
_webpage
(
746 password_request
, list_id
,
747 'Verifying the password', 'Wrong password')
749 def _title_and_entries(self
, list_id
, base_url
):
750 for pagenum
in itertools
.count(1):
751 page_url
= self
._page
_url
(base_url
, pagenum
)
752 webpage
= self
._download
_webpage
(
754 'Downloading page %s' % pagenum
)
757 webpage
= self
._login
_list
_password
(page_url
, list_id
, webpage
)
758 yield self
._extract
_list
_title
(webpage
)
760 # Try extracting href first since not all videos are available via
761 # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729)
763 r
'id="clip_(\d+)"[^>]*>\s*<a[^>]+href="(/(?:[^/]+/)*\1)(?:[^>]+\btitle="([^"]+)")?', webpage
)
765 for video_id
, video_url
, video_title
in clips
:
766 yield self
.url_result(
767 compat_urlparse
.urljoin(base_url
, video_url
),
768 VimeoIE
.ie_key(), video_id
=video_id
, video_title
=video_title
)
769 # More relaxed fallback
771 for video_id
in re
.findall(r
'id=["\']clip_(\d
+)', webpage):
772 yield self.url_result(
773 'https
://vimeo
.com
/%s' % video_id,
774 VimeoIE.ie_key(), video_id=video_id)
776 if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
779 def _extract_videos(self, list_id, base_url):
780 title_and_entries = self._title_and_entries(list_id, base_url)
781 list_title = next(title_and_entries)
782 return self.playlist_result(title_and_entries, list_id, list_title)
784 def _real_extract(self, url):
785 mobj = re.match(self._VALID_URL, url)
786 channel_id = mobj.group('id')
787 return self._extract_videos(channel_id, 'https
://vimeo
.com
/channels
/%s' % channel_id)
790 class VimeoUserIE(VimeoChannelIE):
791 IE_NAME = 'vimeo
:user
'
792 _VALID_URL = r'https
://vimeo\
.com
/(?
!(?
:[0-9]+|watchlater
)(?
:$|
[?
#/]))(?P<name>[^/]+)(?:/videos|[#?]|$)'
793 _TITLE_RE
= r
'<a[^>]+?class="user">([^<>]+?)</a>'
795 'url': 'https://vimeo.com/nkistudio/videos',
800 'playlist_mincount': 66,
803 def _real_extract(self
, url
):
804 mobj
= re
.match(self
._VALID
_URL
, url
)
805 name
= mobj
.group('name')
806 return self
._extract
_videos
(name
, 'https://vimeo.com/%s' % name
)
809 class VimeoAlbumIE(VimeoChannelIE
):
810 IE_NAME
= 'vimeo:album'
811 _VALID_URL
= r
'https://vimeo\.com/album/(?P<id>\d+)(?:$|[?#]|/(?!video))'
812 _TITLE_RE
= r
'<header id="page_header">\n\s*<h1>(.*?)</h1>'
814 'url': 'https://vimeo.com/album/2632481',
817 'title': 'Staff Favorites: November 2013',
819 'playlist_mincount': 13,
821 'note': 'Password-protected album',
822 'url': 'https://vimeo.com/album/3253534',
829 'videopassword': 'youtube-dl',
832 'url': 'https://vimeo.com/album/2632481/sort:plays/format:thumbnail',
833 'only_matching': True,
835 # TODO: respect page number
836 'url': 'https://vimeo.com/album/2632481/page:2/sort:plays/format:thumbnail',
837 'only_matching': True,
840 def _page_url(self
, base_url
, pagenum
):
841 return '%s/page:%d/' % (base_url
, pagenum
)
843 def _real_extract(self
, url
):
844 album_id
= self
._match
_id
(url
)
845 return self
._extract
_videos
(album_id
, 'https://vimeo.com/album/%s' % album_id
)
848 class VimeoGroupsIE(VimeoAlbumIE
):
849 IE_NAME
= 'vimeo:group'
850 _VALID_URL
= r
'https://vimeo\.com/groups/(?P<name>[^/]+)(?:/(?!videos?/\d+)|$)'
852 'url': 'https://vimeo.com/groups/rolexawards',
855 'title': 'Rolex Awards for Enterprise',
857 'playlist_mincount': 73,
860 def _extract_list_title(self
, webpage
):
861 return self
._og
_search
_title
(webpage
)
863 def _real_extract(self
, url
):
864 mobj
= re
.match(self
._VALID
_URL
, url
)
865 name
= mobj
.group('name')
866 return self
._extract
_videos
(name
, 'https://vimeo.com/groups/%s' % name
)
869 class VimeoReviewIE(VimeoBaseInfoExtractor
):
870 IE_NAME
= 'vimeo:review'
871 IE_DESC
= 'Review pages on vimeo'
872 _VALID_URL
= r
'https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)'
874 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
875 'md5': 'c507a72f780cacc12b2248bb4006d253',
879 'title': "DICK HARDWICK 'Comedian'",
880 'uploader': 'Richard Hardwick',
881 'uploader_id': 'user21297594',
884 'note': 'video player needs Referer',
885 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
886 'md5': '6295fdab8f4bf6a002d058b2c6dce276',
890 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
891 'uploader': 'DevWeek Events',
893 'thumbnail': r
're:^https?://.*\.jpg$',
894 'uploader_id': 'user22258446',
897 'note': 'Password protected',
898 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde',
902 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1',
904 'uploader_id': 'user37284429',
907 'videopassword': 'holygrail',
909 'skip': 'video gone',
912 def _real_initialize(self
):
915 def _get_config_url(self
, webpage_url
, video_id
, video_password_verified
=False):
916 webpage
= self
._download
_webpage
(webpage_url
, video_id
)
917 config_url
= self
._html
_search
_regex
(
918 r
'data-config-url=(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1', webpage,
919 'config URL
', default=None, group='url
')
921 data = self._parse_json(self._search_regex(
922 r'window\s
*=\s
*_extend\
(window
,\s
*({.+?
})\
);', webpage, 'data
',
923 default=NO_DEFAULT if video_password_verified else '{}'), video_id)
924 config_url = data.get('vimeo_esi
', {}).get('config
', {}).get('configUrl
')
925 if config_url is None:
926 self._verify_video_password(webpage_url, video_id, webpage)
927 config_url = self._get_config_url(
928 webpage_url, video_id, video_password_verified=True)
931 def _real_extract(self, url):
932 video_id = self._match_id(url)
933 config_url = self._get_config_url(url, video_id)
934 config = self._download_json(config_url, video_id)
935 info_dict = self._parse_config(config, video_id)
936 self._vimeo_sort_formats(info_dict['formats
'])
937 info_dict['id'] = video_id
941 class VimeoWatchLaterIE(VimeoChannelIE):
942 IE_NAME = 'vimeo
:watchlater
'
943 IE_DESC = 'Vimeo watch later
list, "vimeowatchlater" keyword (requires authentication
)'
944 _VALID_URL = r'https
://vimeo\
.com
/(?
:home
/)?watchlater|
:vimeowatchlater
'
945 _TITLE = 'Watch Later
'
946 _LOGIN_REQUIRED = True
948 'url
': 'https
://vimeo
.com
/watchlater
',
949 'only_matching
': True,
952 def _real_initialize(self):
955 def _page_url(self, base_url, pagenum):
956 url = '%s/page
:%d/' % (base_url, pagenum)
957 request = sanitized_Request(url)
958 # Set the header to get a partial html page with the ids,
959 # the normal page doesn't contain them
.
960 request
.add_header('X-Requested-With', 'XMLHttpRequest')
963 def _real_extract(self
, url
):
964 return self
._extract
_videos
('watchlater', 'https://vimeo.com/watchlater')
967 class VimeoLikesIE(InfoExtractor
):
968 _VALID_URL
= r
'https://(?:www\.)?vimeo\.com/user(?P<id>[0-9]+)/likes/?(?:$|[?#]|sort:)'
969 IE_NAME
= 'vimeo:likes'
970 IE_DESC
= 'Vimeo user likes'
972 'url': 'https://vimeo.com/user755559/likes/',
973 'playlist_mincount': 293,
975 'id': 'user755559_likes',
976 'description': 'See all the videos urza likes',
977 'title': 'Videos urza likes',
981 def _real_extract(self
, url
):
982 user_id
= self
._match
_id
(url
)
983 webpage
= self
._download
_webpage
(url
, user_id
)
984 page_count
= self
._int
(
986 r
'''(?x)<li><a\s+href="[^"]+"\s+data-page="([0-9]+)">
987 .*?</a></li>\s*<li\s+class="pagination_next">
988 ''', webpage
, 'page count'),
989 'page count', fatal
=True)
991 title
= self
._html
_search
_regex
(
992 r
'(?s)<h1>(.+?)</h1>', webpage
, 'title', fatal
=False)
993 description
= self
._html
_search
_meta
('description', webpage
)
996 page_url
= 'https://vimeo.com/user%s/likes/page:%d/sort:date' % (
998 webpage
= self
._download
_webpage
(
1000 note
='Downloading page %d/%d' % (idx
+ 1, page_count
))
1001 video_list
= self
._search
_regex
(
1002 r
'(?s)<ol class="js-browse_list[^"]+"[^>]*>(.*?)</ol>',
1003 webpage
, 'video content')
1005 r
'<li[^>]*>\s*<a\s+href="([^"]+)"', video_list
)
1009 'url': compat_urlparse
.urljoin(page_url
, path
),
1012 pl
= InAdvancePagedList(_get_page
, page_count
, PAGE_SIZE
)
1015 '_type': 'playlist',
1016 'id': 'user%s_likes' % user_id
,
1018 'description': description
,