diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-12 19:23:51 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-04-12 19:23:51 +0200 |
commit | f0afbee15380bf5fc242fb3dd5439a9ea9c67d5c (patch) | |
tree | 7e82c022c157a39232fc590ab2ffa69787f5d260 /pyload/plugin/captcha | |
parent | Cleanup (diff) | |
parent | import fixes + code-cleanup (diff) | |
download | pyload-f0afbee15380bf5fc242fb3dd5439a9ea9c67d5c.tar.xz |
Merge branch 'pr/n3_ardi69' into 0.4.10
Conflicts:
pyload/plugin/Plugin.py
pyload/webui/app/pyloadweb.py
Diffstat (limited to 'pyload/plugin/captcha')
-rw-r--r-- | pyload/plugin/captcha/AdYouLike.py | 16 | ||||
-rw-r--r-- | pyload/plugin/captcha/ReCaptcha.py | 16 |
2 files changed, 10 insertions, 22 deletions
diff --git a/pyload/plugin/captcha/AdYouLike.py b/pyload/plugin/captcha/AdYouLike.py index 42441ee86..83fc4e1a3 100644 --- a/pyload/plugin/captcha/AdYouLike.py +++ b/pyload/plugin/captcha/AdYouLike.py @@ -15,11 +15,9 @@ class AdYouLike(Captcha): __license = "GPLv3" __authors = [("Walter Purcaro", "vuolter@gmail.com")] - AYL_PATTERN = r'Adyoulike\.create\s*\((.+?)\)' CALLBACK_PATTERN = r'(Adyoulike\.g\._jsonp_\d+)' - def detect_key(self, html=None): if not html: if hasattr(self.plugin, "html") and self.plugin.html: @@ -39,7 +37,6 @@ class AdYouLike(Captcha): self.logDebug("Ayl or callback not found") return None - def challenge(self, key=None, html=None): if not key: if self.detect_key(html): @@ -56,8 +53,8 @@ class AdYouLike(Captcha): ayl = json_loads(ayl) html = self.plugin.req.load("http://api-ayl.appspot.com/challenge", - get={'key' : ayl['adyoulike']['key'], - 'env' : ayl['all']['env'], + get={'key': ayl['adyoulike']['key'], + 'env': ayl['all']['env'], 'callback': callback}) try: challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1)) @@ -71,7 +68,6 @@ class AdYouLike(Captcha): return self.result(ayl, challenge), challenge - def result(self, server, challenge): # Adyoulike.g._jsonp_5579316662423138 # ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, @@ -98,11 +94,11 @@ class AdYouLike(Captcha): self.plugin.fail(errmsg) raise AttributeError(errmsg) - result = {'_ayl_captcha_engine' : "adyoulike", - '_ayl_env' : server['all']['env'], - '_ayl_tid' : challenge['tid'], + result = {'_ayl_captcha_engine': "adyoulike", + '_ayl_env': server['all']['env'], + '_ayl_tid': challenge['tid'], '_ayl_token_challenge': challenge['token'], - '_ayl_response' : response} + '_ayl_response': response} self.logDebug("Result: %s" % result) diff --git a/pyload/plugin/captcha/ReCaptcha.py b/pyload/plugin/captcha/ReCaptcha.py index 4f35ed30b..410cb19de 100644 --- a/pyload/plugin/captcha/ReCaptcha.py +++ b/pyload/plugin/captcha/ReCaptcha.py @@ -18,14 +18,12 @@ class ReCaptcha(Captcha): __description = """ReCaptcha captcha service plugin""" __license = "GPLv3" __authors = [("pyLoad Team", "admin@pyload.org"), - ("Walter Purcaro", "vuolter@gmail.com"), - ("zapp-brannigan", "fuerst.reinje@web.de")] - + ("Walter Purcaro", "vuolter@gmail.com"), + ("zapp-brannigan", "fuerst.reinje@web.de")] KEY_V2_PATTERN = r'(?:data-sitekey=["\']|["\']sitekey["\']:\s*["\'])([\w-]+)' KEY_V1_PATTERN = r'(?:recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=|Recaptcha\.create\s*\(\s*["\'])([\w-]+)' - def detect_key(self, html=None): if not html: if hasattr(self.plugin, "html") and self.plugin.html: @@ -44,7 +42,6 @@ class ReCaptcha(Captcha): self.logDebug("Key not found") return None - def challenge(self, key=None, html=None, version=None): if not key: if self.detect_key(html): @@ -66,7 +63,6 @@ class ReCaptcha(Captcha): self.plugin.fail(errmsg) raise TypeError(errmsg) - def _challenge_v1(self, key): html = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) @@ -83,7 +79,6 @@ class ReCaptcha(Captcha): return self.result(server, challenge), challenge - def result(self, server, challenge): result = self.plugin.decryptCaptcha("%simage" % server, get={'c': challenge}, @@ -95,13 +90,12 @@ class ReCaptcha(Captcha): return result - def _collectApiInfo(self): html = self.plugin.req.load("http://www.google.com/recaptcha/api.js") a = re.search(r'po.src = \'(.*?)\';', html).group(1) vers = a.split("/")[5] - self.logDebug("API version: %s" %vers) + self.logDebug("API version: %s" % vers) language = a.split("__")[1].split(".")[0] @@ -115,7 +109,6 @@ class ReCaptcha(Captcha): return vers, language, jsh - def _prepareTimeAndRpc(self): self.plugin.req.load("http://www.google.com/recaptcha/api2/demo") @@ -131,7 +124,6 @@ class ReCaptcha(Captcha): return millis, rpc - def _challenge_v2(self, key, parent=None): if parent is None: try: @@ -183,7 +175,7 @@ class ReCaptcha(Captcha): millis_captcha_loading = int(round(time.time() * 1000)) captcha_response = self.plugin.decryptCaptcha("https://www.google.com/recaptcha/api2/payload", - get={'c':token4.group(1), 'k':key}, + get={'c': token4.group(1), 'k': key}, cookies=True, forceUser=True) response = b64encode('{"response":"%s"}' % captcha_response) |