]>
Commit | Line | Data |
---|---|---|
3f0852e3 RSK |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
81acad12 | 3 | ExtractorError, |
3f0852e3 | 4 | int_or_none, |
a3eb987e | 5 | str_or_none, |
1418a043 | 6 | js_to_json, |
81acad12 | 7 | parse_filesize, |
1418a043 | 8 | urlencode_postdata, |
eb0f9d68 | 9 | urljoin, |
3f0852e3 RSK |
10 | ) |
11 | ||
12 | ||
366a7a47 | 13 | class ZoomIE(InfoExtractor): |
14 | IE_NAME = 'zoom' | |
1418a043 | 15 | _VALID_URL = r'(?P<base_url>https?://(?:[^.]+\.)?zoom.us/)rec(?:ording)?/(?:play|share)/(?P<id>[A-Za-z0-9_.-]+)' |
55cd2999 | 16 | _TEST = { |
1418a043 | 17 | 'url': 'https://economist.zoom.us/rec/play/dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5', |
18 | 'md5': 'ab445e8c911fddc4f9adc842c2c5d434', | |
3f0852e3 | 19 | 'info_dict': { |
1418a043 | 20 | 'id': 'dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5', |
21 | 'ext': 'mp4', | |
22 | 'title': 'China\'s "two sessions" and the new five-year plan', | |
a3eb987e T |
23 | }, |
24 | 'skip': 'Recording requires email authentication to access', | |
55cd2999 | 25 | } |
3f0852e3 RSK |
26 | |
27 | def _real_extract(self, url): | |
5ad28e7f | 28 | base_url, play_id = self._match_valid_url(url).groups() |
1418a043 | 29 | webpage = self._download_webpage(url, play_id) |
81acad12 | 30 | |
1418a043 | 31 | try: |
32 | form = self._form_hidden_inputs('password_form', webpage) | |
33 | except ExtractorError: | |
34 | form = None | |
35 | if form: | |
a06916d9 | 36 | password = self.get_param('videopassword') |
1418a043 | 37 | if not password: |
38 | raise ExtractorError( | |
39 | 'This video is protected by a passcode, use the --video-password option', expected=True) | |
40 | is_meeting = form.get('useWhichPasswd') == 'meeting' | |
41 | validation = self._download_json( | |
42 | base_url + 'rec/validate%s_passwd' % ('_meet' if is_meeting else ''), | |
43 | play_id, 'Validating passcode', 'Wrong passcode', data=urlencode_postdata({ | |
44 | 'id': form[('meet' if is_meeting else 'file') + 'Id'], | |
45 | 'passwd': password, | |
46 | 'action': form.get('action'), | |
47 | })) | |
48 | if not validation.get('status'): | |
49 | raise ExtractorError(validation['errorMessage'], expected=True) | |
50 | webpage = self._download_webpage(url, play_id) | |
3f0852e3 | 51 | |
1418a043 | 52 | data = self._parse_json(self._search_regex( |
53 | r'(?s)window\.__data__\s*=\s*({.+?});', | |
54 | webpage, 'data'), play_id, js_to_json) | |
3f0852e3 | 55 | |
eb0f9d68 | 56 | subtitles = {} |
a3eb987e | 57 | for _type in ('transcript', 'cc', 'chapter'): |
eb0f9d68 | 58 | if data.get('%sUrl' % _type): |
59 | subtitles[_type] = [{ | |
60 | 'url': urljoin(base_url, data['%sUrl' % _type]), | |
61 | 'ext': 'vtt', | |
62 | }] | |
63 | ||
a3eb987e T |
64 | formats = [] |
65 | ||
66 | if data.get('viewMp4Url'): | |
67 | formats.append({ | |
68 | 'format_note': 'Camera stream', | |
69 | 'url': str_or_none(data.get('viewMp4Url')), | |
70 | 'width': int_or_none(data.get('viewResolvtionsWidth')), | |
71 | 'height': int_or_none(data.get('viewResolvtionsHeight')), | |
72 | 'format_id': str_or_none(data.get('recordingId')), | |
73 | 'ext': 'mp4', | |
74 | 'filesize_approx': parse_filesize(data.get('fileSize')), | |
75 | 'preference': 0 | |
76 | }) | |
77 | ||
78 | if data.get('shareMp4Url'): | |
79 | formats.append({ | |
80 | 'format_note': 'Screen share stream', | |
81 | 'url': str_or_none(data.get('shareMp4Url')), | |
82 | 'width': int_or_none(data.get('shareResolvtionsWidth')), | |
83 | 'height': int_or_none(data.get('shareResolvtionsHeight')), | |
84 | 'format_id': str_or_none(data.get('shareVideoId')), | |
85 | 'ext': 'mp4', | |
86 | 'preference': -1 | |
87 | }) | |
88 | ||
89 | self._sort_formats(formats) | |
90 | ||
3f0852e3 | 91 | return { |
1418a043 | 92 | 'id': play_id, |
a3eb987e | 93 | 'title': data.get('topic'), |
eb0f9d68 | 94 | 'subtitles': subtitles, |
a3eb987e | 95 | 'formats': formats, |
1418a043 | 96 | 'http_headers': { |
97 | 'Referer': base_url, | |
98 | }, | |
55cd2999 | 99 | } |