summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-09-03 18:12:36 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-09-03 18:12:36 +0200
commitdbd9423f99fcde168b0483e4a37a094b93bb2ea0 (patch)
tree30dd0a93d4d706ada845f0552e21de5ab4ffedc4
parentnetload prefetching fix (diff)
downloadpyload-dbd9423f99fcde168b0483e4a37a094b93bb2ea0.tar.xz
new js engine for cnl
-rw-r--r--module/setup.py13
-rw-r--r--module/web/cnl/views.py40
-rw-r--r--module/web/settings.py7
3 files changed, 42 insertions, 18 deletions
diff --git a/module/setup.py b/module/setup.py
index 73415703d..fecbc8967 100644
--- a/module/setup.py
+++ b/module/setup.py
@@ -63,7 +63,7 @@ class Setup():
print _("When you are ready for system check, hit enter.")
raw_input()
- basic, ssl, captcha, gui, web = self.system_check()
+ basic, ssl, captcha, gui, web, js = self.system_check()
print ""
if not basic:
@@ -85,6 +85,7 @@ class Setup():
if captcha: avail.append(_("automatic captcha decryption"))
if gui: avail.append(_("GUI"))
if web: avail.append(_("Webinterface"))
+ if js: avail.append(_("extended Click'N'Load"))
string = ""
@@ -123,6 +124,10 @@ class Setup():
print _("no Webinterface available")
print _("Gives abillity to control pyLoad with your webbrowser.")
print ""
+
+ if not js:
+ print _("no JavaScript engine found")
+ print _("You will need this for some Click'N'Load links. Install Spidermonkey or ossp-js")
print _("You can abort the setup now and fix some dependicies if you want.")
@@ -223,7 +228,6 @@ class Setup():
print ""
web = self.check_module("django")
-
try:
import django
@@ -240,7 +244,10 @@ class Setup():
self.print_dep("django", web)
web = web and sqlite
- return (basic, ssl, captcha, gui, web)
+ js = self.check_prog(["js", "-v"])
+ self.print_dep(_("JS engine"), js)
+
+ return (basic, ssl, captcha, gui, web, js)
def conf_basic(self):
print ""
diff --git a/module/web/cnl/views.py b/module/web/cnl/views.py
index 7bc2ae6d4..46db5e76e 100644
--- a/module/web/cnl/views.py
+++ b/module/web/cnl/views.py
@@ -90,28 +90,38 @@ def addcrypted2(request):
jk = request.POST["jk"]
crypted = base64.standard_b64decode(unquote(crypted.replace(" ", "+")))
-
try:
import spidermonkey
- except:
- try:
- jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1]
- except:
- ## Test for some known js functions to decode
- if jk.find("dec") > -1 and jk.find("org") > -1:
- org = re.findall(r"var org = ('|\")([^\"']+)", jk)[0][1]
- jk = list(org)
- jk.reverse()
- jk = "".join(jk)
- else:
- print "Could not decrypt key, please install py-spidermonkey"
- else:
rt = spidermonkey.Runtime()
cx = rt.new_context()
jk = cx.execute("%s f()" % jk)
+ except ImportError:
+ if settings.JS:
+ import subprocess
+ jk = jk.replace("'", '"')
+ cmd = settings.JS + ["-e", "%s ;print(f());" % jk ]
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
+ jk = p.stdout.read().strip()
+
+ else:
+ try:
+ jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1]
+ except:
+ ## Test for some known js functions to decode
+ if jk.find("dec") > -1 and jk.find("org") > -1:
+ org = re.findall(r"var org = ('|\")([^\"']+)", jk)[0][1]
+ jk = list(org)
+ jk.reverse()
+ jk = "".join(jk)
+ else:
+ print "Could not decrypt key, please install py-spidermonkey or other js engine"
+ try:
+ Key = binascii.unhexlify(jk)
+ except:
+ print "Could not decrypt key, please install py-spidermonkey or other js engine"
+ return JsonResponse("failed", request)
- Key = binascii.unhexlify(jk)
IV = Key
obj = AES.new(Key, AES.MODE_CBC, IV)
diff --git a/module/web/settings.py b/module/web/settings.py
index 134eadd50..3cac7604c 100644
--- a/module/web/settings.py
+++ b/module/web/settings.py
@@ -53,6 +53,13 @@ except:
PYLOAD = xmlrpclib.ServerProxy(server_url, allow_none=True)
+try:
+ import subprocess
+ subprocess.Popen(["js", "-v"], bufsize=-1,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ JS = ["js"]
+except:
+ JS = []
+
TEMPLATE = config.get('webinterface','template')
DL_ROOT = os.path.join(PYLOAD_DIR, config.get('general','download_folder'))