summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/BypassCaptcha.py
diff options
context:
space:
mode:
authorGravatar Stefano <l.stickell@yahoo.it> 2013-07-24 14:24:51 +0200
committerGravatar Stefano <l.stickell@yahoo.it> 2013-07-24 14:24:51 +0200
commit669b1e0ec048e1ed8aeb842b2570376e9ad96863 (patch)
tree4703826f0c65f84ec5e9f1bac2d9dbd50e3376fa /module/plugins/hooks/BypassCaptcha.py
parentDebridItaliaCom: two more hosters supported (diff)
downloadpyload-669b1e0ec048e1ed8aeb842b2570376e9ad96863.tar.xz
Fixed PEP 8 violations in Hooks
Diffstat (limited to 'module/plugins/hooks/BypassCaptcha.py')
-rw-r--r--module/plugins/hooks/BypassCaptcha.py40
1 files changed, 18 insertions, 22 deletions
diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py
index e24a439af..bd718ea7e 100644
--- a/module/plugins/hooks/BypassCaptcha.py
+++ b/module/plugins/hooks/BypassCaptcha.py
@@ -26,6 +26,7 @@ from module.plugins.Hook import Hook
PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32"
+
class BypassCaptchaException(Exception):
def __init__(self, err):
self.err = err
@@ -39,6 +40,7 @@ class BypassCaptchaException(Exception):
def __repr__(self):
return "<BypassCaptchaException %s>" % self.err
+
class BypassCaptcha(Hook):
__name__ = "BypassCaptcha"
__version__ = "0.04"
@@ -57,13 +59,10 @@ class BypassCaptcha(Hook):
self.info = {}
def getCredits(self):
- response = getURL(self.GETCREDITS_URL,
- post = {"key": self.getConfig("passkey")}
- )
-
- data = dict([x.split(' ',1) for x in response.splitlines()])
+ response = getURL(self.GETCREDITS_URL, post={"key": self.getConfig("passkey")})
+
+ data = dict([x.split(' ', 1) for x in response.splitlines()])
return int(data['Left'])
-
def submit(self, captcha, captchaType="file", match=None):
req = getRequest()
@@ -72,39 +71,36 @@ class BypassCaptcha(Hook):
req.c.setopt(LOW_SPEED_TIME, 80)
try:
- response = req.load(self.SUBMIT_URL,
- post={"vendor_key": PYLOAD_KEY,
- "key": self.getConfig("passkey"),
- "gen_task_id": "1",
- "file": (FORM_FILE, captcha)},
- multipart=True)
+ response = req.load(self.SUBMIT_URL,
+ post={"vendor_key": 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 response.splitlines()])
if not data or "Value" not in data:
raise BypassCaptchaException(response)
-
+
result = data['Value']
ticket = data['TaskId']
- self.logDebug("result %s : %s" % (ticket,result))
+ self.logDebug("result %s : %s" % (ticket, result))
return ticket, result
def respond(self, ticket, success):
try:
- response = getURL(self.RESPOND_URL,
- post={"task_id": ticket,
- "key": self.getConfig("passkey"),
- "cv": 1 if success else 0}
- )
+ response = 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.", str(e))
def newCaptchaTask(self, task):
if "service" in task.data:
return False
-
+
if not task.isTextual():
return False
@@ -140,4 +136,4 @@ class BypassCaptcha(Hook):
return
task.data["ticket"] = ticket
- task.setResult(result) \ No newline at end of file
+ task.setResult(result)