]>
Commit | Line | Data |
---|---|---|
3f0852e3 RSK |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
5 | from ..utils import ( | |
81acad12 | 6 | ExtractorError, |
3f0852e3 | 7 | int_or_none, |
abd273e1 | 8 | url_or_none, |
81acad12 RSK |
9 | parse_filesize, |
10 | urlencode_postdata | |
3f0852e3 RSK |
11 | ) |
12 | ||
13 | ||
14 | class ZoomUSIE(InfoExtractor): | |
15 | IE_NAME = 'zoom.us' | |
b11a88fc | 16 | _VALID_URL = r'https://(?:.*).?zoom.us/rec(?:ording)?/play/(?P<id>[A-Za-z0-9\-_]+)' |
3f0852e3 | 17 | |
55cd2999 | 18 | _TEST = { |
3f0852e3 RSK |
19 | 'url': 'https://zoom.us/recording/play/SILVuCL4bFtRwWTtOCFQQxAsBQsJljFtm9e4Z_bvo-A8B-nzUSYZRNuPl3qW5IGK', |
20 | 'info_dict': { | |
55cd2999 RSK |
21 | 'md5': '031a5b379f1547a8b29c5c4c837dccf2', |
22 | 'title': "GAZ Transformational Tuesdays W/ Landon & Stapes", | |
23 | 'id': "SILVuCL4bFtRwWTtOCFQQxAsBQsJljFtm9e4Z_bvo-A8B-nzUSYZRNuPl3qW5IGK", | |
abd273e1 | 24 | 'ext': "mp4" |
3f0852e3 | 25 | } |
55cd2999 | 26 | } |
3f0852e3 RSK |
27 | |
28 | def _real_extract(self, url): | |
29 | display_id = self._match_id(url) | |
30 | webpage = self._download_webpage(url, display_id) | |
81acad12 | 31 | |
b11a88fc | 32 | password_protected = self._search_regex(r'<form[^>]+?id="(password_form)"', webpage, 'password field', fatal=False, default=None) |
81acad12 RSK |
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 | ||
3f0852e3 | 37 | video_url = self._search_regex(r"viewMp4Url: \'(.*)\'", webpage, 'video url') |
abd273e1 RSK |
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)) | |
3f0852e3 | 42 | |
aa13f124 RSK |
43 | urlprefix = url.split("zoom.us")[0] + "zoom.us/" |
44 | ||
3f0852e3 RSK |
45 | formats = [] |
46 | formats.append({ | |
abd273e1 | 47 | 'url': url_or_none(video_url), |
3f0852e3 RSK |
48 | 'width': int_or_none(viewResolvtionsWidth), |
49 | 'height': int_or_none(viewResolvtionsHeight), | |
55cd2999 | 50 | 'http_headers': {'Accept': 'video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5', |
aa13f124 | 51 | 'Referer': urlprefix}, |
abd273e1 RSK |
52 | 'ext': "mp4", |
53 | 'filesize_approx': int_or_none(fileSize) | |
3f0852e3 RSK |
54 | }) |
55 | self._sort_formats(formats) | |
56 | ||
57 | return { | |
58 | 'id': display_id, | |
abd273e1 | 59 | 'title': title, |
3f0852e3 | 60 | 'formats': formats |
55cd2999 | 61 | } |
81acad12 RSK |
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 | }) | |
aa13f124 | 74 | validation_url = url.split("zoom.us")[0] + "zoom.us/rec/validate_meet_passwd" |
81acad12 RSK |
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'])) |