]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[crunchyroll] Check if already logged in (Closes #10700)
authorSergey M․ <dstftw@gmail.com>
Sun, 18 Sep 2016 19:50:06 +0000 (02:50 +0700)
committerSergey M․ <dstftw@gmail.com>
Sun, 18 Sep 2016 19:50:06 +0000 (02:50 +0700)
youtube_dl/extractor/crunchyroll.py

index 1b69bd0b6787a198bd9d4c69b1042f311c874d71..e4c10ad24de1f5aa31b73baaf76a72d18dc1aae0 100644 (file)
@@ -46,6 +46,13 @@ class CrunchyrollBaseIE(InfoExtractor):
         login_page = self._download_webpage(
             self._LOGIN_URL, None, 'Downloading login page')
 
+        def is_logged(webpage):
+            return '<title>Redirecting' in webpage
+
+        # Already logged in
+        if is_logged(login_page):
+            return
+
         login_form_str = self._search_regex(
             r'(?P<form><form[^>]+?id=(["\'])%s\2[^>]*>)' % self._LOGIN_FORM,
             login_page, 'login form', group='form')
@@ -69,7 +76,7 @@ class CrunchyrollBaseIE(InfoExtractor):
             headers={'Content-Type': 'application/x-www-form-urlencoded'})
 
         # Successful login
-        if '<title>Redirecting' in response:
+        if is_logged(response):
             return
 
         error = self._html_search_regex(