logo

youtube-dl

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

zoom.py (2658B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. import re
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. ExtractorError,
  7. int_or_none,
  8. js_to_json,
  9. parse_filesize,
  10. urlencode_postdata,
  11. )
  12. class ZoomIE(InfoExtractor):
  13. IE_NAME = 'zoom'
  14. _VALID_URL = r'(?P<base_url>https?://(?:[^.]+\.)?zoom.us/)rec(?:ording)?/(?:play|share)/(?P<id>[A-Za-z0-9_.-]+)'
  15. _TEST = {
  16. 'url': 'https://economist.zoom.us/rec/play/dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5',
  17. 'md5': 'ab445e8c911fddc4f9adc842c2c5d434',
  18. 'info_dict': {
  19. 'id': 'dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5',
  20. 'ext': 'mp4',
  21. 'title': 'China\'s "two sessions" and the new five-year plan',
  22. }
  23. }
  24. def _real_extract(self, url):
  25. base_url, play_id = re.match(self._VALID_URL, url).groups()
  26. webpage = self._download_webpage(url, play_id)
  27. try:
  28. form = self._form_hidden_inputs('password_form', webpage)
  29. except ExtractorError:
  30. form = None
  31. if form:
  32. password = self._downloader.params.get('videopassword')
  33. if not password:
  34. raise ExtractorError(
  35. 'This video is protected by a passcode, use the --video-password option', expected=True)
  36. is_meeting = form.get('useWhichPasswd') == 'meeting'
  37. validation = self._download_json(
  38. base_url + 'rec/validate%s_passwd' % ('_meet' if is_meeting else ''),
  39. play_id, 'Validating passcode', 'Wrong passcode', data=urlencode_postdata({
  40. 'id': form[('meet' if is_meeting else 'file') + 'Id'],
  41. 'passwd': password,
  42. 'action': form.get('action'),
  43. }))
  44. if not validation.get('status'):
  45. raise ExtractorError(validation['errorMessage'], expected=True)
  46. webpage = self._download_webpage(url, play_id)
  47. data = self._parse_json(self._search_regex(
  48. r'(?s)window\.__data__\s*=\s*({.+?});',
  49. webpage, 'data'), play_id, js_to_json)
  50. return {
  51. 'id': play_id,
  52. 'title': data['topic'],
  53. 'url': data['viewMp4Url'],
  54. 'width': int_or_none(data.get('viewResolvtionsWidth')),
  55. 'height': int_or_none(data.get('viewResolvtionsHeight')),
  56. 'http_headers': {
  57. 'Referer': base_url,
  58. },
  59. 'filesize_approx': parse_filesize(data.get('fileSize')),
  60. }