diff --git a/README.md b/README.md index f6ebb61..5ee9bea 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,10 @@ Requires Python modules: - PyCrypto (http://www.voidspace.org.uk/python/modules.shtml#pycrypto) - lxml (https://pypi.python.org/pypi/lxml/3.2.5) - m3u8 (https://pypi.python.org/pypi/m3u8/) +- cfscrape (https://pypi.python.org/pypi/cfscrape/) crunchy-xml-decoder will try to install PyCrypto and lxml automatically, -if they are missing. m3u8 can be installed using PIP. +if they are missing. m3u8 and crscrape can be installed using PIP. This is a composite of various scripts required to download video files from CrunchyRoll diff --git a/crunchy-xml-decoder/functtest.py b/crunchy-xml-decoder/functtest.py index 9b68b46..7f3b738 100644 --- a/crunchy-xml-decoder/functtest.py +++ b/crunchy-xml-decoder/functtest.py @@ -1,6 +1,7 @@ import sys import os import re +import pip import platform import subprocess import shutil @@ -85,6 +86,17 @@ def unzip_(filename_,out): lxml_link_="Something Has Gone Wrong While Retrieving Lxml link\nPlease Download Lxml Manually" except KeyError: print "Something Has Gone Wrong While Retrieving Lxml link\nPlease Download Lxml Manually" +try: + from cfscrape import create_scraper + print('Cfscrape installed') +except ImportError: + print 'Installing Cfscrape...', + try: + if python_bit_=="32 bit" or python_bit_=="64 bit": + pip.main(['install', '--quiet', 'cfscrape']) + print "Installed" + except KeyError: + print "Something Has Gone Wrong While Retrieving Cfscrape link\nPlease Download Cfscrape Manually" if Crypto_link_ or lxml_link_: if not os.path.exists("temp"): @@ -109,4 +121,3 @@ def unzip_(filename_,out): if os.path.exists(".\\temp\\PLATLIB\\lxml"): shutil.move('.\\temp\\PLATLIB\\lxml' , bin_dir__ + '\\crunchy-xml-decoder\\') shutil.rmtree("temp") - diff --git a/crunchy-xml-decoder/login.py b/crunchy-xml-decoder/login.py index 727219d..9f83e43 100644 --- a/crunchy-xml-decoder/login.py +++ b/crunchy-xml-decoder/login.py @@ -2,13 +2,14 @@ import re import requests import pickle +import cfscrape from getpass import getpass def getuserstatus(session=''): status = 'Guest' user1 = 'Guest' if session == '': - session = requests.session() + session = cfscrape.create_scraper() with open('cookies') as f: cookies = requests.utils.cookiejar_from_dict(pickle.load(f)) session = requests.session() @@ -32,7 +33,7 @@ def getuserstatus(session=''): def login(username, password): headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:34.0) Gecko/20100101 Firefox/34.0', 'Connection': 'keep-alive'} - session = requests.session() + session = cfscrape.create_scraper() res_get = session.get('https://www.crunchyroll.com/login', headers=headers) s = re.search('name="login_form\\[_token\\]" value="([^"]*)"', res_get.text) @@ -64,7 +65,7 @@ def login(username, password): print 'Login as '+userstatus[0]+' successfully.' pickle.dump(requests.utils.dict_from_cookiejar(session.cookies), open('cookies', 'w')) with open('cookies', 'w') as f: - pickle.dump(requests.utils.dict_from_cookiejar(session.cookies), f) + pickle.dump(requests.utils.dict_from_cookiejar(session.cookies), f) if __name__ == '__main__': try: