logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

vimeo.py (47781B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import base64
  4. import functools
  5. import re
  6. import itertools
  7. from .common import InfoExtractor
  8. from ..compat import (
  9. compat_kwargs,
  10. compat_HTTPError,
  11. compat_str,
  12. compat_urlparse,
  13. )
  14. from ..utils import (
  15. clean_html,
  16. determine_ext,
  17. ExtractorError,
  18. get_element_by_class,
  19. js_to_json,
  20. int_or_none,
  21. merge_dicts,
  22. OnDemandPagedList,
  23. parse_filesize,
  24. parse_iso8601,
  25. sanitized_Request,
  26. smuggle_url,
  27. std_headers,
  28. str_or_none,
  29. try_get,
  30. unified_timestamp,
  31. unsmuggle_url,
  32. urlencode_postdata,
  33. urljoin,
  34. unescapeHTML,
  35. )
  36. class VimeoBaseInfoExtractor(InfoExtractor):
  37. _NETRC_MACHINE = 'vimeo'
  38. _LOGIN_REQUIRED = False
  39. _LOGIN_URL = 'https://vimeo.com/log_in'
  40. def _login(self):
  41. username, password = self._get_login_info()
  42. if username is None:
  43. if self._LOGIN_REQUIRED:
  44. raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
  45. return
  46. webpage = self._download_webpage(
  47. self._LOGIN_URL, None, 'Downloading login page')
  48. token, vuid = self._extract_xsrft_and_vuid(webpage)
  49. data = {
  50. 'action': 'login',
  51. 'email': username,
  52. 'password': password,
  53. 'service': 'vimeo',
  54. 'token': token,
  55. }
  56. self._set_vimeo_cookie('vuid', vuid)
  57. try:
  58. self._download_webpage(
  59. self._LOGIN_URL, None, 'Logging in',
  60. data=urlencode_postdata(data), headers={
  61. 'Content-Type': 'application/x-www-form-urlencoded',
  62. 'Referer': self._LOGIN_URL,
  63. })
  64. except ExtractorError as e:
  65. if isinstance(e.cause, compat_HTTPError) and e.cause.code == 418:
  66. raise ExtractorError(
  67. 'Unable to log in: bad username or password',
  68. expected=True)
  69. raise ExtractorError('Unable to log in')
  70. def _get_video_password(self):
  71. password = self._downloader.params.get('videopassword')
  72. if password is None:
  73. raise ExtractorError(
  74. 'This video is protected by a password, use the --video-password option',
  75. expected=True)
  76. return password
  77. def _verify_video_password(self, url, video_id, password, token, vuid):
  78. if url.startswith('http://'):
  79. # vimeo only supports https now, but the user can give an http url
  80. url = url.replace('http://', 'https://')
  81. self._set_vimeo_cookie('vuid', vuid)
  82. return self._download_webpage(
  83. url + '/password', video_id, 'Verifying the password',
  84. 'Wrong password', data=urlencode_postdata({
  85. 'password': password,
  86. 'token': token,
  87. }), headers={
  88. 'Content-Type': 'application/x-www-form-urlencoded',
  89. 'Referer': url,
  90. })
  91. def _extract_xsrft_and_vuid(self, webpage):
  92. xsrft = self._search_regex(
  93. r'(?:(?P<q1>["\'])xsrft(?P=q1)\s*:|xsrft\s*[=:])\s*(?P<q>["\'])(?P<xsrft>.+?)(?P=q)',
  94. webpage, 'login token', group='xsrft')
  95. vuid = self._search_regex(
  96. r'["\']vuid["\']\s*:\s*(["\'])(?P<vuid>.+?)\1',
  97. webpage, 'vuid', group='vuid')
  98. return xsrft, vuid
  99. def _extract_vimeo_config(self, webpage, video_id, *args, **kwargs):
  100. vimeo_config = self._search_regex(
  101. r'vimeo\.config\s*=\s*(?:({.+?})|_extend\([^,]+,\s+({.+?})\));',
  102. webpage, 'vimeo config', *args, **compat_kwargs(kwargs))
  103. if vimeo_config:
  104. return self._parse_json(vimeo_config, video_id)
  105. def _set_vimeo_cookie(self, name, value):
  106. self._set_cookie('vimeo.com', name, value)
  107. def _vimeo_sort_formats(self, formats):
  108. # Bitrates are completely broken. Single m3u8 may contain entries in kbps and bps
  109. # at the same time without actual units specified. This lead to wrong sorting.
  110. self._sort_formats(formats, field_preference=('preference', 'height', 'width', 'fps', 'tbr', 'format_id'))
  111. def _parse_config(self, config, video_id):
  112. video_data = config['video']
  113. video_title = video_data['title']
  114. live_event = video_data.get('live_event') or {}
  115. is_live = live_event.get('status') == 'started'
  116. request = config.get('request') or {}
  117. formats = []
  118. config_files = video_data.get('files') or request.get('files') or {}
  119. for f in (config_files.get('progressive') or []):
  120. video_url = f.get('url')
  121. if not video_url:
  122. continue
  123. formats.append({
  124. 'url': video_url,
  125. 'format_id': 'http-%s' % f.get('quality'),
  126. 'width': int_or_none(f.get('width')),
  127. 'height': int_or_none(f.get('height')),
  128. 'fps': int_or_none(f.get('fps')),
  129. 'tbr': int_or_none(f.get('bitrate')),
  130. })
  131. # TODO: fix handling of 308 status code returned for live archive manifest requests
  132. sep_pattern = r'/sep/video/'
  133. for files_type in ('hls', 'dash'):
  134. for cdn_name, cdn_data in (try_get(config_files, lambda x: x[files_type]['cdns']) or {}).items():
  135. manifest_url = cdn_data.get('url')
  136. if not manifest_url:
  137. continue
  138. format_id = '%s-%s' % (files_type, cdn_name)
  139. sep_manifest_urls = []
  140. if re.search(sep_pattern, manifest_url):
  141. for suffix, repl in (('', 'video'), ('_sep', 'sep/video')):
  142. sep_manifest_urls.append((format_id + suffix, re.sub(
  143. sep_pattern, '/%s/' % repl, manifest_url)))
  144. else:
  145. sep_manifest_urls = [(format_id, manifest_url)]
  146. for f_id, m_url in sep_manifest_urls:
  147. if files_type == 'hls':
  148. formats.extend(self._extract_m3u8_formats(
  149. m_url, video_id, 'mp4',
  150. 'm3u8' if is_live else 'm3u8_native', m3u8_id=f_id,
  151. note='Downloading %s m3u8 information' % cdn_name,
  152. fatal=False))
  153. elif files_type == 'dash':
  154. if 'json=1' in m_url:
  155. real_m_url = (self._download_json(m_url, video_id, fatal=False) or {}).get('url')
  156. if real_m_url:
  157. m_url = real_m_url
  158. mpd_formats = self._extract_mpd_formats(
  159. m_url.replace('/master.json', '/master.mpd'), video_id, f_id,
  160. 'Downloading %s MPD information' % cdn_name,
  161. fatal=False)
  162. formats.extend(mpd_formats)
  163. live_archive = live_event.get('archive') or {}
  164. live_archive_source_url = live_archive.get('source_url')
  165. if live_archive_source_url and live_archive.get('status') == 'done':
  166. formats.append({
  167. 'format_id': 'live-archive-source',
  168. 'url': live_archive_source_url,
  169. 'preference': 1,
  170. })
  171. for f in formats:
  172. if f.get('vcodec') == 'none':
  173. f['preference'] = -50
  174. elif f.get('acodec') == 'none':
  175. f['preference'] = -40
  176. subtitles = {}
  177. for tt in (request.get('text_tracks') or []):
  178. subtitles[tt['lang']] = [{
  179. 'ext': 'vtt',
  180. 'url': urljoin('https://vimeo.com', tt['url']),
  181. }]
  182. thumbnails = []
  183. if not is_live:
  184. for key, thumb in (video_data.get('thumbs') or {}).items():
  185. thumbnails.append({
  186. 'id': key,
  187. 'width': int_or_none(key),
  188. 'url': thumb,
  189. })
  190. thumbnail = video_data.get('thumbnail')
  191. if thumbnail:
  192. thumbnails.append({
  193. 'url': thumbnail,
  194. })
  195. owner = video_data.get('owner') or {}
  196. video_uploader_url = owner.get('url')
  197. return {
  198. 'id': str_or_none(video_data.get('id')) or video_id,
  199. 'title': self._live_title(video_title) if is_live else video_title,
  200. 'uploader': owner.get('name'),
  201. 'uploader_id': video_uploader_url.split('/')[-1] if video_uploader_url else None,
  202. 'uploader_url': video_uploader_url,
  203. 'thumbnails': thumbnails,
  204. 'duration': int_or_none(video_data.get('duration')),
  205. 'formats': formats,
  206. 'subtitles': subtitles,
  207. 'is_live': is_live,
  208. }
  209. def _extract_original_format(self, url, video_id, unlisted_hash=None):
  210. query = {'action': 'load_download_config'}
  211. if unlisted_hash:
  212. query['unlisted_hash'] = unlisted_hash
  213. download_data = self._download_json(
  214. url, video_id, fatal=False, query=query,
  215. headers={'X-Requested-With': 'XMLHttpRequest'})
  216. if download_data:
  217. source_file = download_data.get('source_file')
  218. if isinstance(source_file, dict):
  219. download_url = source_file.get('download_url')
  220. if download_url and not source_file.get('is_cold') and not source_file.get('is_defrosting'):
  221. source_name = source_file.get('public_name', 'Original')
  222. if self._is_valid_url(download_url, video_id, '%s video' % source_name):
  223. ext = (try_get(
  224. source_file, lambda x: x['extension'],
  225. compat_str) or determine_ext(
  226. download_url, None) or 'mp4').lower()
  227. return {
  228. 'url': download_url,
  229. 'ext': ext,
  230. 'width': int_or_none(source_file.get('width')),
  231. 'height': int_or_none(source_file.get('height')),
  232. 'filesize': parse_filesize(source_file.get('size')),
  233. 'format_id': source_name,
  234. 'preference': 1,
  235. }
  236. class VimeoIE(VimeoBaseInfoExtractor):
  237. """Information extractor for vimeo.com."""
  238. # _VALID_URL matches Vimeo URLs
  239. _VALID_URL = r'''(?x)
  240. https?://
  241. (?:
  242. (?:
  243. www|
  244. player
  245. )
  246. \.
  247. )?
  248. vimeo(?:pro)?\.com/
  249. (?!(?:channels|album|showcase)/[^/?#]+/?(?:$|[?#])|[^/]+/review/|ondemand/)
  250. (?:.*?/)??
  251. (?:
  252. (?:
  253. play_redirect_hls|
  254. moogaloop\.swf)\?clip_id=
  255. )?
  256. (?:videos?/)?
  257. (?P<id>[0-9]+)
  258. (?:/(?P<unlisted_hash>[\da-f]{10}))?
  259. /?(?:[?&].*)?(?:[#].*)?$
  260. '''
  261. IE_NAME = 'vimeo'
  262. _TESTS = [
  263. {
  264. 'url': 'http://vimeo.com/56015672#at=0',
  265. 'md5': '8879b6cc097e987f02484baf890129e5',
  266. 'info_dict': {
  267. 'id': '56015672',
  268. 'ext': 'mp4',
  269. 'title': "youtube-dl test video - \u2605 \" ' \u5e78 / \\ \u00e4 \u21ad \U0001d550",
  270. 'description': 'md5:2d3305bad981a06ff79f027f19865021',
  271. 'timestamp': 1355990239,
  272. 'upload_date': '20121220',
  273. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user7108434',
  274. 'uploader_id': 'user7108434',
  275. 'uploader': 'Filippo Valsorda',
  276. 'duration': 10,
  277. 'license': 'by-sa',
  278. },
  279. 'params': {
  280. 'format': 'best[protocol=https]',
  281. },
  282. },
  283. {
  284. 'url': 'http://vimeopro.com/openstreetmapus/state-of-the-map-us-2013/video/68093876',
  285. 'md5': '3b5ca6aa22b60dfeeadf50b72e44ed82',
  286. 'note': 'Vimeo Pro video (#1197)',
  287. 'info_dict': {
  288. 'id': '68093876',
  289. 'ext': 'mp4',
  290. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/openstreetmapus',
  291. 'uploader_id': 'openstreetmapus',
  292. 'uploader': 'OpenStreetMap US',
  293. 'title': 'Andy Allan - Putting the Carto into OpenStreetMap Cartography',
  294. 'description': 'md5:2c362968038d4499f4d79f88458590c1',
  295. 'duration': 1595,
  296. 'upload_date': '20130610',
  297. 'timestamp': 1370893156,
  298. 'license': 'by',
  299. },
  300. 'params': {
  301. 'format': 'best[protocol=https]',
  302. },
  303. },
  304. {
  305. 'url': 'http://player.vimeo.com/video/54469442',
  306. 'md5': '619b811a4417aa4abe78dc653becf511',
  307. 'note': 'Videos that embed the url in the player page',
  308. 'info_dict': {
  309. 'id': '54469442',
  310. 'ext': 'mp4',
  311. 'title': 'Kathy Sierra: Building the minimum Badass User, Business of Software 2012',
  312. 'uploader': 'Business of Software',
  313. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/businessofsoftware',
  314. 'uploader_id': 'businessofsoftware',
  315. 'duration': 3610,
  316. 'description': None,
  317. },
  318. 'params': {
  319. 'format': 'best[protocol=https]',
  320. },
  321. 'expected_warnings': ['Unable to download JSON metadata'],
  322. },
  323. {
  324. 'url': 'http://vimeo.com/68375962',
  325. 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
  326. 'note': 'Video protected with password',
  327. 'info_dict': {
  328. 'id': '68375962',
  329. 'ext': 'mp4',
  330. 'title': 'youtube-dl password protected test video',
  331. 'timestamp': 1371200155,
  332. 'upload_date': '20130614',
  333. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128',
  334. 'uploader_id': 'user18948128',
  335. 'uploader': 'Jaime Marquínez Ferrándiz',
  336. 'duration': 10,
  337. 'description': 'md5:dca3ea23adb29ee387127bc4ddfce63f',
  338. },
  339. 'params': {
  340. 'format': 'best[protocol=https]',
  341. 'videopassword': 'youtube-dl',
  342. },
  343. },
  344. {
  345. 'url': 'http://vimeo.com/channels/keypeele/75629013',
  346. 'md5': '2f86a05afe9d7abc0b9126d229bbe15d',
  347. 'info_dict': {
  348. 'id': '75629013',
  349. 'ext': 'mp4',
  350. 'title': 'Key & Peele: Terrorist Interrogation',
  351. 'description': 'md5:8678b246399b070816b12313e8b4eb5c',
  352. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/atencio',
  353. 'uploader_id': 'atencio',
  354. 'uploader': 'Peter Atencio',
  355. 'channel_id': 'keypeele',
  356. 'channel_url': r're:https?://(?:www\.)?vimeo\.com/channels/keypeele',
  357. 'timestamp': 1380339469,
  358. 'upload_date': '20130928',
  359. 'duration': 187,
  360. },
  361. 'expected_warnings': ['Unable to download JSON metadata'],
  362. },
  363. {
  364. 'url': 'http://vimeo.com/76979871',
  365. 'note': 'Video with subtitles',
  366. 'info_dict': {
  367. 'id': '76979871',
  368. 'ext': 'mp4',
  369. 'title': 'The New Vimeo Player (You Know, For Videos)',
  370. 'description': 'md5:2ec900bf97c3f389378a96aee11260ea',
  371. 'timestamp': 1381846109,
  372. 'upload_date': '20131015',
  373. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/staff',
  374. 'uploader_id': 'staff',
  375. 'uploader': 'Vimeo Staff',
  376. 'duration': 62,
  377. 'subtitles': {
  378. 'de': [{'ext': 'vtt'}],
  379. 'en': [{'ext': 'vtt'}],
  380. 'es': [{'ext': 'vtt'}],
  381. 'fr': [{'ext': 'vtt'}],
  382. },
  383. }
  384. },
  385. {
  386. # from https://www.ouya.tv/game/Pier-Solar-and-the-Great-Architects/
  387. 'url': 'https://player.vimeo.com/video/98044508',
  388. 'note': 'The js code contains assignments to the same variable as the config',
  389. 'info_dict': {
  390. 'id': '98044508',
  391. 'ext': 'mp4',
  392. 'title': 'Pier Solar OUYA Official Trailer',
  393. 'uploader': 'Tulio Gonçalves',
  394. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user28849593',
  395. 'uploader_id': 'user28849593',
  396. },
  397. },
  398. {
  399. # contains original format
  400. 'url': 'https://vimeo.com/33951933',
  401. 'md5': '53c688fa95a55bf4b7293d37a89c5c53',
  402. 'info_dict': {
  403. 'id': '33951933',
  404. 'ext': 'mp4',
  405. 'title': 'FOX CLASSICS - Forever Classic ID - A Full Minute',
  406. 'uploader': 'The DMCI',
  407. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/dmci',
  408. 'uploader_id': 'dmci',
  409. 'timestamp': 1324343742,
  410. 'upload_date': '20111220',
  411. 'description': 'md5:ae23671e82d05415868f7ad1aec21147',
  412. },
  413. },
  414. {
  415. # only available via https://vimeo.com/channels/tributes/6213729 and
  416. # not via https://vimeo.com/6213729
  417. 'url': 'https://vimeo.com/channels/tributes/6213729',
  418. 'info_dict': {
  419. 'id': '6213729',
  420. 'ext': 'mp4',
  421. 'title': 'Vimeo Tribute: The Shining',
  422. 'uploader': 'Casey Donahue',
  423. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/caseydonahue',
  424. 'uploader_id': 'caseydonahue',
  425. 'channel_url': r're:https?://(?:www\.)?vimeo\.com/channels/tributes',
  426. 'channel_id': 'tributes',
  427. 'timestamp': 1250886430,
  428. 'upload_date': '20090821',
  429. 'description': 'md5:bdbf314014e58713e6e5b66eb252f4a6',
  430. },
  431. 'params': {
  432. 'skip_download': True,
  433. },
  434. 'expected_warnings': ['Unable to download JSON metadata'],
  435. },
  436. {
  437. # redirects to ondemand extractor and should be passed through it
  438. # for successful extraction
  439. 'url': 'https://vimeo.com/73445910',
  440. 'info_dict': {
  441. 'id': '73445910',
  442. 'ext': 'mp4',
  443. 'title': 'The Reluctant Revolutionary',
  444. 'uploader': '10Ft Films',
  445. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/tenfootfilms',
  446. 'uploader_id': 'tenfootfilms',
  447. 'description': 'md5:0fa704e05b04f91f40b7f3ca2e801384',
  448. 'upload_date': '20130830',
  449. 'timestamp': 1377853339,
  450. },
  451. 'params': {
  452. 'skip_download': True,
  453. },
  454. 'expected_warnings': ['Unable to download JSON metadata'],
  455. 'skip': 'this page is no longer available.',
  456. },
  457. {
  458. 'url': 'http://player.vimeo.com/video/68375962',
  459. 'md5': 'aaf896bdb7ddd6476df50007a0ac0ae7',
  460. 'info_dict': {
  461. 'id': '68375962',
  462. 'ext': 'mp4',
  463. 'title': 'youtube-dl password protected test video',
  464. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/user18948128',
  465. 'uploader_id': 'user18948128',
  466. 'uploader': 'Jaime Marquínez Ferrándiz',
  467. 'duration': 10,
  468. },
  469. 'params': {
  470. 'format': 'best[protocol=https]',
  471. 'videopassword': 'youtube-dl',
  472. },
  473. },
  474. {
  475. 'url': 'http://vimeo.com/moogaloop.swf?clip_id=2539741',
  476. 'only_matching': True,
  477. },
  478. {
  479. 'url': 'https://vimeo.com/109815029',
  480. 'note': 'Video not completely processed, "failed" seed status',
  481. 'only_matching': True,
  482. },
  483. {
  484. 'url': 'https://vimeo.com/groups/travelhd/videos/22439234',
  485. 'only_matching': True,
  486. },
  487. {
  488. 'url': 'https://vimeo.com/album/2632481/video/79010983',
  489. 'only_matching': True,
  490. },
  491. {
  492. # source file returns 403: Forbidden
  493. 'url': 'https://vimeo.com/7809605',
  494. 'only_matching': True,
  495. },
  496. {
  497. # requires passing unlisted_hash(a52724358e) to load_download_config request
  498. 'url': 'https://vimeo.com/392479337/a52724358e',
  499. 'only_matching': True,
  500. },
  501. {
  502. # similar, but all numeric: ID must be 581039021, not 9603038895
  503. # issue #29690
  504. 'url': 'https://vimeo.com/581039021/9603038895',
  505. 'info_dict': {
  506. 'id': '581039021',
  507. # these have to be provided but we don't care
  508. 'ext': 'mp4',
  509. 'timestamp': 1627621014,
  510. 'title': 're:.+',
  511. 'uploader_id': 're:.+',
  512. 'uploader': 're:.+',
  513. 'upload_date': r're:\d+',
  514. },
  515. 'params': {
  516. 'skip_download': True,
  517. },
  518. }
  519. # https://gettingthingsdone.com/workflowmap/
  520. # vimeo embed with check-password page protected by Referer header
  521. ]
  522. @staticmethod
  523. def _smuggle_referrer(url, referrer_url):
  524. return smuggle_url(url, {'http_headers': {'Referer': referrer_url}})
  525. @staticmethod
  526. def _extract_urls(url, webpage):
  527. urls = []
  528. # Look for embedded (iframe) Vimeo player
  529. for mobj in re.finditer(
  530. r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//player\.vimeo\.com/video/\d+.*?)\1',
  531. webpage):
  532. urls.append(VimeoIE._smuggle_referrer(unescapeHTML(mobj.group('url')), url))
  533. PLAIN_EMBED_RE = (
  534. # Look for embedded (swf embed) Vimeo player
  535. r'<embed[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/moogaloop\.swf.+?)\1',
  536. # Look more for non-standard embedded Vimeo player
  537. r'<video[^>]+src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?vimeo\.com/[0-9]+)\1',
  538. )
  539. for embed_re in PLAIN_EMBED_RE:
  540. for mobj in re.finditer(embed_re, webpage):
  541. urls.append(mobj.group('url'))
  542. return urls
  543. @staticmethod
  544. def _extract_url(url, webpage):
  545. urls = VimeoIE._extract_urls(url, webpage)
  546. return urls[0] if urls else None
  547. def _verify_player_video_password(self, url, video_id, headers):
  548. password = self._get_video_password()
  549. data = urlencode_postdata({
  550. 'password': base64.b64encode(password.encode()),
  551. })
  552. headers = merge_dicts(headers, {
  553. 'Content-Type': 'application/x-www-form-urlencoded',
  554. })
  555. checked = self._download_json(
  556. url + '/check-password', video_id,
  557. 'Verifying the password', data=data, headers=headers)
  558. if checked is False:
  559. raise ExtractorError('Wrong video password', expected=True)
  560. return checked
  561. def _real_initialize(self):
  562. self._login()
  563. def _extract_from_api(self, video_id, unlisted_hash=None):
  564. token = self._download_json(
  565. 'https://vimeo.com/_rv/jwt', video_id, headers={
  566. 'X-Requested-With': 'XMLHttpRequest'
  567. })['token']
  568. api_url = 'https://api.vimeo.com/videos/' + video_id
  569. if unlisted_hash:
  570. api_url += ':' + unlisted_hash
  571. video = self._download_json(
  572. api_url, video_id, headers={
  573. 'Authorization': 'jwt ' + token,
  574. }, query={
  575. 'fields': 'config_url,created_time,description,license,metadata.connections.comments.total,metadata.connections.likes.total,release_time,stats.plays',
  576. })
  577. info = self._parse_config(self._download_json(
  578. video['config_url'], video_id), video_id)
  579. self._vimeo_sort_formats(info['formats'])
  580. get_timestamp = lambda x: parse_iso8601(video.get(x + '_time'))
  581. info.update({
  582. 'description': video.get('description'),
  583. 'license': video.get('license'),
  584. 'release_timestamp': get_timestamp('release'),
  585. 'timestamp': get_timestamp('created'),
  586. 'view_count': int_or_none(try_get(video, lambda x: x['stats']['plays'])),
  587. })
  588. connections = try_get(
  589. video, lambda x: x['metadata']['connections'], dict) or {}
  590. for k in ('comment', 'like'):
  591. info[k + '_count'] = int_or_none(try_get(connections, lambda x: x[k + 's']['total']))
  592. return info
  593. def _real_extract(self, url):
  594. url, data = unsmuggle_url(url, {})
  595. headers = std_headers.copy()
  596. if 'http_headers' in data:
  597. headers.update(data['http_headers'])
  598. if 'Referer' not in headers:
  599. headers['Referer'] = url
  600. mobj = re.match(self._VALID_URL, url).groupdict()
  601. video_id, unlisted_hash = mobj['id'], mobj.get('unlisted_hash')
  602. if unlisted_hash:
  603. return self._extract_from_api(video_id, unlisted_hash)
  604. orig_url = url
  605. is_pro = 'vimeopro.com/' in url
  606. if is_pro:
  607. # some videos require portfolio_id to be present in player url
  608. # https://github.com/ytdl-org/youtube-dl/issues/20070
  609. url = self._extract_url(url, self._download_webpage(url, video_id))
  610. if not url:
  611. url = 'https://vimeo.com/' + video_id
  612. elif any(p in url for p in ('play_redirect_hls', 'moogaloop.swf')):
  613. url = 'https://vimeo.com/' + video_id
  614. try:
  615. # Retrieve video webpage to extract further information
  616. webpage, urlh = self._download_webpage_handle(
  617. url, video_id, headers=headers)
  618. redirect_url = urlh.geturl()
  619. except ExtractorError as ee:
  620. if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 403:
  621. errmsg = ee.cause.read()
  622. if b'Because of its privacy settings, this video cannot be played here' in errmsg:
  623. raise ExtractorError(
  624. 'Cannot download embed-only video without embedding '
  625. 'URL. Please call youtube-dl with the URL of the page '
  626. 'that embeds this video.',
  627. expected=True)
  628. raise
  629. if '//player.vimeo.com/video/' in url:
  630. config = self._parse_json(self._search_regex(
  631. r'\bconfig\s*=\s*({.+?})\s*;', webpage, 'info section'), video_id)
  632. if config.get('view') == 4:
  633. config = self._verify_player_video_password(
  634. redirect_url, video_id, headers)
  635. info = self._parse_config(config, video_id)
  636. self._vimeo_sort_formats(info['formats'])
  637. return info
  638. if re.search(r'<form[^>]+?id="pw_form"', webpage):
  639. video_password = self._get_video_password()
  640. token, vuid = self._extract_xsrft_and_vuid(webpage)
  641. webpage = self._verify_video_password(
  642. redirect_url, video_id, video_password, token, vuid)
  643. vimeo_config = self._extract_vimeo_config(webpage, video_id, default=None)
  644. if vimeo_config:
  645. seed_status = vimeo_config.get('seed_status') or {}
  646. if seed_status.get('state') == 'failed':
  647. raise ExtractorError(
  648. '%s said: %s' % (self.IE_NAME, seed_status['title']),
  649. expected=True)
  650. cc_license = None
  651. timestamp = None
  652. video_description = None
  653. info_dict = {}
  654. channel_id = self._search_regex(
  655. r'vimeo\.com/channels/([^/]+)', url, 'channel id', default=None)
  656. if channel_id:
  657. config_url = self._html_search_regex(
  658. r'\bdata-config-url="([^"]+)"', webpage, 'config URL')
  659. video_description = clean_html(get_element_by_class('description', webpage))
  660. info_dict.update({
  661. 'channel_id': channel_id,
  662. 'channel_url': 'https://vimeo.com/channels/' + channel_id,
  663. })
  664. else:
  665. page_config = self._parse_json(self._search_regex(
  666. r'vimeo\.(?:clip|vod_title)_page_config\s*=\s*({.+?});',
  667. webpage, 'page config', default='{}'), video_id, fatal=False)
  668. if not page_config:
  669. return self._extract_from_api(video_id)
  670. config_url = page_config['player']['config_url']
  671. cc_license = page_config.get('cc_license')
  672. clip = page_config.get('clip') or {}
  673. timestamp = clip.get('uploaded_on')
  674. video_description = clean_html(
  675. clip.get('description') or page_config.get('description_html_escaped'))
  676. config = self._download_json(config_url, video_id)
  677. video = config.get('video') or {}
  678. vod = video.get('vod') or {}
  679. def is_rented():
  680. if '>You rented this title.<' in webpage:
  681. return True
  682. if try_get(config, lambda x: x['user']['purchased']):
  683. return True
  684. for purchase_option in (vod.get('purchase_options') or []):
  685. if purchase_option.get('purchased'):
  686. return True
  687. label = purchase_option.get('label_string')
  688. if label and (label.startswith('You rented this') or label.endswith(' remaining')):
  689. return True
  690. return False
  691. if is_rented() and vod.get('is_trailer'):
  692. feature_id = vod.get('feature_id')
  693. if feature_id and not data.get('force_feature_id', False):
  694. return self.url_result(smuggle_url(
  695. 'https://player.vimeo.com/player/%s' % feature_id,
  696. {'force_feature_id': True}), 'Vimeo')
  697. if not video_description:
  698. video_description = self._html_search_meta(
  699. ['description', 'og:description', 'twitter:description'],
  700. webpage, default=None)
  701. if not video_description and is_pro:
  702. orig_webpage = self._download_webpage(
  703. orig_url, video_id,
  704. note='Downloading webpage for description',
  705. fatal=False)
  706. if orig_webpage:
  707. video_description = self._html_search_meta(
  708. 'description', orig_webpage, default=None)
  709. if not video_description:
  710. self._downloader.report_warning('Cannot find video description')
  711. if not timestamp:
  712. timestamp = self._search_regex(
  713. r'<time[^>]+datetime="([^"]+)"', webpage,
  714. 'timestamp', default=None)
  715. formats = []
  716. source_format = self._extract_original_format(
  717. 'https://vimeo.com/' + video_id, video_id, video.get('unlisted_hash'))
  718. if source_format:
  719. formats.append(source_format)
  720. info_dict_config = self._parse_config(config, video_id)
  721. formats.extend(info_dict_config['formats'])
  722. self._vimeo_sort_formats(formats)
  723. json_ld = self._search_json_ld(webpage, video_id, default={})
  724. if not cc_license:
  725. cc_license = self._search_regex(
  726. r'<link[^>]+rel=["\']license["\'][^>]+href=(["\'])(?P<license>(?:(?!\1).)+)\1',
  727. webpage, 'license', default=None, group='license')
  728. info_dict.update({
  729. 'formats': formats,
  730. 'timestamp': unified_timestamp(timestamp),
  731. 'description': video_description,
  732. 'webpage_url': url,
  733. 'license': cc_license,
  734. })
  735. return merge_dicts(info_dict, info_dict_config, json_ld)
  736. class VimeoOndemandIE(VimeoIE):
  737. IE_NAME = 'vimeo:ondemand'
  738. _VALID_URL = r'https?://(?:www\.)?vimeo\.com/ondemand/(?:[^/]+/)?(?P<id>[^/?#&]+)'
  739. _TESTS = [{
  740. # ondemand video not available via https://vimeo.com/id
  741. 'url': 'https://vimeo.com/ondemand/20704',
  742. 'md5': 'c424deda8c7f73c1dfb3edd7630e2f35',
  743. 'info_dict': {
  744. 'id': '105442900',
  745. 'ext': 'mp4',
  746. 'title': 'המעבדה - במאי יותם פלדמן',
  747. 'uploader': 'גם סרטים',
  748. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/gumfilms',
  749. 'uploader_id': 'gumfilms',
  750. 'description': 'md5:4c027c965e439de4baab621e48b60791',
  751. 'upload_date': '20140906',
  752. 'timestamp': 1410032453,
  753. },
  754. 'params': {
  755. 'format': 'best[protocol=https]',
  756. },
  757. 'expected_warnings': ['Unable to download JSON metadata'],
  758. }, {
  759. # requires Referer to be passed along with og:video:url
  760. 'url': 'https://vimeo.com/ondemand/36938/126682985',
  761. 'info_dict': {
  762. 'id': '126584684',
  763. 'ext': 'mp4',
  764. 'title': 'Rävlock, rätt läte på rätt plats',
  765. 'uploader': 'Lindroth & Norin',
  766. 'uploader_url': r're:https?://(?:www\.)?vimeo\.com/lindrothnorin',
  767. 'uploader_id': 'lindrothnorin',
  768. 'description': 'md5:c3c46a90529612c8279fb6af803fc0df',
  769. 'upload_date': '20150502',
  770. 'timestamp': 1430586422,
  771. },
  772. 'params': {
  773. 'skip_download': True,
  774. },
  775. 'expected_warnings': ['Unable to download JSON metadata'],
  776. }, {
  777. 'url': 'https://vimeo.com/ondemand/nazmaalik',
  778. 'only_matching': True,
  779. }, {
  780. 'url': 'https://vimeo.com/ondemand/141692381',
  781. 'only_matching': True,
  782. }, {
  783. 'url': 'https://vimeo.com/ondemand/thelastcolony/150274832',
  784. 'only_matching': True,
  785. }]
  786. class VimeoChannelIE(VimeoBaseInfoExtractor):
  787. IE_NAME = 'vimeo:channel'
  788. _VALID_URL = r'https://vimeo\.com/channels/(?P<id>[^/?#]+)/?(?:$|[?#])'
  789. _MORE_PAGES_INDICATOR = r'<a.+?rel="next"'
  790. _TITLE = None
  791. _TITLE_RE = r'<link rel="alternate"[^>]+?title="(.*?)"'
  792. _TESTS = [{
  793. 'url': 'https://vimeo.com/channels/tributes',
  794. 'info_dict': {
  795. 'id': 'tributes',
  796. 'title': 'Vimeo Tributes',
  797. },
  798. 'playlist_mincount': 25,
  799. }]
  800. _BASE_URL_TEMPL = 'https://vimeo.com/channels/%s'
  801. def _page_url(self, base_url, pagenum):
  802. return '%s/videos/page:%d/' % (base_url, pagenum)
  803. def _extract_list_title(self, webpage):
  804. return self._TITLE or self._html_search_regex(
  805. self._TITLE_RE, webpage, 'list title', fatal=False)
  806. def _title_and_entries(self, list_id, base_url):
  807. for pagenum in itertools.count(1):
  808. page_url = self._page_url(base_url, pagenum)
  809. webpage = self._download_webpage(
  810. page_url, list_id,
  811. 'Downloading page %s' % pagenum)
  812. if pagenum == 1:
  813. yield self._extract_list_title(webpage)
  814. # Try extracting href first since not all videos are available via
  815. # short https://vimeo.com/id URL (e.g. https://vimeo.com/channels/tributes/6213729)
  816. clips = re.findall(
  817. r'id="clip_(\d+)"[^>]*>\s*<a[^>]+href="(/(?:[^/]+/)*\1)(?:[^>]+\btitle="([^"]+)")?', webpage)
  818. if clips:
  819. for video_id, video_url, video_title in clips:
  820. yield self.url_result(
  821. compat_urlparse.urljoin(base_url, video_url),
  822. VimeoIE.ie_key(), video_id=video_id, video_title=video_title)
  823. # More relaxed fallback
  824. else:
  825. for video_id in re.findall(r'id=["\']clip_(\d+)', webpage):
  826. yield self.url_result(
  827. 'https://vimeo.com/%s' % video_id,
  828. VimeoIE.ie_key(), video_id=video_id)
  829. if re.search(self._MORE_PAGES_INDICATOR, webpage, re.DOTALL) is None:
  830. break
  831. def _extract_videos(self, list_id, base_url):
  832. title_and_entries = self._title_and_entries(list_id, base_url)
  833. list_title = next(title_and_entries)
  834. return self.playlist_result(title_and_entries, list_id, list_title)
  835. def _real_extract(self, url):
  836. channel_id = self._match_id(url)
  837. return self._extract_videos(channel_id, self._BASE_URL_TEMPL % channel_id)
  838. class VimeoUserIE(VimeoChannelIE):
  839. IE_NAME = 'vimeo:user'
  840. _VALID_URL = r'https://vimeo\.com/(?!(?:[0-9]+|watchlater)(?:$|[?#/]))(?P<id>[^/]+)(?:/videos|[#?]|$)'
  841. _TITLE_RE = r'<a[^>]+?class="user">([^<>]+?)</a>'
  842. _TESTS = [{
  843. 'url': 'https://vimeo.com/nkistudio/videos',
  844. 'info_dict': {
  845. 'title': 'Nki',
  846. 'id': 'nkistudio',
  847. },
  848. 'playlist_mincount': 66,
  849. }]
  850. _BASE_URL_TEMPL = 'https://vimeo.com/%s'
  851. class VimeoAlbumIE(VimeoBaseInfoExtractor):
  852. IE_NAME = 'vimeo:album'
  853. _VALID_URL = r'https://vimeo\.com/(?:album|showcase)/(?P<id>\d+)(?:$|[?#]|/(?!video))'
  854. _TITLE_RE = r'<header id="page_header">\n\s*<h1>(.*?)</h1>'
  855. _TESTS = [{
  856. 'url': 'https://vimeo.com/album/2632481',
  857. 'info_dict': {
  858. 'id': '2632481',
  859. 'title': 'Staff Favorites: November 2013',
  860. },
  861. 'playlist_mincount': 13,
  862. }, {
  863. 'note': 'Password-protected album',
  864. 'url': 'https://vimeo.com/album/3253534',
  865. 'info_dict': {
  866. 'title': 'test',
  867. 'id': '3253534',
  868. },
  869. 'playlist_count': 1,
  870. 'params': {
  871. 'videopassword': 'youtube-dl',
  872. }
  873. }]
  874. _PAGE_SIZE = 100
  875. def _fetch_page(self, album_id, authorization, hashed_pass, page):
  876. api_page = page + 1
  877. query = {
  878. 'fields': 'link,uri',
  879. 'page': api_page,
  880. 'per_page': self._PAGE_SIZE,
  881. }
  882. if hashed_pass:
  883. query['_hashed_pass'] = hashed_pass
  884. try:
  885. videos = self._download_json(
  886. 'https://api.vimeo.com/albums/%s/videos' % album_id,
  887. album_id, 'Downloading page %d' % api_page, query=query, headers={
  888. 'Authorization': 'jwt ' + authorization,
  889. })['data']
  890. except ExtractorError as e:
  891. if isinstance(e.cause, compat_HTTPError) and e.cause.code == 400:
  892. return
  893. for video in videos:
  894. link = video.get('link')
  895. if not link:
  896. continue
  897. uri = video.get('uri')
  898. video_id = self._search_regex(r'/videos/(\d+)', uri, 'video_id', default=None) if uri else None
  899. yield self.url_result(link, VimeoIE.ie_key(), video_id)
  900. def _real_extract(self, url):
  901. album_id = self._match_id(url)
  902. viewer = self._download_json(
  903. 'https://vimeo.com/_rv/viewer', album_id, fatal=False)
  904. if not viewer:
  905. webpage = self._download_webpage(url, album_id)
  906. viewer = self._parse_json(self._search_regex(
  907. r'bootstrap_data\s*=\s*({.+?})</script>',
  908. webpage, 'bootstrap data'), album_id)['viewer']
  909. jwt = viewer['jwt']
  910. album = self._download_json(
  911. 'https://api.vimeo.com/albums/' + album_id,
  912. album_id, headers={'Authorization': 'jwt ' + jwt},
  913. query={'fields': 'description,name,privacy'})
  914. hashed_pass = None
  915. if try_get(album, lambda x: x['privacy']['view']) == 'password':
  916. password = self._downloader.params.get('videopassword')
  917. if not password:
  918. raise ExtractorError(
  919. 'This album is protected by a password, use the --video-password option',
  920. expected=True)
  921. self._set_vimeo_cookie('vuid', viewer['vuid'])
  922. try:
  923. hashed_pass = self._download_json(
  924. 'https://vimeo.com/showcase/%s/auth' % album_id,
  925. album_id, 'Verifying the password', data=urlencode_postdata({
  926. 'password': password,
  927. 'token': viewer['xsrft'],
  928. }), headers={
  929. 'X-Requested-With': 'XMLHttpRequest',
  930. })['hashed_pass']
  931. except ExtractorError as e:
  932. if isinstance(e.cause, compat_HTTPError) and e.cause.code == 401:
  933. raise ExtractorError('Wrong password', expected=True)
  934. raise
  935. entries = OnDemandPagedList(functools.partial(
  936. self._fetch_page, album_id, jwt, hashed_pass), self._PAGE_SIZE)
  937. return self.playlist_result(
  938. entries, album_id, album.get('name'), album.get('description'))
  939. class VimeoGroupsIE(VimeoChannelIE):
  940. IE_NAME = 'vimeo:group'
  941. _VALID_URL = r'https://vimeo\.com/groups/(?P<id>[^/]+)(?:/(?!videos?/\d+)|$)'
  942. _TESTS = [{
  943. 'url': 'https://vimeo.com/groups/kattykay',
  944. 'info_dict': {
  945. 'id': 'kattykay',
  946. 'title': 'Katty Kay',
  947. },
  948. 'playlist_mincount': 27,
  949. }]
  950. _BASE_URL_TEMPL = 'https://vimeo.com/groups/%s'
  951. class VimeoReviewIE(VimeoBaseInfoExtractor):
  952. IE_NAME = 'vimeo:review'
  953. IE_DESC = 'Review pages on vimeo'
  954. _VALID_URL = r'(?P<url>https://vimeo\.com/[^/]+/review/(?P<id>[^/]+)/[0-9a-f]{10})'
  955. _TESTS = [{
  956. 'url': 'https://vimeo.com/user21297594/review/75524534/3c257a1b5d',
  957. 'md5': 'c507a72f780cacc12b2248bb4006d253',
  958. 'info_dict': {
  959. 'id': '75524534',
  960. 'ext': 'mp4',
  961. 'title': "DICK HARDWICK 'Comedian'",
  962. 'uploader': 'Richard Hardwick',
  963. 'uploader_id': 'user21297594',
  964. 'description': "Comedian Dick Hardwick's five minute demo filmed in front of a live theater audience.\nEdit by Doug Mattocks",
  965. },
  966. 'expected_warnings': ['Unable to download JSON metadata'],
  967. }, {
  968. 'note': 'video player needs Referer',
  969. 'url': 'https://vimeo.com/user22258446/review/91613211/13f927e053',
  970. 'md5': '6295fdab8f4bf6a002d058b2c6dce276',
  971. 'info_dict': {
  972. 'id': '91613211',
  973. 'ext': 'mp4',
  974. 'title': 're:(?i)^Death by dogma versus assembling agile . Sander Hoogendoorn',
  975. 'uploader': 'DevWeek Events',
  976. 'duration': 2773,
  977. 'thumbnail': r're:^https?://.*\.jpg$',
  978. 'uploader_id': 'user22258446',
  979. },
  980. 'skip': 'video gone',
  981. }, {
  982. 'note': 'Password protected',
  983. 'url': 'https://vimeo.com/user37284429/review/138823582/c4d865efde',
  984. 'info_dict': {
  985. 'id': '138823582',
  986. 'ext': 'mp4',
  987. 'title': 'EFFICIENT PICKUP MASTERCLASS MODULE 1',
  988. 'uploader': 'TMB',
  989. 'uploader_id': 'user37284429',
  990. },
  991. 'params': {
  992. 'videopassword': 'holygrail',
  993. },
  994. 'skip': 'video gone',
  995. }]
  996. def _real_initialize(self):
  997. self._login()
  998. def _real_extract(self, url):
  999. page_url, video_id = re.match(self._VALID_URL, url).groups()
  1000. data = self._download_json(
  1001. page_url.replace('/review/', '/review/data/'), video_id)
  1002. if data.get('isLocked') is True:
  1003. video_password = self._get_video_password()
  1004. viewer = self._download_json(
  1005. 'https://vimeo.com/_rv/viewer', video_id)
  1006. webpage = self._verify_video_password(
  1007. 'https://vimeo.com/' + video_id, video_id,
  1008. video_password, viewer['xsrft'], viewer['vuid'])
  1009. clip_page_config = self._parse_json(self._search_regex(
  1010. r'window\.vimeo\.clip_page_config\s*=\s*({.+?});',
  1011. webpage, 'clip page config'), video_id)
  1012. config_url = clip_page_config['player']['config_url']
  1013. clip_data = clip_page_config.get('clip') or {}
  1014. else:
  1015. clip_data = data['clipData']
  1016. config_url = clip_data['configUrl']
  1017. config = self._download_json(config_url, video_id)
  1018. info_dict = self._parse_config(config, video_id)
  1019. source_format = self._extract_original_format(
  1020. page_url + '/action', video_id)
  1021. if source_format:
  1022. info_dict['formats'].append(source_format)
  1023. self._vimeo_sort_formats(info_dict['formats'])
  1024. info_dict['description'] = clean_html(clip_data.get('description'))
  1025. return info_dict
  1026. class VimeoWatchLaterIE(VimeoChannelIE):
  1027. IE_NAME = 'vimeo:watchlater'
  1028. IE_DESC = 'Vimeo watch later list, "vimeowatchlater" keyword (requires authentication)'
  1029. _VALID_URL = r'https://vimeo\.com/(?:home/)?watchlater|:vimeowatchlater'
  1030. _TITLE = 'Watch Later'
  1031. _LOGIN_REQUIRED = True
  1032. _TESTS = [{
  1033. 'url': 'https://vimeo.com/watchlater',
  1034. 'only_matching': True,
  1035. }]
  1036. def _real_initialize(self):
  1037. self._login()
  1038. def _page_url(self, base_url, pagenum):
  1039. url = '%s/page:%d/' % (base_url, pagenum)
  1040. request = sanitized_Request(url)
  1041. # Set the header to get a partial html page with the ids,
  1042. # the normal page doesn't contain them.
  1043. request.add_header('X-Requested-With', 'XMLHttpRequest')
  1044. return request
  1045. def _real_extract(self, url):
  1046. return self._extract_videos('watchlater', 'https://vimeo.com/watchlater')
  1047. class VimeoLikesIE(VimeoChannelIE):
  1048. _VALID_URL = r'https://(?:www\.)?vimeo\.com/(?P<id>[^/]+)/likes/?(?:$|[?#]|sort:)'
  1049. IE_NAME = 'vimeo:likes'
  1050. IE_DESC = 'Vimeo user likes'
  1051. _TESTS = [{
  1052. 'url': 'https://vimeo.com/user755559/likes/',
  1053. 'playlist_mincount': 293,
  1054. 'info_dict': {
  1055. 'id': 'user755559',
  1056. 'title': 'urza’s Likes',
  1057. },
  1058. }, {
  1059. 'url': 'https://vimeo.com/stormlapse/likes',
  1060. 'only_matching': True,
  1061. }]
  1062. def _page_url(self, base_url, pagenum):
  1063. return '%s/page:%d/' % (base_url, pagenum)
  1064. def _real_extract(self, url):
  1065. user_id = self._match_id(url)
  1066. return self._extract_videos(user_id, 'https://vimeo.com/%s/likes' % user_id)
  1067. class VHXEmbedIE(VimeoBaseInfoExtractor):
  1068. IE_NAME = 'vhx:embed'
  1069. _VALID_URL = r'https?://embed\.vhx\.tv/videos/(?P<id>\d+)'
  1070. @staticmethod
  1071. def _extract_url(webpage):
  1072. mobj = re.search(
  1073. r'<iframe[^>]+src="(https?://embed\.vhx\.tv/videos/\d+[^"]*)"', webpage)
  1074. return unescapeHTML(mobj.group(1)) if mobj else None
  1075. def _real_extract(self, url):
  1076. video_id = self._match_id(url)
  1077. webpage = self._download_webpage(url, video_id)
  1078. config_url = self._parse_json(self._search_regex(
  1079. r'window\.OTTData\s*=\s*({.+})', webpage,
  1080. 'ott data'), video_id, js_to_json)['config_url']
  1081. config = self._download_json(config_url, video_id)
  1082. info = self._parse_config(config, video_id)
  1083. info['id'] = video_id
  1084. self._vimeo_sort_formats(info['formats'])
  1085. return info