]>
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, |
1418a043 | 9 | js_to_json, |
81acad12 | 10 | parse_filesize, |
1418a043 | 11 | urlencode_postdata, |
eb0f9d68 | 12 | urljoin, |
3f0852e3 RSK |
13 | ) |
14 | ||
15 | ||
366a7a47 | 16 | class ZoomIE(InfoExtractor): |
17 | IE_NAME = 'zoom' | |
1418a043 | 18 | _VALID_URL = r'(?P<base_url>https?://(?:[^.]+\.)?zoom.us/)rec(?:ording)?/(?:play|share)/(?P<id>[A-Za-z0-9_.-]+)' |
55cd2999 | 19 | _TEST = { |
1418a043 | 20 | 'url': 'https://economist.zoom.us/rec/play/dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5', |
21 | 'md5': 'ab445e8c911fddc4f9adc842c2c5d434', | |
3f0852e3 | 22 | 'info_dict': { |
1418a043 | 23 | 'id': 'dUk_CNBETmZ5VA2BwEl-jjakPpJ3M1pcfVYAPRsoIbEByGsLjUZtaa4yCATQuOL3der8BlTwxQePl_j0.EImBkXzTIaPvdZO5', |
24 | 'ext': 'mp4', | |
25 | 'title': 'China\'s "two sessions" and the new five-year plan', | |
3f0852e3 | 26 | } |
55cd2999 | 27 | } |
3f0852e3 RSK |
28 | |
29 | def _real_extract(self, url): | |
5ad28e7f | 30 | base_url, play_id = self._match_valid_url(url).groups() |
1418a043 | 31 | webpage = self._download_webpage(url, play_id) |
81acad12 | 32 | |
1418a043 | 33 | try: |
34 | form = self._form_hidden_inputs('password_form', webpage) | |
35 | except ExtractorError: | |
36 | form = None | |
37 | if form: | |
a06916d9 | 38 | password = self.get_param('videopassword') |
1418a043 | 39 | if not password: |
40 | raise ExtractorError( | |
41 | 'This video is protected by a passcode, use the --video-password option', expected=True) | |
42 | is_meeting = form.get('useWhichPasswd') == 'meeting' | |
43 | validation = self._download_json( | |
44 | base_url + 'rec/validate%s_passwd' % ('_meet' if is_meeting else ''), | |
45 | play_id, 'Validating passcode', 'Wrong passcode', data=urlencode_postdata({ | |
46 | 'id': form[('meet' if is_meeting else 'file') + 'Id'], | |
47 | 'passwd': password, | |
48 | 'action': form.get('action'), | |
49 | })) | |
50 | if not validation.get('status'): | |
51 | raise ExtractorError(validation['errorMessage'], expected=True) | |
52 | webpage = self._download_webpage(url, play_id) | |
3f0852e3 | 53 | |
1418a043 | 54 | data = self._parse_json(self._search_regex( |
55 | r'(?s)window\.__data__\s*=\s*({.+?});', | |
56 | webpage, 'data'), play_id, js_to_json) | |
3f0852e3 | 57 | |
eb0f9d68 | 58 | subtitles = {} |
59 | for _type in ('transcript', 'cc'): | |
60 | if data.get('%sUrl' % _type): | |
61 | subtitles[_type] = [{ | |
62 | 'url': urljoin(base_url, data['%sUrl' % _type]), | |
63 | 'ext': 'vtt', | |
64 | }] | |
65 | ||
3f0852e3 | 66 | return { |
1418a043 | 67 | 'id': play_id, |
68 | 'title': data['topic'], | |
69 | 'url': data['viewMp4Url'], | |
eb0f9d68 | 70 | 'subtitles': subtitles, |
1418a043 | 71 | 'width': int_or_none(data.get('viewResolvtionsWidth')), |
72 | 'height': int_or_none(data.get('viewResolvtionsHeight')), | |
73 | 'http_headers': { | |
74 | 'Referer': base_url, | |
75 | }, | |
76 | 'filesize_approx': parse_filesize(data.get('fileSize')), | |
55cd2999 | 77 | } |