]>
Commit | Line | Data |
---|---|---|
a4a554a7 | 1 | from .common import InfoExtractor |
39ed931e | 2 | from ..utils import ( |
a1af5162 | 3 | ExtractorError, |
39ed931e | 4 | get_element_by_class, |
5 | int_or_none, | |
6 | remove_start, | |
7 | strip_or_none, | |
8 | unified_strdate, | |
a1af5162 | 9 | urlencode_postdata, |
39ed931e | 10 | ) |
6e1b9395 PH |
11 | |
12 | ||
a4a554a7 | 13 | class ScreencastOMaticIE(InfoExtractor): |
39ed931e | 14 | _VALID_URL = r'https?://screencast-o-matic\.com/(?:(?:watch|player)/|embed\?.*?\bsc=)(?P<id>[0-9a-zA-Z]+)' |
15 | _TESTS = [{ | |
6e1b9395 PH |
16 | 'url': 'http://screencast-o-matic.com/watch/c2lD3BeOPl', |
17 | 'md5': '483583cb80d92588f15ccbedd90f0c18', | |
18 | 'info_dict': { | |
19 | 'id': 'c2lD3BeOPl', | |
20 | 'ext': 'mp4', | |
21 | 'title': 'Welcome to 3-4 Philosophy @ DECV!', | |
ec85ded8 | 22 | 'thumbnail': r're:^https?://.*\.jpg$', |
6e1b9395 | 23 | 'description': 'as the title says! also: some general info re 1) VCE philosophy and 2) distance learning.', |
39ed931e | 24 | 'duration': 369, |
25 | 'upload_date': '20141216', | |
6e1b9395 | 26 | } |
39ed931e | 27 | }, { |
28 | 'url': 'http://screencast-o-matic.com/player/c2lD3BeOPl', | |
29 | 'only_matching': True, | |
30 | }, { | |
31 | 'url': 'http://screencast-o-matic.com/embed?ff=true&sc=cbV2r4Q5TL&fromPH=true&a=1', | |
32 | 'only_matching': True, | |
33 | }] | |
6e1b9395 PH |
34 | |
35 | def _real_extract(self, url): | |
36 | video_id = self._match_id(url) | |
39ed931e | 37 | webpage = self._download_webpage( |
38 | 'https://screencast-o-matic.com/player/' + video_id, video_id) | |
a1af5162 SM |
39 | |
40 | if (self._html_extract_title(webpage) == 'Protected Content' | |
41 | or 'This video is private and requires a password' in webpage): | |
42 | password = self.get_param('videopassword') | |
43 | ||
44 | if not password: | |
45 | raise ExtractorError('Password protected video, use --video-password <password>', expected=True) | |
46 | ||
47 | form = self._search_regex( | |
48 | r'(?is)<form[^>]*>(?P<form>.+?)</form>', webpage, 'login form', group='form') | |
49 | form_data = self._hidden_inputs(form) | |
50 | form_data.update({ | |
51 | 'scPassword': password, | |
52 | }) | |
53 | ||
54 | webpage = self._download_webpage( | |
55 | 'https://screencast-o-matic.com/player/password', video_id, 'Logging in', | |
56 | data=urlencode_postdata(form_data)) | |
57 | ||
58 | if '<small class="text-danger">Invalid password</small>' in webpage: | |
59 | raise ExtractorError('Unable to login: Invalid password', expected=True) | |
60 | ||
39ed931e | 61 | info = self._parse_html5_media_entries(url, webpage, video_id)[0] |
62 | info.update({ | |
63 | 'id': video_id, | |
64 | 'title': get_element_by_class('overlayTitle', webpage), | |
65 | 'description': strip_or_none(get_element_by_class('overlayDescription', webpage)) or None, | |
66 | 'duration': int_or_none(self._search_regex( | |
67 | r'player\.duration\s*=\s*function\(\)\s*{\s*return\s+(\d+);\s*};', | |
68 | webpage, 'duration', default=None)), | |
69 | 'upload_date': unified_strdate(remove_start( | |
70 | get_element_by_class('overlayPublished', webpage), 'Published: ')), | |
66fa4958 | 71 | }) |
39ed931e | 72 | return info |