]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | ExtractorError, | |
4 | int_or_none, | |
5 | str_or_none, | |
6 | js_to_json, | |
7 | parse_filesize, | |
8 | urlencode_postdata, | |
9 | urljoin, | |
10 | ) | |
11 | ||
12 | ||
13 | class ZoomIE(InfoExtractor): | |
14 | IE_NAME = 'zoom' | |
15 | _VALID_URL = r'(?P<base_url>https?://(?:[^.]+\.)?zoom.us/)rec(?:ording)?/(?:play|share)/(?P<id>[A-Za-z0-9_.-]+)' | |
16 | _TEST = { | |
17 | 'url': 'https://economist.zoom.us/rec/play/dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5', | |
18 | 'md5': 'ab445e8c911fddc4f9adc842c2c5d434', | |
19 | 'info_dict': { | |
20 | 'id': 'dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5', | |
21 | 'ext': 'mp4', | |
22 | 'title': 'China\'s "two sessions" and the new five-year plan', | |
23 | }, | |
24 | 'skip': 'Recording requires email authentication to access', | |
25 | } | |
26 | ||
27 | def _real_extract(self, url): | |
28 | base_url, play_id = self._match_valid_url(url).groups() | |
29 | webpage = self._download_webpage(url, play_id) | |
30 | ||
31 | try: | |
32 | form = self._form_hidden_inputs('password_form', webpage) | |
33 | except ExtractorError: | |
34 | form = None | |
35 | if form: | |
36 | password = self.get_param('videopassword') | |
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) | |
51 | ||
52 | data = self._parse_json(self._search_regex( | |
53 | r'(?s)window\.__data__\s*=\s*({.+?});', | |
54 | webpage, 'data'), play_id, js_to_json) | |
55 | ||
56 | subtitles = {} | |
57 | for _type in ('transcript', 'cc', 'chapter'): | |
58 | if data.get('%sUrl' % _type): | |
59 | subtitles[_type] = [{ | |
60 | 'url': urljoin(base_url, data['%sUrl' % _type]), | |
61 | 'ext': 'vtt', | |
62 | }] | |
63 | ||
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 | return { | |
90 | 'id': play_id, | |
91 | 'title': data.get('topic'), | |
92 | 'subtitles': subtitles, | |
93 | 'formats': formats, | |
94 | 'http_headers': { | |
95 | 'Referer': base_url, | |
96 | }, | |
97 | } |