summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/CaptchaBrotherhood.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks/CaptchaBrotherhood.py')
-rw-r--r--module/plugins/hooks/CaptchaBrotherhood.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py
index 7bbd85659..ba9d3eb8e 100644
--- a/module/plugins/hooks/CaptchaBrotherhood.py
+++ b/module/plugins/hooks/CaptchaBrotherhood.py
@@ -14,7 +14,7 @@ from time import sleep
from urllib import urlencode
from pyload.network.RequestFactory import getURL, getRequest
-from pyload.plugin.Addon import Addon
+from module.plugins.Hook import Hook, threaded
class CaptchaBrotherhoodException(Exception):
@@ -38,7 +38,7 @@ class CaptchaBrotherhoodException(Exception):
class CaptchaBrotherhood(Addon):
__name__ = "CaptchaBrotherhood"
__type__ = "hook"
- __version__ = "0.06"
+ __version__ = "0.08"
__config__ = [("username", "str", "Username", ""),
("force", "bool", "Force CT even if client is connected", False),
@@ -84,10 +84,10 @@ class CaptchaBrotherhood(Addon):
req = getRequest()
url = "%ssendNewCaptcha.aspx?%s" % (self.API_URL,
- urlencode({"username": self.getConfig("username"),
- "password": self.getConfig("passkey"),
- "captchaSource": "pyLoad",
- "timeout": "80"}))
+ urlencode({'username' : self.getConfig("username"),
+ 'password' : self.getConfig("passkey"),
+ 'captchaSource': "pyLoad",
+ 'timeout' : "80"}))
req.c.setopt(pycurl.URL, url)
req.c.setopt(pycurl.POST, 1)
@@ -109,14 +109,14 @@ class CaptchaBrotherhood(Addon):
for _i in xrange(15):
sleep(5)
- res = self.get_api("askCaptchaResult", ticket)
+ res = self.api_response("askCaptchaResult", ticket)
if res.startswith("OK-answered"):
return ticket, res[12:]
raise CaptchaBrotherhoodException("No solution received in time")
- def get_api(self, api, ticket):
+ def api_response(self, api, ticket):
res = getURL("%s%s.aspx" % (self.API_URL, api),
get={"username": self.getConfig("username"),
"password": self.getConfig("passkey"),
@@ -144,17 +144,18 @@ class CaptchaBrotherhood(Addon):
task.handler.append(self)
task.data['service'] = self.__name__
task.setWaiting(100)
- self.processCaptcha(task)
+ self._processCaptcha(task)
else:
self.logInfo(_("Your CaptchaBrotherhood Account has not enough credits"))
def captchaInvalid(self, task):
if task.data['service'] == self.__name__ and "ticket" in task.data:
- res = self.get_api("complainCaptcha", task.data['ticket'])
+ res = self.api_response("complainCaptcha", task.data['ticket'])
- def processCaptcha(self, task):
+ @threaded
+ def _processCaptcha(self, task):
c = task.captchaFile
try:
ticket, result = self.submit(c)