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