From 6eae782f13953dd0ba2bbe1b582cf33fd4d7d90a Mon Sep 17 00:00:00 2001 From: RaNaN Date: Mon, 19 Dec 2011 23:10:49 +0100 Subject: configparser v2, warning CONFIG will be DELETED. --- module/web/json_app.py | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'module/web/json_app.py') diff --git a/module/web/json_app.py b/module/web/json_app.py index f3626405c..196c9e36d 100644 --- a/module/web/json_app.py +++ b/module/web/json_app.py @@ -232,38 +232,23 @@ def set_captcha(): return {'captcha': False} -@route("/json/load_config/:category/:section") +@route("/json/load_config/:section") @login_required("SETTINGS") -def load_config(category, section): - conf = None - if category == "general": - conf = PYLOAD.getConfigDict() - elif category == "plugin": - conf = PYLOAD.getPluginConfigDict() +def load_config(section): + data = PYLOAD.configureSection(section) + return render_to_response("settings_item.html", {"section": data}) - for key, option in conf[section].iteritems(): - if key in ("desc","outline"): continue - if ";" in option["type"]: - option["list"] = option["type"].split(";") - - option["value"] = decode(option["value"]) - - return render_to_response("settings_item.html", {"skey": section, "section": conf[section]}) - - -@route("/json/save_config/:category", method="POST") +@route("/json/save_config", method="POST") @login_required("SETTINGS") -def save_config(category): +def save_config(): for key, value in request.POST.iteritems(): try: section, option = key.split("|") except: continue - if category == "general": category = "core" - - PYLOAD.setConfigValue(section, option, decode(value), category) + PYLOAD.setConfigValue(section, option, decode(value)) @route("/json/add_account", method="POST") -- cgit v1.2.3 From 958bf611f5d9d117f19f824990ec6fd6b537e967 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Thu, 22 Dec 2011 23:45:38 +0100 Subject: accountmanager v2, delete your accounts.conf and re-enter them in pyload, new nice debug functions, try core.shell() and core.breakpoint() --- module/web/json_app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/web/json_app.py') diff --git a/module/web/json_app.py b/module/web/json_app.py index 196c9e36d..e02aa0707 100644 --- a/module/web/json_app.py +++ b/module/web/json_app.py @@ -278,9 +278,9 @@ def update_accounts(): if action == "password": PYLOAD.updateAccount(plugin, user, value) elif action == "time" and "-" in value: - PYLOAD.updateAccount(plugin, user, options={"time": [value]}) + PYLOAD.updateAccount(plugin, user, options={"time": value}) elif action == "limitdl" and value.isdigit(): - PYLOAD.updateAccount(plugin, user, options={"limitDL": [value]}) + PYLOAD.updateAccount(plugin, user, options={"limitDL": value}) elif action == "delete": deleted.append((plugin,user)) PYLOAD.removeAccount(plugin, user) -- cgit v1.2.3 From d35c003cc53d4723d1dfe0d81eeb9bea78cee594 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 31 Dec 2011 16:01:24 +0100 Subject: new crypter plugin API, now decrypting possible for now. --- module/web/json_app.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'module/web/json_app.py') diff --git a/module/web/json_app.py b/module/web/json_app.py index e02aa0707..5acafe153 100644 --- a/module/web/json_app.py +++ b/module/web/json_app.py @@ -179,11 +179,7 @@ def add_package(): links = map(lambda x: x.strip(), links) links = filter(lambda x: x != "", links) - pack = PYLOAD.addPackage(name, links, queue) - if pw: - pw = pw.decode("utf8", "ignore") - data = {"password": pw} - PYLOAD.setPackageData(pack, data) + PYLOAD.addPackage(name, links, queue, pw.decode("utf8", "ignore")) @route("/json/move_package//") -- cgit v1.2.3 From 4df2b77fdf42046fe19bd371be7c7255986b5980 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 6 Mar 2012 13:36:39 +0100 Subject: renamed hooks to addons, new filemanager and database, many new api methods you will loose ALL your LINKS, webinterface will NOT work --- module/web/json_app.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'module/web/json_app.py') diff --git a/module/web/json_app.py b/module/web/json_app.py index 5acafe153..fcaa906e1 100644 --- a/module/web/json_app.py +++ b/module/web/json_app.py @@ -11,16 +11,7 @@ from webinterface import PYLOAD from utils import login_required, render_to_response, toDict -from module.utils import decode, formatSize - - -def format_time(seconds): - seconds = int(seconds) - - hours, seconds = divmod(seconds, 3600) - minutes, seconds = divmod(seconds, 60) - return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) - +from module.utils import decode, format_size def get_sort_key(item): return item["order"] @@ -49,7 +40,7 @@ def links(): ids.append(link['fid']) if link['status'] == 12: - link['info'] = "%s @ %s/s" % (link['format_eta'], formatSize(link['speed'])) + link['info'] = "%s @ %s/s" % (link['format_eta'], format_size(link['speed'])) elif link['status'] == 5: link['percent'] = 0 link['size'] = 0 -- cgit v1.2.3 From 50d4df8b4d48b855bd18e9922355b7f3f2b4da4e Mon Sep 17 00:00:00 2001 From: RaNaN Date: Tue, 20 Mar 2012 14:57:45 +0100 Subject: captcha decrypting for all plugin types, new interaction manager --- module/web/json_app.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/web/json_app.py') diff --git a/module/web/json_app.py b/module/web/json_app.py index fcaa906e1..ed4f6bcfb 100644 --- a/module/web/json_app.py +++ b/module/web/json_app.py @@ -11,6 +11,7 @@ from webinterface import PYLOAD from utils import login_required, render_to_response, toDict +from module.Api import Output from module.utils import decode, format_size def get_sort_key(item): @@ -23,7 +24,7 @@ def get_sort_key(item): def status(): try: status = toDict(PYLOAD.statusServer()) - status['captcha'] = PYLOAD.isCaptchaWaiting() + status['captcha'] = PYLOAD.isInteractionWaiting(Output.Captcha) return status except: return HTTPError() @@ -34,7 +35,7 @@ def status(): @login_required('LIST') def links(): try: - links = [toDict(x) for x in PYLOAD.statusDownloads()] + links = [toDict(x) for x in PYLOAD.getProgressInfo()] ids = [] for link in links: ids.append(link['fid']) -- cgit v1.2.3 From a8f763fb85756f69899f7b3b71c01bb01461ee3c Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 10 Aug 2012 22:12:10 +0200 Subject: beginning new pyload web-ui from scratch --- module/web/json_app.py | 285 ------------------------------------------------- 1 file changed, 285 deletions(-) delete mode 100644 module/web/json_app.py (limited to 'module/web/json_app.py') diff --git a/module/web/json_app.py b/module/web/json_app.py deleted file mode 100644 index ed4f6bcfb..000000000 --- a/module/web/json_app.py +++ /dev/null @@ -1,285 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from os.path import join -from traceback import print_exc -from shutil import copyfileobj - -from bottle import route, request, HTTPError - -from webinterface import PYLOAD - -from utils import login_required, render_to_response, toDict - -from module.Api import Output -from module.utils import decode, format_size - -def get_sort_key(item): - return item["order"] - - -@route("/json/status") -@route("/json/status", method="POST") -@login_required('LIST') -def status(): - try: - status = toDict(PYLOAD.statusServer()) - status['captcha'] = PYLOAD.isInteractionWaiting(Output.Captcha) - return status - except: - return HTTPError() - - -@route("/json/links") -@route("/json/links", method="POST") -@login_required('LIST') -def links(): - try: - links = [toDict(x) for x in PYLOAD.getProgressInfo()] - ids = [] - for link in links: - ids.append(link['fid']) - - if link['status'] == 12: - link['info'] = "%s @ %s/s" % (link['format_eta'], format_size(link['speed'])) - elif link['status'] == 5: - link['percent'] = 0 - link['size'] = 0 - link['bleft'] = 0 - link['info'] = _("waiting %s") % link['format_wait'] - else: - link['info'] = "" - - data = {'links': links, 'ids': ids} - return data - except Exception, e: - print_exc() - return HTTPError() - - -@route("/json/packages") -@login_required('LIST') -def packages(): - print "/json/packages" - try: - data = PYLOAD.getQueue() - - for package in data: - package['links'] = [] - for file in PYLOAD.get_package_files(package['id']): - package['links'].append(PYLOAD.get_file_info(file)) - - return data - - except: - return HTTPError() - - -@route("/json/package/") -@login_required('LIST') -def package(id): - try: - data = toDict(PYLOAD.getPackageData(id)) - data["links"] = [toDict(x) for x in data["links"]] - - for pyfile in data["links"]: - if pyfile["status"] == 0: - pyfile["icon"] = "status_finished.png" - elif pyfile["status"] in (2, 3): - pyfile["icon"] = "status_queue.png" - elif pyfile["status"] in (9, 1): - pyfile["icon"] = "status_offline.png" - elif pyfile["status"] == 5: - pyfile["icon"] = "status_waiting.png" - elif pyfile["status"] == 8: - pyfile["icon"] = "status_failed.png" - elif pyfile["status"] == 4: - pyfile["icon"] = "arrow_right.png" - elif pyfile["status"] in (11, 13): - pyfile["icon"] = "status_proc.png" - else: - pyfile["icon"] = "status_downloading.png" - - tmp = data["links"] - tmp.sort(key=get_sort_key) - data["links"] = tmp - return data - - except: - print_exc() - return HTTPError() - - -@route("/json/package_order/:ids") -@login_required('ADD') -def package_order(ids): - try: - pid, pos = ids.split("|") - PYLOAD.orderPackage(int(pid), int(pos)) - return {"response": "success"} - except: - return HTTPError() - - -@route("/json/abort_link/") -@login_required('DELETE') -def abort_link(id): - try: - PYLOAD.stopDownloads([id]) - return {"response": "success"} - except: - return HTTPError() - - -@route("/json/link_order/:ids") -@login_required('ADD') -def link_order(ids): - try: - pid, pos = ids.split("|") - PYLOAD.orderFile(int(pid), int(pos)) - return {"response": "success"} - except: - return HTTPError() - - -@route("/json/add_package") -@route("/json/add_package", method="POST") -@login_required('ADD') -def add_package(): - name = request.forms.get("add_name", "New Package").strip() - queue = int(request.forms['add_dest']) - links = decode(request.forms['add_links']) - links = links.split("\n") - pw = request.forms.get("add_password", "").strip("\n\r") - - try: - f = request.files['add_file'] - - if not name or name == "New Package": - name = f.name - - fpath = join(PYLOAD.getConfigValue("general", "download_folder"), "tmp_" + f.filename) - destination = open(fpath, 'wb') - copyfileobj(f.file, destination) - destination.close() - links.insert(0, fpath) - except: - pass - - name = name.decode("utf8", "ignore") - - links = map(lambda x: x.strip(), links) - links = filter(lambda x: x != "", links) - - PYLOAD.addPackage(name, links, queue, pw.decode("utf8", "ignore")) - - -@route("/json/move_package//") -@login_required('MODIFY') -def move_package(dest, id): - try: - PYLOAD.movePackage(dest, id) - return {"response": "success"} - except: - return HTTPError() - - -@route("/json/edit_package", method="POST") -@login_required('MODIFY') -def edit_package(): - try: - id = int(request.forms.get("pack_id")) - data = {"name": request.forms.get("pack_name").decode("utf8", "ignore"), - "folder": request.forms.get("pack_folder").decode("utf8", "ignore"), - "password": request.forms.get("pack_pws").decode("utf8", "ignore")} - - PYLOAD.setPackageData(id, data) - return {"response": "success"} - - except: - return HTTPError() - - -@route("/json/set_captcha") -@route("/json/set_captcha", method="POST") -@login_required('ADD') -def set_captcha(): - if request.environ.get('REQUEST_METHOD', "GET") == "POST": - try: - PYLOAD.setCaptchaResult(request.forms["cap_id"], request.forms["cap_result"]) - except: - pass - - task = PYLOAD.getCaptchaTask() - - if task.tid >= 0: - src = "data:image/%s;base64,%s" % (task.type, task.data) - - return {'captcha': True, 'id': task.tid, 'src': src, 'result_type' : task.resultType} - else: - return {'captcha': False} - - -@route("/json/load_config/:section") -@login_required("SETTINGS") -def load_config(section): - data = PYLOAD.configureSection(section) - return render_to_response("settings_item.html", {"section": data}) - - -@route("/json/save_config", method="POST") -@login_required("SETTINGS") -def save_config(): - for key, value in request.POST.iteritems(): - try: - section, option = key.split("|") - except: - continue - - PYLOAD.setConfigValue(section, option, decode(value)) - - -@route("/json/add_account", method="POST") -@login_required("ACCOUNTS") -def add_account(): - login = request.POST["account_login"] - password = request.POST["account_password"] - type = request.POST["account_type"] - - PYLOAD.updateAccount(type, login, password) - - -@route("/json/update_accounts", method="POST") -@login_required("ACCOUNTS") -def update_accounts(): - deleted = [] #dont update deleted accs or they will be created again - - for name, value in request.POST.iteritems(): - value = value.strip() - if not value: continue - - tmp, user = name.split(";") - plugin, action = tmp.split("|") - - if (plugin, user) in deleted: continue - - if action == "password": - PYLOAD.updateAccount(plugin, user, value) - elif action == "time" and "-" in value: - PYLOAD.updateAccount(plugin, user, options={"time": value}) - elif action == "limitdl" and value.isdigit(): - PYLOAD.updateAccount(plugin, user, options={"limitDL": value}) - elif action == "delete": - deleted.append((plugin,user)) - PYLOAD.removeAccount(plugin, user) - -@route("/json/change_password", method="POST") -def change_password(): - - user = request.POST["user_login"] - oldpw = request.POST["login_current_password"] - newpw = request.POST["login_new_password"] - - if not PYLOAD.changePassword(user, oldpw, newpw): - print "Wrong password" - return HTTPError() -- cgit v1.2.3