[extractor/dropout] Support cookies and login only as needed (#4075)

Closes #4035
Authored by: pingiun, pukkandan
This commit is contained in:
Jelle Besseling 2022-06-24 01:21:03 +02:00 committed by GitHub
parent 9809740ba5
commit 34baaced11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,16 +119,16 @@ def _login(self, display_id):
def _real_extract(self, url):
display_id = self._match_id(url)
login_err, webpage = False, ''
try:
webpage = None
if self._get_cookies('https://www.dropout.tv').get('_session'):
webpage = self._download_webpage(url, display_id)
if not webpage or '<div id="watch-unauthorized"' in webpage:
login_err = self._login(display_id)
webpage = self._download_webpage(url, display_id)
finally:
if not login_err:
self._download_webpage('https://www.dropout.tv/logout', display_id, note='Logging out', fatal=False)
elif '<div id="watch-unauthorized"' in webpage:
if login_err and '<div id="watch-unauthorized"' in webpage:
if login_err is True:
self.raise_login_required(method='password')
self.raise_login_required(method='any')
raise ExtractorError(login_err, expected=True)
embed_url = self._search_regex(r'embed_url:\s*["\'](.+?)["\']', webpage, 'embed url')