Fixes #11572 Handle ImportError and display a message if you want use login function for CrunchyRoll

This commit is contained in:
kidburglar 2017-01-15 22:32:19 +01:00
parent 076e0481f3
commit b02249521b

View File

@ -5,7 +5,11 @@ import re
import json import json
import base64 import base64
import zlib import zlib
import cfscrape try:
import cfscrape
install_cfscrape_flag = True
except ImportError:
install_cfscrape_flag = False
from hashlib import sha1 from hashlib import sha1
from math import pow, sqrt, floor from math import pow, sqrt, floor
@ -45,6 +49,10 @@ class CrunchyrollBaseIE(InfoExtractor):
if username is None: if username is None:
return 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 cloudfront and insert them # Scrape cookie from cloudfront 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'])