Skip to content

Commit

Permalink
Merge pull request #8 from Kcchouette/patch-2
Browse files Browse the repository at this point in the history
Workaround of #6
  • Loading branch information
jaw20 authored Jan 24, 2017
2 parents 6651524 + 6a91d87 commit 5c38d97
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion crunchy-xml-decoder/functtest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sys
import os
import re
import pip
import platform
import subprocess
import shutil
Expand Down Expand Up @@ -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"):
Expand All @@ -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")

7 changes: 4 additions & 3 deletions crunchy-xml-decoder/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

1 comment on commit 5c38d97

@yuuuusha
Copy link

@yuuuusha yuuuusha commented on 5c38d97 Feb 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 98 & 99 in "functtest.py" are indented with tabs, resulting in a syntax error.
Connection is still not working. See #11

Please sign in to comment.