mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-27 02:42:30 +00:00
[teachable] Skip login when already logged in (closes #22572)
This commit is contained in:
parent
2906631e12
commit
74bc299453
@ -48,6 +48,16 @@ def _login(self, site):
|
|||||||
'https://%s/sign_in' % site, None,
|
'https://%s/sign_in' % site, None,
|
||||||
'Downloading %s login page' % site)
|
'Downloading %s login page' % site)
|
||||||
|
|
||||||
|
def is_logged(webpage):
|
||||||
|
return any(re.search(p, webpage) for p in (
|
||||||
|
r'class=["\']user-signout',
|
||||||
|
r'<a[^>]+\bhref=["\']/sign_out',
|
||||||
|
r'Log\s+[Oo]ut\s*<'))
|
||||||
|
|
||||||
|
if is_logged(login_page):
|
||||||
|
self._logged_in = True
|
||||||
|
return
|
||||||
|
|
||||||
login_url = compat_str(urlh.geturl())
|
login_url = compat_str(urlh.geturl())
|
||||||
|
|
||||||
login_form = self._hidden_inputs(login_page)
|
login_form = self._hidden_inputs(login_page)
|
||||||
@ -78,10 +88,7 @@ def _login(self, site):
|
|||||||
'Go to https://%s/ and accept.' % (site, site), expected=True)
|
'Go to https://%s/ and accept.' % (site, site), expected=True)
|
||||||
|
|
||||||
# Successful login
|
# Successful login
|
||||||
if any(re.search(p, response) for p in (
|
if is_logged(response):
|
||||||
r'class=["\']user-signout',
|
|
||||||
r'<a[^>]+\bhref=["\']/sign_out',
|
|
||||||
r'>\s*Log out\s*<')):
|
|
||||||
self._logged_in = True
|
self._logged_in = True
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user