summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
Diffstat (limited to 'module')
-rw-r--r--module/plugins/hooks/ClickAndLoad.py56
-rw-r--r--module/web/cnl_app.py47
2 files changed, 53 insertions, 50 deletions
diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py
index 304cb9233..253f05ac5 100644
--- a/module/plugins/hooks/ClickAndLoad.py
+++ b/module/plugins/hooks/ClickAndLoad.py
@@ -6,34 +6,6 @@ import thread
from module.plugins.Hook import Hook
-class ClickAndLoad(Hook):
- __name__ = "ClickAndLoad"
- __type__ = "hook"
- __version__ = "0.22"
-
- __config__ = [("activated", "bool", "Activated", True),
- ("extern", "bool", "Allow external link adding", False)]
-
- __description__ = """Gives abillity to use jd's click and load. depends on webinterface"""
- __license__ = "GPLv3"
- __authors__ = [("RaNaN", "RaNaN@pyload.de"),
- ("mkaay", "mkaay@mkaay.de")]
-
-
- def coreReady(self):
- self.port = int(self.config['webinterface']['port'])
- if self.config['webinterface']['activated']:
- try:
- if self.getConfig("extern"):
- ip = "0.0.0.0"
- else:
- ip = "127.0.0.1"
-
- thread.start_new_thread(proxy, (self, ip, self.port, 9666))
- except:
- self.logError(_("ClickAndLoad port already in use"))
-
-
def proxy(self, *settings):
thread.start_new_thread(server, (self,) + settings)
lock = thread.allocate_lock()
@@ -75,3 +47,31 @@ def forward(source, destination):
else:
#source.shutdown(socket.SHUT_RD)
destination.shutdown(socket.SHUT_WR)
+
+
+class ClickAndLoad(Hook):
+ __name__ = "ClickAndLoad"
+ __type__ = "hook"
+ __version__ = "0.22"
+
+ __config__ = [("activated", "bool", "Activated", True),
+ ("extern", "bool", "Allow external link adding", False)]
+
+ __description__ = """Click'N'Load hook plugin"""
+ __license__ = "GPLv3"
+ __authors__ = [("RaNaN", "RaNaN@pyload.de"),
+ ("mkaay", "mkaay@mkaay.de")]
+
+
+ def coreReady(self):
+ self.port = int(self.config['webinterface']['port'])
+ if self.config['webinterface']['activated']:
+ try:
+ if self.getConfig("extern"):
+ ip = "0.0.0.0"
+ else:
+ ip = "127.0.0.1"
+
+ thread.start_new_thread(proxy, (self, ip, self.port, 9666))
+ except:
+ self.logError(_("ClickAndLoad port already in use"))
diff --git a/module/web/cnl_app.py b/module/web/cnl_app.py
index d8f7c1180..718499dfb 100644
--- a/module/web/cnl_app.py
+++ b/module/web/cnl_app.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# -*- coding: utf-8 -*-
from os.path import join
import re
@@ -9,6 +8,7 @@ from binascii import unhexlify
from bottle import route, request, HTTPError
from webinterface import PYLOAD, DL_ROOT, JS
+
try:
from Crypto.Cipher import AES
except:
@@ -17,8 +17,8 @@ except:
def local_check(function):
def _view(*args, **kwargs):
- if request.environ.get('REMOTE_ADDR', "0") in ('127.0.0.1', 'localhost') \
- or request.environ.get('HTTP_HOST','0') == '127.0.0.1:9666':
+ if request.environ.get("REMOTE_ADDR", "0") in ("127.0.0.1", "localhost") \
+ or request.environ.get("HTTP_HOST", "0") in ("127.0.0.1:9666", "localhost:9666"):
return function(*args, **kwargs)
else:
return HTTPError(403, "Forbidden")
@@ -26,14 +26,15 @@ def local_check(function):
return _view
-@route("/flash")
-@route("/flash/:id")
-@route("/flash", method="POST")
+@route('/flash')
+@route('/flash/<id>')
+@route('/flash', method='POST')
@local_check
def flash(id="0"):
return "JDownloader\r\n"
-@route("/flash/add", method="POST")
+
+@route('/flash/add', method='POST')
@local_check
def add(request):
package = request.POST.get('referer', None)
@@ -46,10 +47,10 @@ def add(request):
return ""
-@route("/flash/addcrypted", method="POST")
+
+@route('/flash/addcrypted', method='POST')
@local_check
def addcrypted():
-
package = request.forms.get('referer', 'ClickAndLoad Package')
dlc = request.forms['crypted'].replace(" ", "+")
@@ -65,10 +66,10 @@ def addcrypted():
else:
return "success\r\n"
-@route("/flash/addcrypted2", method="POST")
+
+@route('/flash/addcrypted2', method='POST')
@local_check
def addcrypted2():
-
package = request.forms.get("source", None)
crypted = request.forms["crypted"]
jk = request.forms["jk"]
@@ -82,7 +83,7 @@ def addcrypted2():
try:
jk = re.findall(r"return ('|\")(.+)('|\")", jk)[0][1]
except:
- ## Test for some known js functions to decode
+ ## 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)
@@ -100,7 +101,7 @@ def addcrypted2():
IV = Key
obj = AES.new(Key, AES.MODE_CBC, IV)
- result = obj.decrypt(crypted).replace("\x00", "").replace("\r","").split("\n")
+ result = obj.decrypt(crypted).replace("\x00", "").replace("\r", "").split("\n")
result = filter(lambda x: x != "", result)
@@ -114,13 +115,14 @@ def addcrypted2():
else:
return "success\r\n"
-@route("/flashgot_pyload")
-@route("/flashgot_pyload", method="POST")
-@route("/flashgot")
-@route("/flashgot", method="POST")
+
+@route('/flashgot_pyload')
+@route('/flashgot_pyload', method='POST')
+@route('/flashgot')
+@route('/flashgot', method='POST')
@local_check
def flashgot():
- if request.environ['HTTP_REFERER'] != "http://localhost:9666/flashgot" and request.environ['HTTP_REFERER'] != "http://127.0.0.1:9666/flashgot":
+ if request.environ['HTTP_REFERER'] not in ("http://localhost:9666/flashgot", "http://127.0.0.1:9666/flashgot"):
return HTTPError()
autostart = int(request.forms.get('autostart', 0))
@@ -135,7 +137,8 @@ def flashgot():
return ""
-@route("/crossdomain.xml")
+
+@route('/crossdomain.xml')
@local_check
def crossdomain():
rep = "<?xml version=\"1.0\"?>\n"
@@ -146,17 +149,17 @@ def crossdomain():
return rep
-@route("/flash/checkSupportForUrl")
+@route('/flash/checkSupportForUrl')
@local_check
def checksupport():
-
url = request.GET.get("url")
res = PYLOAD.checkURLs([url])
supported = (not res[0][1] is None)
return str(supported).lower()
-@route("/jdcheck.js")
+
+@route('/jdcheck.js')
@local_check
def jdcheck():
rep = "jdownloader=true;\n"