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