[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 @@ class DropoutIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
display_id = self._match_id(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) login_err = self._login(display_id)
webpage = self._download_webpage(url, display_id) webpage = self._download_webpage(url, display_id)
finally: if login_err and '<div id="watch-unauthorized"' in webpage:
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 is True: if login_err is True:
self.raise_login_required(method='password') self.raise_login_required(method='any')
raise ExtractorError(login_err, expected=True) raise ExtractorError(login_err, expected=True)
embed_url = self._search_regex(r'embed_url:\s*["\'](.+?)["\']', webpage, 'embed url') embed_url = self._search_regex(r'embed_url:\s*["\'](.+?)["\']', webpage, 'embed url')