]>
Commit | Line | Data |
---|---|---|
1 | # coding: utf-8 | |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
5 | from ..utils import ( | |
6 | ExtractorError, | |
7 | int_or_none, | |
8 | url_or_none, | |
9 | parse_filesize, | |
10 | urlencode_postdata | |
11 | ) | |
12 | ||
13 | ||
14 | class ZoomIE(InfoExtractor): | |
15 | IE_NAME = 'zoom' | |
16 | _VALID_URL = r'https://(?:.*).?zoom.us/rec(?:ording)?/(play|share)/(?P<id>[A-Za-z0-9\-_.]+)' | |
17 | ||
18 | _TEST = { | |
19 | 'url': 'https://zoom.us/recording/play/SILVuCL4bFtRwWTtOCFQQxAsBQsJljFtm9e4Z_bvo-A8B-nzUSYZRNuPl3qW5IGK', | |
20 | 'info_dict': { | |
21 | 'md5': '031a5b379f1547a8b29c5c4c837dccf2', | |
22 | 'title': "GAZ Transformational Tuesdays W/ Landon & Stapes", | |
23 | 'id': "SILVuCL4bFtRwWTtOCFQQxAsBQsJljFtm9e4Z_bvo-A8B-nzUSYZRNuPl3qW5IGK", | |
24 | 'ext': "mp4" | |
25 | } | |
26 | } | |
27 | ||
28 | def _real_extract(self, url): | |
29 | display_id = self._match_id(url) | |
30 | webpage = self._download_webpage(url, display_id) | |
31 | ||
32 | password_protected = self._search_regex(r'<form[^>]+?id="(password_form)"', webpage, 'password field', fatal=False, default=None) | |
33 | if password_protected is not None: | |
34 | self._verify_video_password(url, display_id, webpage) | |
35 | webpage = self._download_webpage(url, display_id) | |
36 | ||
37 | video_url = self._search_regex(r"viewMp4Url: \'(.*)\'", webpage, 'video url') | |
38 | title = self._html_search_regex([r"topic: \"(.*)\",", r"<title>(.*) - Zoom</title>"], webpage, 'title') | |
39 | viewResolvtionsWidth = self._search_regex(r"viewResolvtionsWidth: (\d*)", webpage, 'res width', fatal=False) | |
40 | viewResolvtionsHeight = self._search_regex(r"viewResolvtionsHeight: (\d*)", webpage, 'res height', fatal=False) | |
41 | fileSize = parse_filesize(self._search_regex(r"fileSize: \'(.+)\'", webpage, 'fileSize', fatal=False)) | |
42 | ||
43 | urlprefix = url.split("zoom.us")[0] + "zoom.us/" | |
44 | ||
45 | formats = [] | |
46 | formats.append({ | |
47 | 'url': url_or_none(video_url), | |
48 | 'width': int_or_none(viewResolvtionsWidth), | |
49 | 'height': int_or_none(viewResolvtionsHeight), | |
50 | 'http_headers': {'Accept': 'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5', | |
51 | 'Referer': urlprefix}, | |
52 | 'ext': "mp4", | |
53 | 'filesize_approx': int_or_none(fileSize) | |
54 | }) | |
55 | self._sort_formats(formats) | |
56 | ||
57 | return { | |
58 | 'id': display_id, | |
59 | 'title': title, | |
60 | 'formats': formats | |
61 | } | |
62 | ||
63 | def _verify_video_password(self, url, video_id, webpage): | |
64 | password = self._downloader.params.get('videopassword') | |
65 | if password is None: | |
66 | raise ExtractorError('This video is protected by a password, use the --video-password option', expected=True) | |
67 | meetId = self._search_regex(r'<input[^>]+?id="meetId" value="([^\"]+)"', webpage, 'meetId') | |
68 | data = urlencode_postdata({ | |
69 | 'id': meetId, | |
70 | 'passwd': password, | |
71 | 'action': "viewdetailedpage", | |
72 | 'recaptcha': "" | |
73 | }) | |
74 | validation_url = url.split("zoom.us")[0] + "zoom.us/rec/validate_meet_passwd" | |
75 | validation_response = self._download_json( | |
76 | validation_url, video_id, | |
77 | note='Validating Password...', | |
78 | errnote='Wrong password?', | |
79 | data=data) | |
80 | ||
81 | if validation_response['errorCode'] != 0: | |
82 | raise ExtractorError('Login failed, %s said: %r' % (self.IE_NAME, validation_response['errorMessage'])) |