]>
Commit | Line | Data |
---|---|---|
3f0852e3 RSK |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
1418a043 | 4 | import re |
5 | ||
3f0852e3 RSK |
6 | from .common import InfoExtractor |
7 | from ..utils import ( | |
81acad12 | 8 | ExtractorError, |
3f0852e3 | 9 | int_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', | |
3f0852e3 | 27 | } |
55cd2999 | 28 | } |
3f0852e3 RSK |
29 | |
30 | def _real_extract(self, url): | |
1418a043 | 31 | base_url, play_id = re.match(self._VALID_URL, url).groups() |
32 | webpage = self._download_webpage(url, play_id) | |
81acad12 | 33 | |
1418a043 | 34 | try: |
35 | form = self._form_hidden_inputs('password_form', webpage) | |
36 | except ExtractorError: | |
37 | form = None | |
38 | if form: | |
a06916d9 | 39 | password = self.get_param('videopassword') |
1418a043 | 40 | if not password: |
41 | raise ExtractorError( | |
42 | 'This video is protected by a passcode, use the --video-password option', expected=True) | |
43 | is_meeting = form.get('useWhichPasswd') == 'meeting' | |
44 | validation = self._download_json( | |
45 | base_url + 'rec/validate%s_passwd' % ('_meet' if is_meeting else ''), | |
46 | play_id, 'Validating passcode', 'Wrong passcode', data=urlencode_postdata({ | |
47 | 'id': form[('meet' if is_meeting else 'file') + 'Id'], | |
48 | 'passwd': password, | |
49 | 'action': form.get('action'), | |
50 | })) | |
51 | if not validation.get('status'): | |
52 | raise ExtractorError(validation['errorMessage'], expected=True) | |
53 | webpage = self._download_webpage(url, play_id) | |
3f0852e3 | 54 | |
1418a043 | 55 | data = self._parse_json(self._search_regex( |
56 | r'(?s)window\.__data__\s*=\s*({.+?});', | |
57 | webpage, 'data'), play_id, js_to_json) | |
3f0852e3 | 58 | |
eb0f9d68 | 59 | subtitles = {} |
60 | for _type in ('transcript', 'cc'): | |
61 | if data.get('%sUrl' % _type): | |
62 | subtitles[_type] = [{ | |
63 | 'url': urljoin(base_url, data['%sUrl' % _type]), | |
64 | 'ext': 'vtt', | |
65 | }] | |
66 | ||
3f0852e3 | 67 | return { |
1418a043 | 68 | 'id': play_id, |
69 | 'title': data['topic'], | |
70 | 'url': data['viewMp4Url'], | |
eb0f9d68 | 71 | 'subtitles': subtitles, |
1418a043 | 72 | 'width': int_or_none(data.get('viewResolvtionsWidth')), |
73 | 'height': int_or_none(data.get('viewResolvtionsHeight')), | |
74 | 'http_headers': { | |
75 | 'Referer': base_url, | |
76 | }, | |
77 | 'filesize_approx': parse_filesize(data.get('fileSize')), | |
55cd2999 | 78 | } |