Skip to content

Commit

Permalink
[extractor/screencastomatic] Support --video-password (yt-dlp#4761)
Browse files Browse the repository at this point in the history
Authored by: shreyasminocha
  • Loading branch information
shreyasminocha authored Aug 26, 2022
1 parent 1d64a59 commit a1af516
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions yt_dlp/extractor/screencastomatic.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from .common import InfoExtractor
from ..utils import (
ExtractorError,
get_element_by_class,
int_or_none,
remove_start,
strip_or_none,
unified_strdate,
urlencode_postdata,
)


Expand Down Expand Up @@ -34,6 +36,28 @@ def _real_extract(self, url):
video_id = self._match_id(url)
webpage = self._download_webpage(
'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.update({
'id': video_id,
Expand Down

0 comments on commit a1af516

Please sign in to comment.