diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-02-07 19:49:38 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-02-07 19:49:38 +0100 |
commit | 15ff5792f74ffe8b0cdcf24fb91e4ae0c32e94c8 (patch) | |
tree | 954fc930c3a6cc002d0acc8fd6674884a02c82bd | |
parent | added Thrift backend (diff) | |
download | pyload-15ff5792f74ffe8b0cdcf24fb91e4ae0c32e94c8.tar.xz |
captchamanager fix
-rw-r--r-- | module/CaptchaManager.py | 17 | ||||
-rw-r--r-- | module/plugins/hooks/CaptchaTrader.py | 20 |
2 files changed, 21 insertions, 16 deletions
diff --git a/module/CaptchaManager.py b/module/CaptchaManager.py index 7c851a16e..1520bb1b9 100644 --- a/module/CaptchaManager.py +++ b/module/CaptchaManager.py @@ -59,10 +59,11 @@ class CaptchaManager(): return None def handleCaptcha(self, task): - if self.core.isClientConnected: #client connected -> should solve the captcha + cli = self.core.isClientConnected() + + if cli: #client connected -> should solve the captcha self.tasks.append(task) task.setWaiting(40) #wait 40 sec for response - return True for plugin in self.core.hookManager.activePlugins(): try: @@ -71,8 +72,8 @@ class CaptchaManager(): if self.core.debug: print_exc() - if task.handler: # a plugin handles the captcha - return True + if task.handler or cli: #the captcha was handled + return True task.error = _("No Client connected for captcha decrypting") @@ -85,7 +86,7 @@ class CaptchaTask(): self.captchaImg = img self.captchaType = type self.captchaFile = temp - self.handler = None #the hook plugin that will take care of the solution + self.handler = [] #the hook plugins that will take care of the solution self.result = None self.waitUntil = None self.error = None #error message @@ -132,12 +133,10 @@ class CaptchaTask(): def invalid(self): """ indicates the captcha was not correct """ - if self.handler: - self.handler.captchaInvalid() + [x.captchaInvalid() for x in self.handler] def correct(self): - if self.handler: - self.handler.captchaCorrect() + [x.captchaCorrect() for x in self.handler] def __str__(self): return "<CaptchaTask '%s'>" % self.id diff --git a/module/plugins/hooks/CaptchaTrader.py b/module/plugins/hooks/CaptchaTrader.py index 9bb8dd2f0..4b96f0922 100644 --- a/module/plugins/hooks/CaptchaTrader.py +++ b/module/plugins/hooks/CaptchaTrader.py @@ -47,9 +47,10 @@ class CaptchaTrader(Hook): __name__ = "CaptchaTrader" __version__ = "0.1" __description__ = """send captchas to captchatrader.com""" - __config__ = [("activated", "bool", "Activated", "True"), + __config__ = [("activated", "bool", "Activated", True), ("username", "str", "Username", ""), - ("passkey", "password", "Password", "")] + ("force", "bool", "Force CT even if client connected", False), + ("passkey", "password", "Password", ""),] __author_name__ = ("RaNaN") __author_mail__ = ("RaNaN@pyload.org") @@ -103,8 +104,10 @@ class CaptchaTrader(Hook): if not self.getConfig("username") or not self.getConfig("passkey"): return False - if self.getCredits() > 10: + if not (self.core.isClientConnected() and self.getConfig("force")): + return False + if self.getCredits() > 10: task.handler = self task.setWaiting(40) start_new_thread(self.processCaptcha, (task,)) @@ -113,12 +116,14 @@ class CaptchaTrader(Hook): self.log.info(_("Your CaptchaTrader Account has not enough credits")) def captchaCorrect(self, task): - ticket = task.data["ticket"] - self.respond(ticket, True) + if task.data.has_key("ticket"): + ticket = task.data["ticket"] + self.respond(ticket, True) def captchaWrong(self, task): - ticket = task.data["ticket"] - self.respond(ticket, True) + if task.data.has_key("ticket"): + ticket = task.data["ticket"] + self.respond(ticket, True) def processCaptcha(self, task): c = task.captchaFile @@ -126,6 +131,7 @@ class CaptchaTrader(Hook): ticket, result = self.submit(c) except CaptchaTraderException, e: task.error = e.getCode() + return task.data["ticket"] = ticket task.setResult(result) |