]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/vimeo.py
7e854f3265eac3312f1b63199ce8633a17eb7d04
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
', 'format_id
'))
97 def _parse_config(self, config, video_id):
99 video_title = config['video
']['title
']
101 # Extract uploader, uploader_url and uploader_id
102 video_uploader = config['video
'].get('owner
', {}).get('name
')
103 video_uploader_url = config['video
'].get('owner
', {}).get('url
')
104 video_uploader_id = video_uploader_url.split('/')[-1] if video_uploader_url else None
106 # Extract video thumbnail
107 video_thumbnail = config['video
'].get('thumbnail
')
108 if video_thumbnail is None:
109 video_thumbs = config['video
'].get('thumbs
')
110 if video_thumbs and isinstance(video_thumbs, dict):
111 _, video_thumbnail = sorted((int(width if width.isdigit() else 0), t_url) for (width, t_url) in video_thumbs.items())[-1]
113 # Extract video duration
114 video_duration = int_or_none(config['video
'].get('duration
'))
117 config_files = config['video
'].get('files
') or config['request
'].get('files
', {})
118 for f in config_files.get('progressive
', []):
119 video_url = f.get('url
')
124 'format_id
': 'http
-%s' % f.get('quality
'),
125 'width
': int_or_none(f.get('width
')),
126 'height
': int_or_none(f.get('height
')),
127 'fps
': int_or_none(f.get('fps
')),
128 'tbr
': int_or_none(f.get('bitrate
')),
130 m3u8_url = config_files.get('hls
', {}).get('url
')
132 formats.extend(self._extract_m3u8_formats(
133 m3u8_url, video_id, 'mp4
', 'm3u8_native
', m3u8_id='hls
', fatal=False))
136 text_tracks = config['request
'].get('text_tracks
')
138 for tt in text_tracks:
139 subtitles[tt['lang
']] = [{
141 'url
': 'https
://vimeo
.com
' + tt['url
'],
145 'title
': video_title,
146 'uploader
': video_uploader,
147 'uploader_id
': video_uploader_id,
148 'uploader_url
': video_uploader_url,
149 'thumbnail
': video_thumbnail,
150 'duration
': video_duration,
152 'subtitles
': subtitles,
156 class VimeoIE(VimeoBaseInfoExtractor):
157 """Information extractor for vimeo.com."""
159 # _VALID_URL matches Vimeo URLs
160 _VALID_URL = r'''(?x)
169 vimeo(?P<pro>pro)?\.com/
170 (?!(?:channels|album)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/)
175 moogaloop\.swf)\?clip_id=
180 /?(?:[?&].*)?(?:[#].*)?$
185 'url
': 'http
://vimeo
.com
/56015672#at=0',
186 'md5': '8879b6cc097e987f02484baf890129e5',
190 'title': "youtube-dl test video - \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550",
191 'description': 'md5:2d3305bad981a06ff79f027f19865021',
192 'upload_date': '20121220',
193 'uploader_url': 're:https?://(?:www\.)?vimeo\.com/user7108434',
194 'uploader_id': 'user7108434',
195 'uploader': 'Filippo Valsorda',
200 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
201 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
202 'note': 'Vimeo Pro video (#1197)',
206 'uploader_url': 're:https?://(?:www\.)?vimeo\.com/openstreetmapus',
207 'uploader_id': 'openstreetmapus',
208 'uploader': 'OpenStreetMap US',
209 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
210 'description': 'md5:fd69a7b8d8c34a4e1d2ec2e4afd6ec30',
215 'url': 'http://player.vimeo.com/video/54469442',
216 'md5': '619b811a4417aa4abe78dc653becf511',
217 'note': 'Videos that embed the url in the player page',
221 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
222 'uploader': 'The BLN & Business of Software',
223 'uploader_url': 're:https?://(?:www\.)?vimeo\.com/theblnbusinessofsoftware',
224 'uploader_id': 'theblnbusinessofsoftware',
230 'url': 'http://vimeo.com/68375962',
231 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
232 'note': 'Video protected with password',
236 'title': 'youtube-dl password protected test video',
237 'upload_date': '20130614',
238 'uploader_url': 're:https?://(?:www\.)?vimeo\.com/user18948128',
239 'uploader_id': 'user18948128',
240 'uploader': 'Jaime MarquĆnez FerrĆ”ndiz',
242 'description': 'This is "youtube-dl password protected test video" by on Vimeo, the home for high quality videos and the people who love them.',
245 'videopassword': 'youtube-dl',
249 'url': 'http://vimeo.com/channels/keypeele/75629013',
250 'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
254 'title': 'Key & Peele: Terrorist Interrogation',
255 'description': 'md5:8678b246399b070816b12313e8b4eb5c',
256 'uploader_url': 're:https?://(?:www\.)?vimeo\.com/atencio',
257 'uploader_id': 'atencio',
258 'uploader': 'Peter Atencio',
259 'upload_date': '20130927',
264 'url': 'http://vimeo.com/76979871',
265 'note': 'Video with subtitles',
269 'title': 'The New Vimeo Player (You Know, For Videos)',
270 'description': 'md5:2ec900bf97c3f389378a96aee11260ea',
271 'upload_date': '20131015',
272 'uploader_url': 're:https?://(?:www\.)?vimeo\.com/staff',
273 'uploader_id': 'staff',
274 'uploader': 'Vimeo Staff',
279 # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
280 'url': 'https://player.vimeo.com/video/98044508',
281 'note': 'The js code contains assignments to the same variable as the config',
285 'title': 'Pier Solar OUYA Official Trailer',
286 'uploader': 'Tulio GonƧalves',
287 'uploader_url': 're:https?://(?:www\.)?vimeo\.com/user28849593',
288 'uploader_id': 'user28849593',
292 # contains original format
293 'url': 'https://vimeo.com/33951933',
294 'md5': '2d9f5475e0537f013d0073e812ab89e6',
298 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
299 'uploader': 'The DMCI',
300 'uploader_url': 're:https?://(?:www\.)?vimeo\.com/dmci',
301 'uploader_id': 'dmci',
302 'upload_date': '20111220',
303 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
307 # only available via https://vimeo.com/channels/tributes/6213729 and
308 # not via https://vimeo.com/6213729
309 'url': 'https://vimeo.com/channels/tributes/6213729',
313 'title': 'Vimeo Tribute: The Shining',
314 'uploader': 'Casey Donahue',
315 'uploader_url': 're:https?://(?:www\.)?vimeo\.com/caseydonahue',
316 'uploader_id': 'caseydonahue',
317 'upload_date': '20090821',
318 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6',
321 'skip_download': True,
323 'expected_warnings': ['Unable to download JSON metadata'],
326 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741',
327 'only_matching': True,
330 'url': 'https://vimeo.com/109815029',
331 'note': 'Video not completely processed, "failed" seed status',
332 'only_matching': True,
335 'url': 'https://vimeo.com/groups/travelhd/videos/22439234',
336 'only_matching': True,
339 'url': 'https://vimeo.com/album/2632481/video/79010983',
340 'only_matching': True,
343 # source file returns 403: Forbidden
344 'url': 'https://vimeo.com/7809605',
345 'only_matching': True,
348 'url': 'https://vimeo.com/160743502/abd0e13fb4',
349 'only_matching': True,
354 def _extract_vimeo_url(url
, webpage
):
355 # Look for embedded (iframe) Vimeo player
357 r
'<iframe[^>]+?src=(["\'])(?P
<url
>(?
:https?
:)?
//player\
.vimeo\
.com
/video
/.+?
)\
1', webpage)
359 player_url = unescapeHTML(mobj.group('url
'))
360 surl = smuggle_url(player_url, {'http_headers
': {'Referer
': url}})
362 # Look for embedded (swf embed) Vimeo player
364 r'<embed
[^
>]+?src
="((?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)"', webpage)
367 # Look more for non-standard embedded Vimeo player
369 r'<video
[^
>]+src
=(?P
<q1
>[\'"])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/[0-9]+)(?P=q1)', webpage)
371 return mobj.group('url')
373 def _verify_player_video_password(self, url, video_id):
374 password = self._downloader.params.get('videopassword')
376 raise ExtractorError('This video is protected by a password, use the --video-password option')
377 data = urlencode_postdata({'password': password})
378 pass_url = url + '/check-password'
379 password_request = sanitized_Request(pass_url, data)
380 password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
381 password_request.add_header('Referer', url)
382 return self._download_json(
383 password_request, video_id,
384 'Verifying the password', 'Wrong password')
386 def _real_initialize(self):
389 def _real_extract(self, url):
390 url, data = unsmuggle_url(url, {})
391 headers = std_headers.copy()
392 if 'http_headers' in data:
393 headers.update(data['http_headers'])
394 if 'Referer' not in headers:
395 headers['Referer'] = url
397 # Extract ID from URL
398 mobj = re.match(self._VALID_URL, url)
399 video_id = mobj.group('id')
401 if mobj.group('pro') or mobj.group('player'):
402 url = 'https://player.vimeo.com/video/' + video_id
403 elif any(p in url for p in ('play_redirect_hls', 'moogaloop.swf')):
404 url = 'https://vimeo.com/' + video_id
406 # Retrieve video webpage to extract further information
407 request = sanitized_Request(url, headers=headers)
409 webpage = self._download_webpage(request, video_id)
410 except ExtractorError as ee:
411 if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
412 errmsg = ee.cause.read()
413 if b'Because of its privacy settings, this video cannot be played here' in errmsg:
414 raise ExtractorError(
415 'Cannot download embed-only video without embedding '
416 'URL. Please call youtube-dl with the URL of the page '
417 'that embeds this video.',
421 # Now we begin extracting as much information as we can from what we
422 # retrieved. First we extract the information common to all extractors,
423 # and latter we extract those that are Vimeo specific.
424 self.report_extraction(video_id)
426 vimeo_config = self._search_regex(
427 r'vimeo\.config\s*=\s*(?:({.+?})|_extend\([^,]+,\s+({.+?})\));', webpage,
428 'vimeo config', default=None)
430 seed_status = self._parse_json(vimeo_config, video_id).get('seed_status', {})
431 if seed_status.get('state') == 'failed':
432 raise ExtractorError(
433 '%s said: %s' % (self.IE_NAME, seed_status['title']),
436 # Extract the config JSON
439 config_url = self._html_search_regex(
440 r' data-config-url="(.+?
)"', webpage,
441 'config URL', default=None)
443 # Sometimes new react-based page is served instead of old one that require
444 # different config URL extraction approach (see
445 # https://github.com/rg3/youtube-dl/pull/7209)
446 vimeo_clip_page_config = self._search_regex(
447 r'vimeo\.clip_page_config\s*=\s*({.+?});', webpage,
448 'vimeo clip page config')
449 config_url = self._parse_json(
450 vimeo_clip_page_config, video_id)['player']['config_url']
451 config_json = self._download_webpage(config_url, video_id)
452 config = json.loads(config_json)
453 except RegexNotFoundError:
454 # For pro videos or player.vimeo.com urls
455 # We try to find out to which variable is assigned the config dic
456 m_variable_name = re.search('(\w)\.video\.id', webpage)
457 if m_variable_name is not None:
458 config_re = r'%s=({[^}].+?});' % re.escape(m_variable_name.group(1))
460 config_re = [r' = {config:({.+?}),assets:', r'(?:[abc])=({.+?});']
461 config = self._search_regex(config_re, webpage, 'info section',
463 config = json.loads(config)
464 except Exception as e:
465 if re.search('The creator of this video has not given you permission to embed it on this domain.', webpage):
466 raise ExtractorError('The author has restricted the access to this video, try with the "--referer
" option')
468 if re.search(r'<form[^>]+?id="pw_form
"', webpage) is not None:
469 if '_video_password_verified' in data:
470 raise ExtractorError('video password verification failed!')
471 self._verify_video_password(url, video_id, webpage)
472 return self._real_extract(
473 smuggle_url(url, {'_video_password_verified': 'verified'}))
475 raise ExtractorError('Unable to extract info section',
478 if config.get('view') == 4:
479 config = self._verify_player_video_password(url, video_id)
482 if '>You rented this title.<' in webpage:
484 if config.get('user', {}).get('purchased'):
487 config, lambda x: x['video']['vod']['purchase_options'][0]['label_string'], compat_str)
488 if label and label.startswith('You rented this'):
493 feature_id = config.get('video', {}).get('vod', {}).get('feature_id')
494 if feature_id and not data.get('force_feature_id', False):
495 return self.url_result(smuggle_url(
496 'https://player.vimeo.com/player/%s' % feature_id,
497 {'force_feature_id': True}), 'Vimeo')
499 # Extract video description
501 video_description = self._html_search_regex(
502 r'(?s)<div\s+class="[^
"]*description[^"]*"[^>]*>(.*?)</div>',
503 webpage, 'description', default=None)
504 if not video_description:
505 video_description = self._html_search_meta(
506 'description', webpage, default=None)
507 if not video_description and mobj.group('pro'):
508 orig_webpage = self._download_webpage(
510 note='Downloading webpage for description',
513 video_description = self._html_search_meta(
514 'description', orig_webpage, default=None)
515 if not video_description and not mobj.group('player'):
516 self._downloader.report_warning('Cannot find video description')
518 # Extract upload date
519 video_upload_date = None
520 mobj = re.search(r'<time[^>]+datetime="([^
"]+)"', webpage)
522 video_upload_date = unified_strdate(mobj.group(1))
525 view_count = int(self._search_regex(r'UserPlays
:(\d
+)', webpage, 'view count
'))
526 like_count = int(self._search_regex(r'UserLikes
:(\d
+)', webpage, 'like count
'))
527 comment_count = int(self._search_regex(r'UserComments
:(\d
+)', webpage, 'comment count
'))
528 except RegexNotFoundError:
529 # This info is only available in vimeo.com/{id} urls
535 download_request = sanitized_Request('https
://vimeo
.com
/%s?action
=load_download_config
' % video_id, headers={
536 'X
-Requested
-With
': 'XMLHttpRequest
'})
537 download_data = self._download_json(download_request, video_id, fatal=False)
539 source_file = download_data.get('source_file
')
540 if isinstance(source_file, dict):
541 download_url = source_file.get('download_url
')
542 if download_url and not source_file.get('is_cold
') and not source_file.get('is_defrosting
'):
543 source_name = source_file.get('public_name
', 'Original
')
544 if self._is_valid_url(download_url, video_id, '%s video
' % source_name):
545 ext = source_file.get('extension
', determine_ext(download_url)).lower()
549 'width
': int_or_none(source_file.get('width
')),
550 'height
': int_or_none(source_file.get('height
')),
551 'filesize
': parse_filesize(source_file.get('size
')),
552 'format_id
': source_name,
556 info_dict = self._parse_config(config, video_id)
557 formats.extend(info_dict['formats
'])
558 self._vimeo_sort_formats(formats)
562 'upload_date
': video_upload_date,
563 'description
': video_description,
565 'view_count
': view_count,
566 'like_count
': like_count,
567 'comment_count
': comment_count,
573 class VimeoOndemandIE(VimeoBaseInfoExtractor):
574 IE_NAME = 'vimeo
:ondemand
'
575 _VALID_URL = r'https?
://(?
:www\
.)?vimeo\
.com
/ondemand
/(?P
<id>[^
/?
#&]+)'
577 # ondemand video not available via https://vimeo.com/id
578 'url': 'https://vimeo.com/ondemand/20704',
579 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35',
583 'title': '×××¢××× - ×××× ×××Ŗ× ×¤××××',
584 'uploader': '×× ×”×Ø×××',
585 'uploader_url': 're:https?://(?:www\.)?vimeo\.com/gumfilms',
586 'uploader_id': 'gumfilms',
589 'url': 'https://vimeo.com/ondemand/nazmaalik',
590 'only_matching': True,
592 'url': 'https://vimeo.com/ondemand/141692381',
593 'only_matching': True,
595 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832',
596 'only_matching': True,
599 def _real_extract(self
, url
):
600 video_id
= self
._match
_id
(url
)
601 webpage
= self
._download
_webpage
(url
, video_id
)
602 return self
.url_result(self
._og
_search
_video
_url
(webpage
), VimeoIE
.ie_key())
605 class VimeoChannelIE(VimeoBaseInfoExtractor
):
606 IE_NAME
= 'vimeo:channel'
607 _VALID_URL
= r
'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
608 _MORE_PAGES_INDICATOR
= r
'<a.+?rel="next"'
610 _TITLE_RE
= r
'<link rel="alternate"[^>]+?title="(.*?)"'
612 'url': 'https://vimeo.com/channels/tributes',
615 'title': 'Vimeo Tributes',
617 'playlist_mincount': 25,
620 def _page_url(self
, base_url
, pagenum
):
621 return '%s/videos/page:%d/' % (base_url
, pagenum
)
623 def _extract_list_title(self
, webpage
):
624 return self
._TITLE
or self
._html
_search
_regex
(self
._TITLE
_RE
, webpage
, 'list title')
626 def _login_list_password(self
, page_url
, list_id
, webpage
):
627 login_form
= self
._search
_regex
(
628 r
'(?s)<form[^>]+?id="pw_form"(.*?)</form>',
629 webpage
, 'login form', default
=None)
633 password
= self
._downloader
.params
.get('videopassword')
635 raise ExtractorError('This album is protected by a password, use the --video-password option', expected
=True)
636 fields
= self
._hidden
_inputs
(login_form
)
637 token
, vuid
= self
._extract
_xsrft
_and
_vuid
(webpage
)
638 fields
['token'] = token
639 fields
['password'] = password
640 post
= urlencode_postdata(fields
)
641 password_path
= self
._search
_regex
(
642 r
'action="([^"]+)"', login_form
, 'password URL')
643 password_url
= compat_urlparse
.urljoin(page_url
, password_path
)
644 password_request
= sanitized_Request(password_url
, post
)
645 password_request
.add_header('Content-type', 'application/x-www-form-urlencoded')
646 self
._set
_vimeo
_cookie
('vuid', vuid
)
647 self
._set
_vimeo
_cookie
('xsrft', token
)
649 return self
._download
_webpage
(
650 password_request
, list_id
,
651 'Verifying the password', 'Wrong password')
653 def _title_and_entries(self
, list_id
, base_url
):
654 for pagenum
in itertools
.count(1):
655 page_url
= self
._page
_url
(base_url
, pagenum
)
656 webpage
= self
._download
_webpage
(
658 'Downloading page %s' % pagenum
)
661 webpage
= self
._login
_list
_password
(page_url
, list_id
, webpage
)
662 yield self
._extract
_list
_title
(webpage
)
664 # Try extracting href first since not all videos are available via
665 # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729)
667 r
'id="clip_(\d+)"[^>]*>\s*<a[^>]+href="(/(?:[^/]+/)*\1)', webpage
)
669 for video_id
, video_url
in clips
:
670 yield self
.url_result(
671 compat_urlparse
.urljoin(base_url
, video_url
),
672 VimeoIE
.ie_key(), video_id
=video_id
)
673 # More relaxed fallback
675 for video_id
in re
.findall(r
'id=["\']clip_(\d
+)', webpage):
676 yield self.url_result(
677 'https
://vimeo
.com
/%s' % video_id,
678 VimeoIE.ie_key(), video_id=video_id)
680 if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
683 def _extract_videos(self, list_id, base_url):
684 title_and_entries = self._title_and_entries(list_id, base_url)
685 list_title = next(title_and_entries)
686 return self.playlist_result(title_and_entries, list_id, list_title)
688 def _real_extract(self, url):
689 mobj = re.match(self._VALID_URL, url)
690 channel_id = mobj.group('id')
691 return self._extract_videos(channel_id, 'https
://vimeo
.com
/channels
/%s' % channel_id)
694 class VimeoUserIE(VimeoChannelIE):
695 IE_NAME = 'vimeo
:user
'
696 _VALID_URL = r'https
://vimeo\
.com
/(?
!(?
:[0-9]+|watchlater
)(?
:$|
[?
#/]))(?P<name>[^/]+)(?:/videos|[#?]|$)'
697 _TITLE_RE
= r
'<a[^>]+?class="user">([^<>]+?)</a>'
699 'url': 'https://vimeo.com/nkistudio/videos',
704 'playlist_mincount': 66,
707 def _real_extract(self
, url
):
708 mobj
= re
.match(self
._VALID
_URL
, url
)
709 name
= mobj
.group('name')
710 return self
._extract
_videos
(name
, 'https://vimeo.com/%s' % name
)
713 class VimeoAlbumIE(VimeoChannelIE
):
714 IE_NAME
= 'vimeo:album'
715 _VALID_URL
= r
'https://vimeo\.com/album/(?P<id>\d+)(?:$|[?#]|/(?!video))'
716 _TITLE_RE
= r
'<header id="page_header">\n\s*<h1>(.*?)</h1>'
718 'url': 'https://vimeo.com/album/2632481',
721 'title': 'Staff Favorites: November 2013',
723 'playlist_mincount': 13,
725 'note': 'Password-protected album',
726 'url': 'https://vimeo.com/album/3253534',
733 'videopassword': 'youtube-dl',
736 'url': 'https://vimeo.com/album/2632481/sort:plays/format:thumbnail',
737 'only_matching': True,
739 # TODO: respect page number
740 'url': 'https://vimeo.com/album/2632481/page:2/sort:plays/format:thumbnail',
741 'only_matching': True,
744 def _page_url(self
, base_url
, pagenum
):
745 return '%s/page:%d/' % (base_url
, pagenum
)
747 def _real_extract(self
, url
):
748 album_id
= self
._match
_id
(url
)
749 return self
._extract
_videos
(album_id
, 'https://vimeo.com/album/%s' % album_id
)
752 class VimeoGroupsIE(VimeoAlbumIE
):
753 IE_NAME
= 'vimeo:group'
754 _VALID_URL
= r
'https://vimeo\.com/groups/(?P<name>[^/]+)(?:/(?!videos?/\d+)|$)'
756 'url': 'https://vimeo.com/groups/rolexawards',
759 'title': 'Rolex Awards for Enterprise',
761 'playlist_mincount': 73,
764 def _extract_list_title(self
, webpage
):
765 return self
._og
_search
_title
(webpage
)
767 def _real_extract(self
, url
):
768 mobj
= re
.match(self
._VALID
_URL
, url
)
769 name
= mobj
.group('name')
770 return self
._extract
_videos
(name
, 'https://vimeo.com/groups/%s' % name
)
773 class VimeoReviewIE(VimeoBaseInfoExtractor
):
774 IE_NAME
= 'vimeo:review'
775 IE_DESC
= 'Review pages on vimeo'
776 _VALID_URL
= r
'https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)'
778 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
779 'md5': 'c507a72f780cacc12b2248bb4006d253',
783 'title': "DICK HARDWICK 'Comedian'",
784 'uploader': 'Richard Hardwick',
785 'uploader_id': 'user21297594',
788 'note': 'video player needs Referer',
789 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
790 'md5': '6295fdab8f4bf6a002d058b2c6dce276',
794 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
795 'uploader': 'DevWeek Events',
797 'thumbnail': 're:^https?://.*\.jpg$',
798 'uploader_id': 'user22258446',
801 'note': 'Password protected',
802 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde',
806 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1',
808 'uploader_id': 'user37284429',
811 'videopassword': 'holygrail',
815 def _real_initialize(self
):
818 def _get_config_url(self
, webpage_url
, video_id
, video_password_verified
=False):
819 webpage
= self
._download
_webpage
(webpage_url
, video_id
)
820 config_url
= self
._html
_search
_regex
(
821 r
'data-config-url="([^"]+)"', webpage
, 'config URL',
822 default
=NO_DEFAULT
if video_password_verified
else None)
823 if config_url
is None:
824 self
._verify
_video
_password
(webpage_url
, video_id
, webpage
)
825 config_url
= self
._get
_config
_url
(
826 webpage_url
, video_id
, video_password_verified
=True)
829 def _real_extract(self
, url
):
830 video_id
= self
._match
_id
(url
)
831 config_url
= self
._get
_config
_url
(url
, video_id
)
832 config
= self
._download
_json
(config_url
, video_id
)
833 info_dict
= self
._parse
_config
(config
, video_id
)
834 self
._vimeo
_sort
_formats
(info_dict
['formats'])
835 info_dict
['id'] = video_id
839 class VimeoWatchLaterIE(VimeoChannelIE
):
840 IE_NAME
= 'vimeo:watchlater'
841 IE_DESC
= 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)'
842 _VALID_URL
= r
'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater'
843 _TITLE
= 'Watch Later'
844 _LOGIN_REQUIRED
= True
846 'url': 'https://vimeo.com/watchlater',
847 'only_matching': True,
850 def _real_initialize(self
):
853 def _page_url(self
, base_url
, pagenum
):
854 url
= '%s/page:%d/' % (base_url
, pagenum
)
855 request
= sanitized_Request(url
)
856 # Set the header to get a partial html page with the ids,
857 # the normal page doesn't contain them.
858 request
.add_header('X-Requested-With', 'XMLHttpRequest')
861 def _real_extract(self
, url
):
862 return self
._extract
_videos
('watchlater', 'https://vimeo.com/watchlater')
865 class VimeoLikesIE(InfoExtractor
):
866 _VALID_URL
= r
'https://(?:www\.)?vimeo\.com/user(?P<id>[0-9]+)/likes/?(?:$|[?#]|sort:)'
867 IE_NAME
= 'vimeo:likes'
868 IE_DESC
= 'Vimeo user likes'
870 'url': 'https://vimeo.com/user755559/likes/',
871 'playlist_mincount': 293,
873 'id': 'user755559_likes',
874 'description': 'See all the videos urza likes',
875 'title': 'Videos urza likes',
879 def _real_extract(self
, url
):
880 user_id
= self
._match
_id
(url
)
881 webpage
= self
._download
_webpage
(url
, user_id
)
882 page_count
= self
._int
(
884 r
'''(?x)<li><a\s+href="[^"]+"\s+data-page="([0-9]+)">
885 .*?</a></li>\s*<li\s+class="pagination_next">
886 ''', webpage
, 'page count'),
887 'page count', fatal
=True)
889 title
= self
._html
_search
_regex
(
890 r
'(?s)<h1>(.+?)</h1>', webpage
, 'title', fatal
=False)
891 description
= self
._html
_search
_meta
('description', webpage
)
894 page_url
= 'https://vimeo.com/user%s/likes/page:%d/sort:date' % (
896 webpage
= self
._download
_webpage
(
898 note
='Downloading page %d/%d' % (idx
+ 1, page_count
))
899 video_list
= self
._search
_regex
(
900 r
'(?s)<ol class="js-browse_list[^"]+"[^>]*>(.*?)</ol>',
901 webpage
, 'video content')
903 r
'<li[^>]*>\s*<a\s+href="([^"]+)"', video_list
)
907 'url': compat_urlparse
.urljoin(page_url
, path
),
910 pl
= InAdvancePagedList(_get_page
, page_count
, PAGE_SIZE
)
914 'id': 'user%s_likes' % user_id
,
916 'description': description
,