summaryrefslogtreecommitdiffstats
path: root/pyLoadCore.py
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2009-12-30 12:35:03 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2009-12-30 12:35:03 +0100
commitc1516088e4e7f76dddd68ef71f58c6413862e31c (patch)
tree9e392f79fc225934b8a0a99cc4a119332b6685e0 /pyLoadCore.py
parentmessed up last commit message; added new icons, default connection in gui, pu... (diff)
downloadpyload-c1516088e4e7f76dddd68ef71f58c6413862e31c.tar.xz
show captchas in gui, SerienjunkiesOrg plugin
Diffstat (limited to 'pyLoadCore.py')
-rwxr-xr-xpyLoadCore.py47
1 files changed, 40 insertions, 7 deletions
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 6b38d425c..4ca81efed 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -50,12 +50,16 @@ from time import sleep
from shutil import copyfile
from tempfile import NamedTemporaryFile
-from module.file_list import File_List
from module.network.Request import Request
import module.remote.SecureXMLRPCServer as Server
+from module.XMLConfigParser import XMLConfigParser
+
+from module.file_list import File_List
from module.thread_list import Thread_List
from module.web.ServerThread import WebServer
-from module.XMLConfigParser import XMLConfigParser
+from module.CaptchaManager import CaptchaManager
+
+from xmlrpclib import Binary
class Core(object):
""" pyLoad Core """
@@ -121,10 +125,13 @@ class Core(object):
self.init_scripts()
path.append(self.plugin_folder)
self.create_plugin_index()
-
+
+ self.lastGuiConnected = 0
+
self.server_methods = ServerMethods(self)
self.file_list = File_List(self)
- self.thread_list = Thread_List(self)
+ self.thread_list = Thread_List(self)
+ self.captchaManager = CaptchaManager(self)
self.last_update_check = 0
self.update_check_interval = 1800
@@ -135,7 +142,7 @@ class Core(object):
self.logger.info(_("Downloadtime: %s") % self.server_methods.is_time_download()) # debug only
-
+
#read url list @mkaay: pid, lid?
# pid = package id
# lid = link/file id
@@ -273,7 +280,10 @@ class Core(object):
print _("could not create %s: %s") % (description, tmp_name)
if essential:
exit()
-
+
+ def isGUIConnected(self):
+ return self.lastGuiConnected+10 > time.time()
+
def restart(self):
self.shutdown()
execv(executable, [executable, "pyLoadCore.py"])
@@ -556,7 +566,30 @@ class ServerMethods():
self.core.file_list.packager.setPackageData(pid, package_name=name)
def pull_out_package(self, pid):
- self.core.file_list.packager.pullOutPackage(pid)
+ self.core.file_list.packager.pullOutPackage(pid)
+
+ def is_captcha_waiting(self):
+ self.core.lastGuiConnected = time.time()
+ task = self.core.captchaManager.getTask()
+ return not task == None
+
+ def get_captcha_task(self):
+ task = self.core.captchaManager.getTask()
+ if task:
+ task.setWatingForUser()
+ c = task.getCaptcha()
+ return str(task.getID()), Binary(c[0]), str(c[1])
+ else:
+ return None, None, None
+
+ def set_captcha_result(self, tid, result):
+ task = self.core.captchaManager.getTaskFromID(tid)
+ if task:
+ task.setResult(result)
+ task.setDone()
+ return True
+ else:
+ return False
#def move_urls_up(self, ids):
# for id in ids: