From c0782316af05a67d3c057452d8d1ae6a63759b12 Mon Sep 17 00:00:00 2001 From: Kcchouette Date: Sat, 14 Jan 2017 14:35:34 +0100 Subject: [PATCH 1/3] Add cfscrape installation --- crunchy-xml-decoder/functtest.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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") - From 901feeaeba368287bb2cf968230b8d5ec8899379 Mon Sep 17 00:00:00 2001 From: Kcchouette Date: Sat, 14 Jan 2017 14:39:51 +0100 Subject: [PATCH 2/3] use cfscrape to have the session for login --- crunchy-xml-decoder/login.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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: From 6a91d8785100c2f8901a2f15764cef84da9b826d Mon Sep 17 00:00:00 2001 From: Kcchouette Date: Wed, 18 Jan 2017 20:18:36 +0100 Subject: [PATCH 3/3] Include the manual download link for cfscrape and fix the maintainer's request --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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