]>
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, |
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): | |
1418a043 | 30 | base_url, play_id = re.match(self._VALID_URL, url).groups() |
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 RSK |
57 | |
58 | return { | |
1418a043 | 59 | 'id': play_id, |
60 | 'title': data['topic'], | |
61 | 'url': data['viewMp4Url'], | |
62 | 'width': int_or_none(data.get('viewResolvtionsWidth')), | |
63 | 'height': int_or_none(data.get('viewResolvtionsHeight')), | |
64 | 'http_headers': { | |
65 | 'Referer': base_url, | |
66 | }, | |
67 | 'filesize_approx': parse_filesize(data.get('fileSize')), | |
55cd2999 | 68 | } |