Skip to content

Commit

Permalink
[teachable] Skip login when already logged in (closes #22572)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw authored and pareronia committed Jun 22, 2020
1 parent 26f07bc commit 15ad7b0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions youtube_dl/extractor/teachable.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ def _login(self, site):
'https://%s/sign_in' % site, None,
'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_form = self._hidden_inputs(login_page)
Expand Down Expand Up @@ -78,10 +88,7 @@ def _login(self, site):
'Go to https://%s/ and accept.' % (site, site), expected=True)

# Successful login
if any(re.search(p, response) for p in (
r'class=["\']user-signout',
r'<a[^>]+\bhref=["\']/sign_out',
r'>\s*Log out\s*<')):
if is_logged(response):
self._logged_in = True
return

Expand Down

0 comments on commit 15ad7b0

Please sign in to comment.