Fixes #11572 Change the flow of the verification is cfscrape is available
This commit is contained in:
parent
7ef4388f15
commit
8fc2e7b461
@ -7,9 +7,9 @@ import base64
|
|||||||
import zlib
|
import zlib
|
||||||
try:
|
try:
|
||||||
import cfscrape
|
import cfscrape
|
||||||
install_cfscrape_flag = True
|
cfscrape_available = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
install_cfscrape_flag = False
|
cfscrape_available = False
|
||||||
|
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from math import pow, sqrt, floor
|
from math import pow, sqrt, floor
|
||||||
@ -45,19 +45,18 @@ class CrunchyrollBaseIE(InfoExtractor):
|
|||||||
_NETRC_MACHINE = 'crunchyroll'
|
_NETRC_MACHINE = 'crunchyroll'
|
||||||
|
|
||||||
def _login(self):
|
def _login(self):
|
||||||
(username, password) = self._get_login_info()
|
if cfscrape_available:
|
||||||
if username is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
if install_cfscrape_flag == False:
|
|
||||||
print 'cfscrape not found. Please install it if you want use login function for CrunchyRoll.'
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Scrape cookie from cloudflare and insert them
|
# Scrape cookie from cloudflare and insert them
|
||||||
scraper = cfscrape.create_scraper()
|
scraper = cfscrape.create_scraper()
|
||||||
tokens = scraper.get_tokens(self._LOGIN_URL, std_headers['User-Agent'])
|
tokens = scraper.get_tokens(self._LOGIN_URL, std_headers['User-Agent'])
|
||||||
self._set_crunchyroll_cookie('cf_clearance', tokens[0]['cf_clearance'])
|
self._set_crunchyroll_cookie('cf_clearance', tokens[0]['cf_clearance'])
|
||||||
self._set_crunchyroll_cookie('__cfduid', tokens[0]['__cfduid'])
|
self._set_crunchyroll_cookie('__cfduid', tokens[0]['__cfduid'])
|
||||||
|
else
|
||||||
|
print 'cfscrape not found. Please install it if you want use login function for CrunchyRoll.'
|
||||||
|
|
||||||
|
(username, password) = self._get_login_info()
|
||||||
|
if username is None:
|
||||||
|
return
|
||||||
|
|
||||||
login_page = self._download_webpage(
|
login_page = self._download_webpage(
|
||||||
self._LOGIN_URL, None, 'Downloading login page')
|
self._LOGIN_URL, None, 'Downloading login page')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user