logo

youtube-dl

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

vimeo.py (48238B)


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