summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/hook/BypassCaptcha.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/plugins/hook/BypassCaptcha.py')
-rw-r--r--pyload/plugins/hook/BypassCaptcha.py50
1 files changed, 30 insertions, 20 deletions
diff --git a/pyload/plugins/hook/BypassCaptcha.py b/pyload/plugins/hook/BypassCaptcha.py
index 02b72c6d0..8b34777f0 100644
--- a/pyload/plugins/hook/BypassCaptcha.py
+++ b/pyload/plugins/hook/BypassCaptcha.py
@@ -13,29 +13,32 @@ class BypassCaptchaException(Exception):
def __init__(self, err):
self.err = err
+
def getCode(self):
return self.err
+
def __str__(self):
return "<BypassCaptchaException %s>" % self.err
+
def __repr__(self):
return "<BypassCaptchaException %s>" % self.err
class BypassCaptcha(Hook):
- __name__ = "BypassCaptcha"
- __type__ = "hook"
+ __name__ = "BypassCaptcha"
+ __type__ = "hook"
__version__ = "0.04"
- __config__ = [("activated", "bool", "Activated", False),
- ("force", "bool", "Force BC even if client is connected", False),
+ __config__ = [("force", "bool", "Force BC even if client is connected", False),
("passkey", "password", "Passkey", "")]
__description__ = """Send captchas to BypassCaptcha.com"""
- __authors__ = [("RaNaN", "RaNaN@pyload.org"),
- ("Godofdream", "soilfcition@gmail.com"),
- ("zoidberg", "zoidberg@mujmail.cz")]
+ __license__ = "GPLv3"
+ __authors__ = [("RaNaN", "RaNaN@pyload.org"),
+ ("Godofdream", "soilfcition@gmail.com"),
+ ("zoidberg", "zoidberg@mujmail.cz")]
PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32"
@@ -46,14 +49,16 @@ class BypassCaptcha(Hook):
def setup(self):
- self.info = {}
+ self.info = {} #@TODO: Remove in 0.4.10
+
def getCredits(self):
- response = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")})
+ res = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")})
- data = dict([x.split(' ', 1) for x in response.splitlines()])
+ data = dict([x.split(' ', 1) for x in res.splitlines()])
return int(data['Left'])
+
def submit(self, captcha, captchaType="file", match=None):
req = getRequest()
@@ -61,18 +66,18 @@ class BypassCaptcha(Hook):
req.c.setopt(LOW_SPEED_TIME, 80)
try:
- response = req.load(self.SUBMIT_URL,
- post={"vendor_key": self.PYLOAD_KEY,
- "key": self.getConfig("passkey"),
- "gen_task_id": "1",
- "file": (FORM_FILE, captcha)},
- multipart=True)
+ res = req.load(self.SUBMIT_URL,
+ post={'vendor_key': self.PYLOAD_KEY,
+ 'key': self.getConfig("passkey"),
+ 'gen_task_id': "1",
+ 'file': (FORM_FILE, captcha)},
+ multipart=True)
finally:
req.close()
- data = dict([x.split(' ', 1) for x in response.splitlines()])
+ data = dict([x.split(' ', 1) for x in res.splitlines()])
if not data or "Value" not in data:
- raise BypassCaptchaException(response)
+ raise BypassCaptchaException(res)
result = data['Value']
ticket = data['TaskId']
@@ -80,12 +85,14 @@ class BypassCaptcha(Hook):
return ticket, result
+
def respond(self, ticket, success):
try:
- response = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig("passkey"),
+ res = getURL(self.RESPOND_URL, post={"task_id": ticket, "key": self.getConfig("passkey"),
"cv": 1 if success else 0})
except BadHeader, e:
- self.logError(_("Could not send response."), e
+ self.logError(_("Could not send response"), e)
+
def newCaptchaTask(self, task):
if "service" in task.data:
@@ -109,14 +116,17 @@ class BypassCaptcha(Hook):
else:
self.logInfo(_("Your %s account has not enough credits") % self.__name__)
+
def captchaCorrect(self, task):
if task.data['service'] == self.__name__ and "ticket" in task.data:
self.respond(task.data['ticket'], True)
+
def captchaInvalid(self, task):
if task.data['service'] == self.__name__ and "ticket" in task.data:
self.respond(task.data['ticket'], False)
+
def processCaptcha(self, task):
c = task.captchaFile
try: