2020-04-12 21:27:58 +00:00
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
2020-04-20 14:20:54 +00:00
|
|
|
ExtractorError,
|
2020-04-12 21:27:58 +00:00
|
|
|
int_or_none,
|
2022-02-12 14:22:51 +00:00
|
|
|
str_or_none,
|
2021-03-24 22:32:37 +00:00
|
|
|
js_to_json,
|
2020-04-20 14:20:54 +00:00
|
|
|
parse_filesize,
|
2021-03-24 22:32:37 +00:00
|
|
|
urlencode_postdata,
|
2021-06-06 11:39:09 +00:00
|
|
|
urljoin,
|
2020-04-12 21:27:58 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-11-04 20:13:51 +00:00
|
|
|
class ZoomIE(InfoExtractor):
|
|
|
|
IE_NAME = 'zoom'
|
2021-03-24 22:32:37 +00:00
|
|
|
_VALID_URL = r'(?P<base_url>https?://(?:[^.]+\.)?zoom.us/)rec(?:ording)?/(?:play|share)/(?P<id>[A-Za-z0-9_.-]+)'
|
2020-04-12 22:18:40 +00:00
|
|
|
_TEST = {
|
2021-03-24 22:32:37 +00:00
|
|
|
'url': 'https://economist.zoom.us/rec/play/dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5',
|
|
|
|
'md5': 'ab445e8c911fddc4f9adc842c2c5d434',
|
2020-04-12 21:27:58 +00:00
|
|
|
'info_dict': {
|
2021-03-24 22:32:37 +00:00
|
|
|
'id': 'dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'title': 'China\'s "two sessions" and the new five-year plan',
|
2022-02-12 14:22:51 +00:00
|
|
|
},
|
|
|
|
'skip': 'Recording requires email authentication to access',
|
2020-04-12 22:18:40 +00:00
|
|
|
}
|
2020-04-12 21:27:58 +00:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
2021-08-19 01:41:24 +00:00
|
|
|
base_url, play_id = self._match_valid_url(url).groups()
|
2021-03-24 22:32:37 +00:00
|
|
|
webpage = self._download_webpage(url, play_id)
|
2020-04-20 14:20:54 +00:00
|
|
|
|
2021-03-24 22:32:37 +00:00
|
|
|
try:
|
|
|
|
form = self._form_hidden_inputs('password_form', webpage)
|
|
|
|
except ExtractorError:
|
|
|
|
form = None
|
|
|
|
if form:
|
2021-05-17 12:23:08 +00:00
|
|
|
password = self.get_param('videopassword')
|
2021-03-24 22:32:37 +00:00
|
|
|
if not password:
|
|
|
|
raise ExtractorError(
|
|
|
|
'This video is protected by a passcode, use the --video-password option', expected=True)
|
|
|
|
is_meeting = form.get('useWhichPasswd') == 'meeting'
|
|
|
|
validation = self._download_json(
|
|
|
|
base_url + 'rec/validate%s_passwd' % ('_meet' if is_meeting else ''),
|
|
|
|
play_id, 'Validating passcode', 'Wrong passcode', data=urlencode_postdata({
|
|
|
|
'id': form[('meet' if is_meeting else 'file') + 'Id'],
|
|
|
|
'passwd': password,
|
|
|
|
'action': form.get('action'),
|
|
|
|
}))
|
|
|
|
if not validation.get('status'):
|
|
|
|
raise ExtractorError(validation['errorMessage'], expected=True)
|
|
|
|
webpage = self._download_webpage(url, play_id)
|
2020-04-12 21:27:58 +00:00
|
|
|
|
2021-03-24 22:32:37 +00:00
|
|
|
data = self._parse_json(self._search_regex(
|
|
|
|
r'(?s)window\.__data__\s*=\s*({.+?});',
|
|
|
|
webpage, 'data'), play_id, js_to_json)
|
2020-04-12 21:27:58 +00:00
|
|
|
|
2021-06-06 11:39:09 +00:00
|
|
|
subtitles = {}
|
2022-02-12 14:22:51 +00:00
|
|
|
for _type in ('transcript', 'cc', 'chapter'):
|
2021-06-06 11:39:09 +00:00
|
|
|
if data.get('%sUrl' % _type):
|
|
|
|
subtitles[_type] = [{
|
|
|
|
'url': urljoin(base_url, data['%sUrl' % _type]),
|
|
|
|
'ext': 'vtt',
|
|
|
|
}]
|
|
|
|
|
2022-02-12 14:22:51 +00:00
|
|
|
formats = []
|
|
|
|
|
|
|
|
if data.get('viewMp4Url'):
|
|
|
|
formats.append({
|
|
|
|
'format_note': 'Camera stream',
|
|
|
|
'url': str_or_none(data.get('viewMp4Url')),
|
|
|
|
'width': int_or_none(data.get('viewResolvtionsWidth')),
|
|
|
|
'height': int_or_none(data.get('viewResolvtionsHeight')),
|
|
|
|
'format_id': str_or_none(data.get('recordingId')),
|
|
|
|
'ext': 'mp4',
|
|
|
|
'filesize_approx': parse_filesize(data.get('fileSize')),
|
|
|
|
'preference': 0
|
|
|
|
})
|
|
|
|
|
|
|
|
if data.get('shareMp4Url'):
|
|
|
|
formats.append({
|
|
|
|
'format_note': 'Screen share stream',
|
|
|
|
'url': str_or_none(data.get('shareMp4Url')),
|
|
|
|
'width': int_or_none(data.get('shareResolvtionsWidth')),
|
|
|
|
'height': int_or_none(data.get('shareResolvtionsHeight')),
|
|
|
|
'format_id': str_or_none(data.get('shareVideoId')),
|
|
|
|
'ext': 'mp4',
|
|
|
|
'preference': -1
|
|
|
|
})
|
|
|
|
|
2020-04-12 21:27:58 +00:00
|
|
|
return {
|
2021-03-24 22:32:37 +00:00
|
|
|
'id': play_id,
|
2022-02-12 14:22:51 +00:00
|
|
|
'title': data.get('topic'),
|
2021-06-06 11:39:09 +00:00
|
|
|
'subtitles': subtitles,
|
2022-02-12 14:22:51 +00:00
|
|
|
'formats': formats,
|
2021-03-24 22:32:37 +00:00
|
|
|
'http_headers': {
|
|
|
|
'Referer': base_url,
|
|
|
|
},
|
2020-04-12 22:18:40 +00:00
|
|
|
}
|