1
mirror of https://github.com/yt-dlp/yt-dlp synced 2024-11-27 22:53:41 +01:00

[extractor/screencastomatic] Support --video-password (#4761)

Authored by: shreyasminocha
This commit is contained in:
Shreyas Minocha 2022-08-25 20:29:45 -07:00 committed by GitHub
parent 1d64a59547
commit a1af516259
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,12 @@
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
ExtractorError,
get_element_by_class, get_element_by_class,
int_or_none, int_or_none,
remove_start, remove_start,
strip_or_none, strip_or_none,
unified_strdate, unified_strdate,
urlencode_postdata,
) )
@ -34,6 +36,28 @@ class ScreencastOMaticIE(InfoExtractor):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage( webpage = self._download_webpage(
'https://screencast-o-matic.com/player/' + video_id, video_id) 'https://screencast-o-matic.com/player/' + video_id, video_id)
if (self._html_extract_title(webpage) == 'Protected Content'
or 'This video is private and requires a password' in webpage):
password = self.get_param('videopassword')
if not password:
raise ExtractorError('Password protected video, use --video-password <password>', expected=True)
form = self._search_regex(
r'(?is)<form[^>]*>(?P<form>.+?)</form>', webpage, 'login form', group='form')
form_data = self._hidden_inputs(form)
form_data.update({
'scPassword': password,
})
webpage = self._download_webpage(
'https://screencast-o-matic.com/player/password', video_id, 'Logging in',
data=urlencode_postdata(form_data))
if '<small class="text-danger">Invalid password</small>' in webpage:
raise ExtractorError('Unable to login: Invalid password', expected=True)
info = self._parse_html5_media_entries(url, webpage, video_id)[0] info = self._parse_html5_media_entries(url, webpage, video_id)[0]
info.update({ info.update({
'id': video_id, 'id': video_id,