summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal/CaptchaService.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2013-11-17 19:29:37 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2013-11-23 17:39:12 +0100
commit92888358e14c0a9e50e5604095a1c148ccc8b80d (patch)
tree2c3f5b0c141ac90e34e2c8360886bc14f9715edd /module/plugins/internal/CaptchaService.py
parentMerge pull request #386 from vuolter/s/setup_clean (diff)
downloadpyload-92888358e14c0a9e50e5604095a1c148ccc8b80d.tar.xz
Internal plugins PEP8 cleanup
Diffstat (limited to 'module/plugins/internal/CaptchaService.py')
-rw-r--r--module/plugins/internal/CaptchaService.py37
1 files changed, 21 insertions, 16 deletions
diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py
index b912436a7..4aa3f7dad 100644
--- a/module/plugins/internal/CaptchaService.py
+++ b/module/plugins/internal/CaptchaService.py
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+
"""
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,49 +19,53 @@
import re
-class CaptchaService():
+
+class CaptchaService():
__version__ = "0.02"
-
+
def __init__(self, plugin):
self.plugin = plugin
-
+
+
class ReCaptcha():
def __init__(self, plugin):
self.plugin = plugin
-
+
def challenge(self, id):
- js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k":id}, cookies=True)
-
+ js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k": id}, cookies=True)
+
try:
challenge = re.search("challenge : '(.*?)',", js).group(1)
server = re.search("server : '(.*?)',", js).group(1)
except:
self.plugin.fail("recaptcha error")
- result = self.result(server,challenge)
-
+ result = self.result(server, challenge)
+
return challenge, result
def result(self, server, challenge):
- return self.plugin.decryptCaptcha("%simage"%server, get={"c":challenge}, cookies=True, forceUser=True, imgtype="jpg")
+ return self.plugin.decryptCaptcha("%simage" % server, get={"c": challenge}, cookies=True, forceUser=True, imgtype="jpg")
+
class AdsCaptcha(CaptchaService):
def challenge(self, src):
js = self.plugin.req.load(src, cookies=True)
-
+
try:
challenge = re.search("challenge: '(.*?)',", js).group(1)
server = re.search("server: '(.*?)',", js).group(1)
except:
self.plugin.fail("adscaptcha error")
- result = self.result(server,challenge)
-
+ result = self.result(server, challenge)
+
return challenge, result
def result(self, server, challenge):
return self.plugin.decryptCaptcha("%sChallenge.aspx" % server, get={"cid": challenge, "dummy": random()}, cookies=True, imgtype="jpg")
+
class SolveMedia(CaptchaService):
- def __init__(self,plugin):
+ def __init__(self, plugin):
self.plugin = plugin
def challenge(self, src):
@@ -70,8 +75,8 @@ class SolveMedia(CaptchaService):
except:
self.plugin.fail("solvmedia error")
result = self.result(challenge)
-
+
return challenge, result
- def result(self,challenge):
- return self.plugin.decryptCaptcha("http://api.solvemedia.com/papi/media?c=%s" % challenge,imgtype="gif") \ No newline at end of file
+ def result(self, challenge):
+ return self.plugin.decryptCaptcha("http://api.solvemedia.com/papi/media?c=%s" % challenge, imgtype="gif")