vimeo.py 23 KB

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