]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[teachable] Skip login when already logged in (closes #22572)
authorSergey M․ <dstftw@gmail.com>
Tue, 1 Oct 2019 19:03:22 +0000 (02:03 +0700)
committerSergey M․ <dstftw@gmail.com>
Tue, 1 Oct 2019 19:03:22 +0000 (02:03 +0700)
youtube_dl/extractor/teachable.py

index c1a9deafee4dc2bdb16393b64374367cd47f3e8c..7d2e34b3bc4204d3ec999968c1ac76db7687a0c4 100644 (file)
@@ -48,6 +48,16 @@ class TeachableBaseIE(InfoExtractor):
             '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)
@@ -78,10 +88,7 @@ class TeachableBaseIE(InfoExtractor):
                 '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