]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/vimeo.py
[SpankBang] Use python2.6 compatible string formatting spec
[youtube-dl] / youtube_dl / extractor / vimeo.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 import json
5 import re
6 import itertools
7
8 from .common import InfoExtractor
9 from ..compat import (
10     compat_HTTPError,
11     compat_urllib_parse,
12     compat_urllib_request,
13     compat_urlparse,
14 )
15 from ..utils import (
16     ExtractorError,
17     InAdvancePagedList,
18     int_or_none,
19     RegexNotFoundError,
20     smuggle_url,
21     std_headers,
22     unified_strdate,
23     unsmuggle_url,
24     urlencode_postdata,
25 )
26
27
28 class VimeoBaseInfoExtractor(InfoExtractor):
29     _NETRC_MACHINE = 'vimeo'
30     _LOGIN_REQUIRED = False
31
32     def _login(self):
33         (username, password) = self._get_login_info()
34         if username is None:
35             if self._LOGIN_REQUIRED:
36                 raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
37             return
38         self.report_login()
39         login_url = 'https://vimeo.com/log_in'
40         webpage = self._download_webpage(login_url, None, False)
41         token = self._search_regex(r'xsrft = \'(.*?)\'', webpage, 'login token')
42         data = urlencode_postdata({
43             'email': username,
44             'password': password,
45             'action': 'login',
46             'service': 'vimeo',
47             'token': token,
48         })
49         login_request = compat_urllib_request.Request(login_url, data)
50         login_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
51         login_request.add_header('Cookie', 'xsrft=%s' % token)
52         self._download_webpage(login_request, None, False, 'Wrong login info')
53
54
55 class VimeoIE(VimeoBaseInfoExtractor):
56     """Information extractor for vimeo.com."""
57
58     # _VALID_URL matches Vimeo URLs
59     _VALID_URL = r'''(?x)
60         https?://
61         (?:(?:www|(?P<player>player))\.)?
62         vimeo(?P<pro>pro)?\.com/
63         (?!channels/[^/?#]+/?(?:$|[?#])|album/)
64         (?:.*?/)?
65         (?:(?:play_redirect_hls|moogaloop\.swf)\?clip_id=)?
66         (?:videos?/)?
67         (?P<id>[0-9]+)
68         /?(?:[?&].*)?(?:[#].*)?$'''
69     IE_NAME = 'vimeo'
70     _TESTS = [
71         {
72             'url': 'http://vimeo.com/56015672#at=0',
73             'md5': '8879b6cc097e987f02484baf890129e5',
74             'info_dict': {
75                 'id': '56015672',
76                 'ext': 'mp4',
77                 "upload_date": "20121220",
78                 "description": "This is a test case for youtube-dl.\nFor more information, see github.com/rg3/youtube-dl\nTest chars: \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550",
79                 "uploader_id": "user7108434",
80                 "uploader": "Filippo Valsorda",
81                 "title": "youtube-dl test video - \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550",
82                 "duration": 10,
83             },
84         },
85         {
86             'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
87             'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
88             'note': 'Vimeo Pro video (#1197)',
89             'info_dict': {
90                 'id': '68093876',
91                 'ext': 'mp4',
92                 'uploader_id': 'openstreetmapus',
93                 'uploader': 'OpenStreetMap US',
94                 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
95                 'description': 'md5:380943ec71b89736ff4bf27183233d09',
96                 'duration': 1595,
97             },
98         },
99         {
100             'url': 'http://player.vimeo.com/video/54469442',
101             'md5': '619b811a4417aa4abe78dc653becf511',
102             'note': 'Videos that embed the url in the player page',
103             'info_dict': {
104                 'id': '54469442',
105                 'ext': 'mp4',
106                 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
107                 'uploader': 'The BLN & Business of Software',
108                 'uploader_id': 'theblnbusinessofsoftware',
109                 'duration': 3610,
110                 'description': None,
111             },
112         },
113         {
114             'url': 'http://vimeo.com/68375962',
115             'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
116             'note': 'Video protected with password',
117             'info_dict': {
118                 'id': '68375962',
119                 'ext': 'mp4',
120                 'title': 'youtube-dl password protected test video',
121                 'upload_date': '20130614',
122                 'uploader_id': 'user18948128',
123                 'uploader': 'Jaime Marquínez Ferrándiz',
124                 'duration': 10,
125                 'description': 'This is "youtube-dl password protected test video" by Jaime Marquínez Ferrándiz on Vimeo, the home for high quality videos and the people who love them.',
126             },
127             'params': {
128                 'videopassword': 'youtube-dl',
129             },
130         },
131         {
132             'url': 'http://vimeo.com/channels/keypeele/75629013',
133             'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
134             'note': 'Video is freely available via original URL '
135                     'and protected with password when accessed via http://vimeo.com/75629013',
136             'info_dict': {
137                 'id': '75629013',
138                 'ext': 'mp4',
139                 'title': 'Key & Peele: Terrorist Interrogation',
140                 'description': 'md5:8678b246399b070816b12313e8b4eb5c',
141                 'uploader_id': 'atencio',
142                 'uploader': 'Peter Atencio',
143                 'upload_date': '20130927',
144                 'duration': 187,
145             },
146         },
147         {
148             'url': 'http://vimeo.com/76979871',
149             'md5': '3363dd6ffebe3784d56f4132317fd446',
150             'note': 'Video with subtitles',
151             'info_dict': {
152                 'id': '76979871',
153                 'ext': 'mp4',
154                 'title': 'The New Vimeo Player (You Know, For Videos)',
155                 'description': 'md5:2ec900bf97c3f389378a96aee11260ea',
156                 'upload_date': '20131015',
157                 'uploader_id': 'staff',
158                 'uploader': 'Vimeo Staff',
159                 'duration': 62,
160             }
161         },
162         {
163             # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
164             'url': 'https://player.vimeo.com/video/98044508',
165             'note': 'The js code contains assignments to the same variable as the config',
166             'info_dict': {
167                 'id': '98044508',
168                 'ext': 'mp4',
169                 'title': 'Pier Solar OUYA Official Trailer',
170                 'uploader': 'Tulio Gonçalves',
171                 'uploader_id': 'user28849593',
172             },
173         },
174     ]
175
176     def _verify_video_password(self, url, video_id, webpage):
177         password = self._downloader.params.get('videopassword', None)
178         if password is None:
179             raise ExtractorError('This video is protected by a password, use the --video-password option', expected=True)
180         token = self._search_regex(r'xsrft = \'(.*?)\'', webpage, 'login token')
181         data = urlencode_postdata({
182             'password': password,
183             'token': token,
184         })
185         if url.startswith('http://'):
186             # vimeo only supports https now, but the user can give an http url
187             url = url.replace('http://', 'https://')
188         password_request = compat_urllib_request.Request(url + '/password', data)
189         password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
190         password_request.add_header('Cookie', 'xsrft=%s' % token)
191         return self._download_webpage(
192             password_request, video_id,
193             'Verifying the password', 'Wrong password')
194
195     def _verify_player_video_password(self, url, video_id):
196         password = self._downloader.params.get('videopassword', None)
197         if password is None:
198             raise ExtractorError('This video is protected by a password, use the --video-password option')
199         data = compat_urllib_parse.urlencode({'password': password})
200         pass_url = url + '/check-password'
201         password_request = compat_urllib_request.Request(pass_url, data)
202         password_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
203         return self._download_json(
204             password_request, video_id,
205             'Verifying the password',
206             'Wrong password')
207
208     def _real_initialize(self):
209         self._login()
210
211     def _real_extract(self, url):
212         url, data = unsmuggle_url(url)
213         headers = std_headers
214         if data is not None:
215             headers = headers.copy()
216             headers.update(data)
217         if 'Referer' not in headers:
218             headers['Referer'] = url
219
220         # Extract ID from URL
221         mobj = re.match(self._VALID_URL, url)
222         video_id = mobj.group('id')
223         orig_url = url
224         if mobj.group('pro') or mobj.group('player'):
225             url = 'https://player.vimeo.com/video/' + video_id
226
227         # Retrieve video webpage to extract further information
228         request = compat_urllib_request.Request(url, None, headers)
229         try:
230             webpage = self._download_webpage(request, video_id)
231         except ExtractorError as ee:
232             if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
233                 errmsg = ee.cause.read()
234                 if b'Because of its privacy settings, this video cannot be played here' in errmsg:
235                     raise ExtractorError(
236                         'Cannot download embed-only video without embedding '
237                         'URL. Please call youtube-dl with the URL of the page '
238                         'that embeds this video.',
239                         expected=True)
240             raise
241
242         # Now we begin extracting as much information as we can from what we
243         # retrieved. First we extract the information common to all extractors,
244         # and latter we extract those that are Vimeo specific.
245         self.report_extraction(video_id)
246
247         vimeo_config = self._search_regex(
248             r'vimeo\.config\s*=\s*({.+?});', webpage,
249             'vimeo config', default=None)
250         if vimeo_config:
251             seed_status = self._parse_json(vimeo_config, video_id).get('seed_status', {})
252             if seed_status.get('state') == 'failed':
253                 raise ExtractorError(
254                     '%s returned error: %s' % (self.IE_NAME, seed_status['title']),
255                     expected=True)
256
257         # Extract the config JSON
258         try:
259             try:
260                 config_url = self._html_search_regex(
261                     r' data-config-url="(.+?)"', webpage, 'config URL')
262                 config_json = self._download_webpage(config_url, video_id)
263                 config = json.loads(config_json)
264             except RegexNotFoundError:
265                 # For pro videos or player.vimeo.com urls
266                 # We try to find out to which variable is assigned the config dic
267                 m_variable_name = re.search('(\w)\.video\.id', webpage)
268                 if m_variable_name is not None:
269                     config_re = r'%s=({[^}].+?});' % re.escape(m_variable_name.group(1))
270                 else:
271                     config_re = [r' = {config:({.+?}),assets:', r'(?:[abc])=({.+?});']
272                 config = self._search_regex(config_re, webpage, 'info section',
273                                             flags=re.DOTALL)
274                 config = json.loads(config)
275         except Exception as e:
276             if re.search('The creator of this video has not given you permission to embed it on this domain.', webpage):
277                 raise ExtractorError('The author has restricted the access to this video, try with the "--referer" option')
278
279             if re.search(r'<form[^>]+?id="pw_form"', webpage) is not None:
280                 if data and '_video_password_verified' in data:
281                     raise ExtractorError('video password verification failed!')
282                 self._verify_video_password(url, video_id, webpage)
283                 return self._real_extract(
284                     smuggle_url(url, {'_video_password_verified': 'verified'}))
285             else:
286                 raise ExtractorError('Unable to extract info section',
287                                      cause=e)
288         else:
289             if config.get('view') == 4:
290                 config = self._verify_player_video_password(url, video_id)
291
292         # Extract title
293         video_title = config["video"]["title"]
294
295         # Extract uploader and uploader_id
296         video_uploader = config["video"]["owner"]["name"]
297         video_uploader_id = config["video"]["owner"]["url"].split('/')[-1] if config["video"]["owner"]["url"] else None
298
299         # Extract video thumbnail
300         video_thumbnail = config["video"].get("thumbnail")
301         if video_thumbnail is None:
302             video_thumbs = config["video"].get("thumbs")
303             if video_thumbs and isinstance(video_thumbs, dict):
304                 _, video_thumbnail = sorted((int(width if width.isdigit() else 0), t_url) for (width, t_url) in video_thumbs.items())[-1]
305
306         # Extract video description
307
308         video_description = self._html_search_regex(
309             r'(?s)<div\s+class="[^"]*description[^"]*"[^>]*>(.*?)</div>',
310             webpage, 'description', default=None)
311         if not video_description:
312             video_description = self._html_search_meta(
313                 'description', webpage, default=None)
314         if not video_description and mobj.group('pro'):
315             orig_webpage = self._download_webpage(
316                 orig_url, video_id,
317                 note='Downloading webpage for description',
318                 fatal=False)
319             if orig_webpage:
320                 video_description = self._html_search_meta(
321                     'description', orig_webpage, default=None)
322         if not video_description and not mobj.group('player'):
323             self._downloader.report_warning('Cannot find video description')
324
325         # Extract video duration
326         video_duration = int_or_none(config["video"].get("duration"))
327
328         # Extract upload date
329         video_upload_date = None
330         mobj = re.search(r'<time[^>]+datetime="([^"]+)"', webpage)
331         if mobj is not None:
332             video_upload_date = unified_strdate(mobj.group(1))
333
334         try:
335             view_count = int(self._search_regex(r'UserPlays:(\d+)', webpage, 'view count'))
336             like_count = int(self._search_regex(r'UserLikes:(\d+)', webpage, 'like count'))
337             comment_count = int(self._search_regex(r'UserComments:(\d+)', webpage, 'comment count'))
338         except RegexNotFoundError:
339             # This info is only available in vimeo.com/{id} urls
340             view_count = None
341             like_count = None
342             comment_count = None
343
344         # Vimeo specific: extract request signature and timestamp
345         sig = config['request']['signature']
346         timestamp = config['request']['timestamp']
347
348         # Vimeo specific: extract video codec and quality information
349         # First consider quality, then codecs, then take everything
350         codecs = [('vp6', 'flv'), ('vp8', 'flv'), ('h264', 'mp4')]
351         files = {'hd': [], 'sd': [], 'other': []}
352         config_files = config["video"].get("files") or config["request"].get("files")
353         for codec_name, codec_extension in codecs:
354             for quality in config_files.get(codec_name, []):
355                 format_id = '-'.join((codec_name, quality)).lower()
356                 key = quality if quality in files else 'other'
357                 video_url = None
358                 if isinstance(config_files[codec_name], dict):
359                     file_info = config_files[codec_name][quality]
360                     video_url = file_info.get('url')
361                 else:
362                     file_info = {}
363                 if video_url is None:
364                     video_url = "http://player.vimeo.com/play_redirect?clip_id=%s&sig=%s&time=%s&quality=%s&codecs=%s&type=moogaloop_local&embed_location=" \
365                         % (video_id, sig, timestamp, quality, codec_name.upper())
366
367                 files[key].append({
368                     'ext': codec_extension,
369                     'url': video_url,
370                     'format_id': format_id,
371                     'width': file_info.get('width'),
372                     'height': file_info.get('height'),
373                 })
374         formats = []
375         for key in ('other', 'sd', 'hd'):
376             formats += files[key]
377         if len(formats) == 0:
378             raise ExtractorError('No known codec found')
379
380         subtitles = {}
381         text_tracks = config['request'].get('text_tracks')
382         if text_tracks:
383             for tt in text_tracks:
384                 subtitles[tt['lang']] = [{
385                     'ext': 'vtt',
386                     'url': 'https://vimeo.com' + tt['url'],
387                 }]
388
389         return {
390             'id': video_id,
391             'uploader': video_uploader,
392             'uploader_id': video_uploader_id,
393             'upload_date': video_upload_date,
394             'title': video_title,
395             'thumbnail': video_thumbnail,
396             'description': video_description,
397             'duration': video_duration,
398             'formats': formats,
399             'webpage_url': url,
400             'view_count': view_count,
401             'like_count': like_count,
402             'comment_count': comment_count,
403             'subtitles': subtitles,
404         }
405
406
407 class VimeoChannelIE(InfoExtractor):
408     IE_NAME = 'vimeo:channel'
409     _VALID_URL = r'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
410     _MORE_PAGES_INDICATOR = r'<a.+?rel="next"'
411     _TITLE_RE = r'<link rel="alternate"[^>]+?title="(.*?)"'
412     _TESTS = [{
413         'url': 'https://vimeo.com/channels/tributes',
414         'info_dict': {
415             'id': 'tributes',
416             'title': 'Vimeo Tributes',
417         },
418         'playlist_mincount': 25,
419     }]
420
421     def _page_url(self, base_url, pagenum):
422         return '%s/videos/page:%d/' % (base_url, pagenum)
423
424     def _extract_list_title(self, webpage):
425         return self._html_search_regex(self._TITLE_RE, webpage, 'list title')
426
427     def _login_list_password(self, page_url, list_id, webpage):
428         login_form = self._search_regex(
429             r'(?s)<form[^>]+?id="pw_form"(.*?)</form>',
430             webpage, 'login form', default=None)
431         if not login_form:
432             return webpage
433
434         password = self._downloader.params.get('videopassword', None)
435         if password is None:
436             raise ExtractorError('This album is protected by a password, use the --video-password option', expected=True)
437         fields = dict(re.findall(r'''(?x)<input\s+
438             type="hidden"\s+
439             name="([^"]+)"\s+
440             value="([^"]*)"
441             ''', login_form))
442         token = self._search_regex(r'xsrft = \'(.*?)\'', webpage, 'login token')
443         fields['token'] = token
444         fields['password'] = password
445         post = urlencode_postdata(fields)
446         password_path = self._search_regex(
447             r'action="([^"]+)"', login_form, 'password URL')
448         password_url = compat_urlparse.urljoin(page_url, password_path)
449         password_request = compat_urllib_request.Request(password_url, post)
450         password_request.add_header('Content-type', 'application/x-www-form-urlencoded')
451         self._set_cookie('vimeo.com', 'xsrft', token)
452
453         return self._download_webpage(
454             password_request, list_id,
455             'Verifying the password', 'Wrong password')
456
457     def _extract_videos(self, list_id, base_url):
458         video_ids = []
459         for pagenum in itertools.count(1):
460             page_url = self._page_url(base_url, pagenum)
461             webpage = self._download_webpage(
462                 page_url, list_id,
463                 'Downloading page %s' % pagenum)
464
465             if pagenum == 1:
466                 webpage = self._login_list_password(page_url, list_id, webpage)
467
468             video_ids.extend(re.findall(r'id="clip_(\d+?)"', webpage))
469             if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
470                 break
471
472         entries = [self.url_result('https://vimeo.com/%s' % video_id, 'Vimeo')
473                    for video_id in video_ids]
474         return {'_type': 'playlist',
475                 'id': list_id,
476                 'title': self._extract_list_title(webpage),
477                 'entries': entries,
478                 }
479
480     def _real_extract(self, url):
481         mobj = re.match(self._VALID_URL, url)
482         channel_id = mobj.group('id')
483         return self._extract_videos(channel_id, 'https://vimeo.com/channels/%s' % channel_id)
484
485
486 class VimeoUserIE(VimeoChannelIE):
487     IE_NAME = 'vimeo:user'
488     _VALID_URL = r'https://vimeo\.com/(?![0-9]+(?:$|[?#/]))(?P<name>[^/]+)(?:/videos|[#?]|$)'
489     _TITLE_RE = r'<a[^>]+?class="user">([^<>]+?)</a>'
490     _TESTS = [{
491         'url': 'https://vimeo.com/nkistudio/videos',
492         'info_dict': {
493             'title': 'Nki',
494             'id': 'nkistudio',
495         },
496         'playlist_mincount': 66,
497     }]
498
499     def _real_extract(self, url):
500         mobj = re.match(self._VALID_URL, url)
501         name = mobj.group('name')
502         return self._extract_videos(name, 'https://vimeo.com/%s' % name)
503
504
505 class VimeoAlbumIE(VimeoChannelIE):
506     IE_NAME = 'vimeo:album'
507     _VALID_URL = r'https://vimeo\.com/album/(?P<id>\d+)'
508     _TITLE_RE = r'<header id="page_header">\n\s*<h1>(.*?)</h1>'
509     _TESTS = [{
510         'url': 'https://vimeo.com/album/2632481',
511         'info_dict': {
512             'id': '2632481',
513             'title': 'Staff Favorites: November 2013',
514         },
515         'playlist_mincount': 13,
516     }, {
517         'note': 'Password-protected album',
518         'url': 'https://vimeo.com/album/3253534',
519         'info_dict': {
520             'title': 'test',
521             'id': '3253534',
522         },
523         'playlist_count': 1,
524         'params': {
525             'videopassword': 'youtube-dl',
526         }
527     }]
528
529     def _page_url(self, base_url, pagenum):
530         return '%s/page:%d/' % (base_url, pagenum)
531
532     def _real_extract(self, url):
533         album_id = self._match_id(url)
534         return self._extract_videos(album_id, 'https://vimeo.com/album/%s' % album_id)
535
536
537 class VimeoGroupsIE(VimeoAlbumIE):
538     IE_NAME = 'vimeo:group'
539     _VALID_URL = r'https://vimeo\.com/groups/(?P<name>[^/]+)'
540     _TESTS = [{
541         'url': 'https://vimeo.com/groups/rolexawards',
542         'info_dict': {
543             'id': 'rolexawards',
544             'title': 'Rolex Awards for Enterprise',
545         },
546         'playlist_mincount': 73,
547     }]
548
549     def _extract_list_title(self, webpage):
550         return self._og_search_title(webpage)
551
552     def _real_extract(self, url):
553         mobj = re.match(self._VALID_URL, url)
554         name = mobj.group('name')
555         return self._extract_videos(name, 'https://vimeo.com/groups/%s' % name)
556
557
558 class VimeoReviewIE(InfoExtractor):
559     IE_NAME = 'vimeo:review'
560     IE_DESC = 'Review pages on vimeo'
561     _VALID_URL = r'https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)'
562     _TESTS = [{
563         'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
564         'md5': 'c507a72f780cacc12b2248bb4006d253',
565         'info_dict': {
566             'id': '75524534',
567             'ext': 'mp4',
568             'title': "DICK HARDWICK 'Comedian'",
569             'uploader': 'Richard Hardwick',
570         }
571     }, {
572         'note': 'video player needs Referer',
573         'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
574         'md5': '6295fdab8f4bf6a002d058b2c6dce276',
575         'info_dict': {
576             'id': '91613211',
577             'ext': 'mp4',
578             'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
579             'uploader': 'DevWeek Events',
580             'duration': 2773,
581             'thumbnail': 're:^https?://.*\.jpg$',
582         }
583     }]
584
585     def _real_extract(self, url):
586         mobj = re.match(self._VALID_URL, url)
587         video_id = mobj.group('id')
588         player_url = 'https://player.vimeo.com/player/' + video_id
589         return self.url_result(player_url, 'Vimeo', video_id)
590
591
592 class VimeoWatchLaterIE(VimeoBaseInfoExtractor, VimeoChannelIE):
593     IE_NAME = 'vimeo:watchlater'
594     IE_DESC = 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)'
595     _VALID_URL = r'https://vimeo\.com/home/watchlater|:vimeowatchlater'
596     _LOGIN_REQUIRED = True
597     _TITLE_RE = r'href="/home/watchlater".*?>(.*?)<'
598     _TESTS = [{
599         'url': 'https://vimeo.com/home/watchlater',
600         'only_matching': True,
601     }]
602
603     def _real_initialize(self):
604         self._login()
605
606     def _page_url(self, base_url, pagenum):
607         url = '%s/page:%d/' % (base_url, pagenum)
608         request = compat_urllib_request.Request(url)
609         # Set the header to get a partial html page with the ids,
610         # the normal page doesn't contain them.
611         request.add_header('X-Requested-With', 'XMLHttpRequest')
612         return request
613
614     def _real_extract(self, url):
615         return self._extract_videos('watchlater', 'https://vimeo.com/home/watchlater')
616
617
618 class VimeoLikesIE(InfoExtractor):
619     _VALID_URL = r'https://(?:www\.)?vimeo\.com/user(?P<id>[0-9]+)/likes/?(?:$|[?#]|sort:)'
620     IE_NAME = 'vimeo:likes'
621     IE_DESC = 'Vimeo user likes'
622     _TEST = {
623         'url': 'https://vimeo.com/user755559/likes/',
624         'playlist_mincount': 293,
625         "info_dict": {
626             'id': 'user755559_likes',
627             "description": "See all the videos urza likes",
628             "title": 'Videos urza likes',
629         },
630     }
631
632     def _real_extract(self, url):
633         user_id = self._match_id(url)
634         webpage = self._download_webpage(url, user_id)
635         page_count = self._int(
636             self._search_regex(
637                 r'''(?x)<li><a\s+href="[^"]+"\s+data-page="([0-9]+)">
638                     .*?</a></li>\s*<li\s+class="pagination_next">
639                 ''', webpage, 'page count'),
640             'page count', fatal=True)
641         PAGE_SIZE = 12
642         title = self._html_search_regex(
643             r'(?s)<h1>(.+?)</h1>', webpage, 'title', fatal=False)
644         description = self._html_search_meta('description', webpage)
645
646         def _get_page(idx):
647             page_url = 'https://vimeo.com/user%s/likes/page:%d/sort:date' % (
648                 user_id, idx + 1)
649             webpage = self._download_webpage(
650                 page_url, user_id,
651                 note='Downloading page %d/%d' % (idx + 1, page_count))
652             video_list = self._search_regex(
653                 r'(?s)<ol class="js-browse_list[^"]+"[^>]*>(.*?)</ol>',
654                 webpage, 'video content')
655             paths = re.findall(
656                 r'<li[^>]*>\s*<a\s+href="([^"]+)"', video_list)
657             for path in paths:
658                 yield {
659                     '_type': 'url',
660                     'url': compat_urlparse.urljoin(page_url, path),
661                 }
662
663         pl = InAdvancePagedList(_get_page, page_count, PAGE_SIZE)
664
665         return {
666             '_type': 'playlist',
667             'id': 'user%s_likes' % user_id,
668             'title': title,
669             'description': description,
670             'entries': pl,
671         }