diff options
-rw-r--r-- | module/web/WebServer.py | 13 | ||||
-rw-r--r-- | module/web/static/default/status.js | 4 | ||||
-rw-r--r-- | module/web/templates/default.tpl | 6 | ||||
-rwxr-xr-x | pyLoadCore.py | 23 |
4 files changed, 37 insertions, 9 deletions
diff --git a/module/web/WebServer.py b/module/web/WebServer.py index 29b0aafe8..3486bf7cb 100644 --- a/module/web/WebServer.py +++ b/module/web/WebServer.py @@ -184,7 +184,7 @@ def queue(): username = request.COOKIES.get('user') - return template('default', page='queue', links=core.get_links(), user=username, status=core_methods.status_server()) + return template('default', page='queue', links=core_methods.get_queue(), user=username, status=core_methods.status_server()) @route('/downloads') def downloads(): @@ -252,6 +252,17 @@ def get_status(): json = '{ "status": "%s", "speed": "%s", "queue": "%s" }' % (status, str(int(data['speed'])), str(data['queue'])) return json +@route('json/addpackage', method='POST') +def add_package(): + response.header['Cache-Control'] = 'no-cache, must-revalidate' + response.content_type = 'application/json' + + if not check_auth(request): + abort(404, "No Access") + + links = request.POST['links'].split('\n') + name = request.POST['name'] + core_methods.add_package(name, links) @route('/json/addlinks', method='POST') def add_links(): diff --git a/module/web/static/default/status.js b/module/web/static/default/status.js index 31a4e0032..3923e80ca 100644 --- a/module/web/static/default/status.js +++ b/module/web/static/default/status.js @@ -39,11 +39,11 @@ window.addEvent('domready', function(){ new Request({ method: 'post', - url: '/json/addlinks', + url: '/json/addpackage', onSuccess: function(){ document.id('linkarea').value = "" } - }).send('links='+document.id('linkarea').value) + }).send('links='+document.id('linkarea').value+"&name="+document.id('pname').value) }) diff --git a/module/web/templates/default.tpl b/module/web/templates/default.tpl index 13be260b6..3f5e8d8e8 100644 --- a/module/web/templates/default.tpl +++ b/module/web/templates/default.tpl @@ -11,7 +11,7 @@ %include header title=header, use_js=js, use_css=['default.css','window.css'], redirect=red -%include window id="addlinks", width=400, caption="Add links", body="<textarea rows=10 style='width: 345px;' id='linkarea'></textarea>", button="Add" +%include window id="addlinks", width=400, caption="Add links", body="<input id='pname' type='text' style='width: 345px;' value='Package'/><textarea rows=10 style='width: 345px;' id='linkarea'></textarea>", button="Add" <a class="anchor" name="top" id="top"></a> @@ -199,9 +199,9 @@ this.morph({'color': '#000'}); <ul> -%for id in links['order']: +%for package in links: -<li>{{links[id].url}}</li> +<li>{{package.name}}</li> %end diff --git a/pyLoadCore.py b/pyLoadCore.py index b78cf5b5c..7218586e0 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -23,7 +23,6 @@ """ CURRENT_VERSION = '0.3' - import ConfigParser import gettext from glob import glob @@ -43,13 +42,14 @@ from sys import path from sys import stdout import time from time import sleep -import urllib2 from imp import find_module from re import sub from module.file_list import File_List from module.thread_list import Thread_List from module.network.Request import Request +from module.web.WebServer import WebServer import module.remote.SecureXMLRPCServer as Server + import thread class Core(object): @@ -113,6 +113,7 @@ class Core(object): translation.install(unicode=True) self.check_install("Crypto", "pycrypto to decode container files") + self.check_install("Image", "Python Image Libary (PIL) for captha reading") self.check_install("pycurl", "pycurl for lower memory footprint while downloading") self.check_install("tesseract", "tesseract for captcha reading", False) self.check_install("gocr", "gocr for captcha reading", False) @@ -139,6 +140,7 @@ class Core(object): self.thread_list = Thread_List(self) self.init_server() + self.init_webserver() self.logger.info(_("Downloadtime: %s") % self.server_methods.is_time_download()) # debug only @@ -290,6 +292,10 @@ class Core(object): elif start < now and end < now and start > end: return True else: return False + def init_webserver(self): + self.webserver = WebServer(self) + if self.config['webinterface']['activated']: + self.webserver.start() #################################### ########## XMLRPC Methods ########## #################################### @@ -324,7 +330,7 @@ class ServerMethods(): def status_server(self): status = {} status['pause'] = self.core.thread_list.pause - status['queue'] = len(self.core.file_list.files) + status['queue'] = len(self.core.file_list.data['queue']) status['speed'] = 0 for pyfile in self.core.thread_list.py_downloading: @@ -343,6 +349,17 @@ class ServerMethods(): self.core.file_list.collector.addLink(link) self.core.file_list.save() + def add_package(self, name, links): + pid = self.new_package(name) + self.core.file_list.packager.pushPackage2Queue(pid) + fids = [] + for link in links: + fids.append(self.core.file_list.collector.addLink(link)) + for fid in fids: + self.move_file_2_package(fid,pid) + + self.push_package_2_queue(pid) + def new_package(self, name): id = self.core.file_list.packager.addNewPackage(name) self.core.file_list.save() |