Browse Source

[crunchyroll] Check if already logged in (Closes #10700)

totalwebcasting
Sergey M․ 8 years ago
parent
commit
70b4cf9b1b
No known key found for this signature in database GPG Key ID: 2C393E0F18A9236D
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      youtube_dl/extractor/crunchyroll.py

+ 8
- 1
youtube_dl/extractor/crunchyroll.py View File

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


Loading…
Cancel
Save