diff options
author | 2013-07-24 14:24:51 +0200 | |
---|---|---|
committer | 2013-07-24 14:36:59 +0200 | |
commit | 9be1035b2945f82b269487a009c02bd5a83028b0 (patch) | |
tree | 83c2496c60ddb5de3821151b80d69b639f007fe3 /pyload/plugins/addons/BypassCaptcha.py | |
parent | Two more replace module import rules (diff) | |
download | pyload-9be1035b2945f82b269487a009c02bd5a83028b0.tar.xz |
Fixed PEP 8 violations in Hooks
(cherry picked from commit 669b1e0ec048e1ed8aeb842b2570376e9ad96863)
Conflicts:
pyload/plugins/addons/CaptchaTrader.py
pyload/plugins/addons/ClickAndLoad.py
pyload/plugins/addons/Ev0InFetcher.py
pyload/plugins/addons/ExternalScripts.py
pyload/plugins/addons/ExtractArchive.py
pyload/plugins/addons/HotFolder.py
pyload/plugins/addons/MergeFiles.py
pyload/plugins/addons/MultiHome.py
pyload/plugins/addons/XMPPInterface.py
Diffstat (limited to 'pyload/plugins/addons/BypassCaptcha.py')
-rw-r--r-- | pyload/plugins/addons/BypassCaptcha.py | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/pyload/plugins/addons/BypassCaptcha.py b/pyload/plugins/addons/BypassCaptcha.py index e24a439af..bd718ea7e 100644 --- a/pyload/plugins/addons/BypassCaptcha.py +++ b/pyload/plugins/addons/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) |