From 08ee77db1b3ec0cd42e40e35c07c6c3882d940bf Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 10 Jul 2014 03:31:21 +0200 Subject: [CaptchaService] Remove SolveMedia __init__ --- module/plugins/internal/CaptchaService.py | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 400484d26..30f9e8d14 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -1,28 +1,11 @@ # -*- 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 - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . - - @author: zoidberg -""" - import re from random import random class CaptchaService(): - __version__ = "0.04" + __version__ = "0.05" def __init__(self, plugin): self.plugin = plugin @@ -88,9 +71,6 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): - def __init__(self, plugin): - self.plugin = plugin - def challenge(self, src): html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript?k=%s" % src, cookies=True) try: -- cgit v1.2.3 From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/internal/CaptchaService.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 30f9e8d14..c2c66ed31 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -5,8 +5,14 @@ from random import random class CaptchaService(): + __name__ = "CaptchaService" __version__ = "0.05" + __description__ = """Captcha service plugin""" + __author_name__ = "pyLoad Team" + __author_mail__ = "admin@pyload.org" + + def __init__(self, plugin): self.plugin = plugin @@ -17,6 +23,7 @@ class ReCaptcha(): recaptcha_key = None + def __init__(self, plugin): self.plugin = plugin -- cgit v1.2.3 From 31449f9e22cf4b5ae0f147a46bcbbf6f53a098a5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 14 Jul 2014 02:27:08 +0200 Subject: Fix class definition --- module/plugins/internal/CaptchaService.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index c2c66ed31..b2f73e4ea 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -4,7 +4,7 @@ import re from random import random -class CaptchaService(): +class CaptchaService: __name__ = "CaptchaService" __version__ = "0.05" @@ -17,7 +17,7 @@ class CaptchaService(): self.plugin = plugin -class ReCaptcha(): +class ReCaptcha: RECAPTCHA_KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+)" RECAPTCHA_KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P\w+)[\"']\s*," -- cgit v1.2.3 From 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 16:25:41 +0200 Subject: Fix code indentation, some bad whitespaces and missing authors + use 'not' instead 'is None' + replace __pattern__'s r" with r' + other minor cosmetics --- module/plugins/internal/CaptchaService.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index b2f73e4ea..d8306bbb7 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -60,6 +60,7 @@ class ReCaptcha: class AdsCaptcha(CaptchaService): + def challenge(self, src): js = self.plugin.req.load(src, cookies=True) -- cgit v1.2.3 From 8e47b0de30a25d0fd5dfb518bfe4e1e7beff93fd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 15 Jul 2014 16:27:44 +0200 Subject: Key attributes cleanup for account, container and crypter plugins --- module/plugins/internal/CaptchaService.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index d8306bbb7..6586256f7 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -79,6 +79,7 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): + def challenge(self, src): html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript?k=%s" % src, cookies=True) try: -- cgit v1.2.3 From 05d258d98dd8c2faf0b769840fa1e3c4acccdce8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 20 Jul 2014 03:25:14 +0200 Subject: Fix and improve 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 --- module/plugins/internal/CaptchaService.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 6586256f7..d325d7928 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -29,7 +29,7 @@ class ReCaptcha: def detect_key(self, html): m = re.search(self.RECAPTCHA_KEY_PATTERN, html) - if not m: + if m is None: m = re.search(self.RECAPTCHA_KEY_AJAX_PATTERN, html) if m: self.recaptcha_key = m.group('key') @@ -38,9 +38,9 @@ class ReCaptcha: return None def challenge(self, key=None): - if not key and self.recaptcha_key: + if key is None and self.recaptcha_key: key = self.recaptcha_key - elif not (key or self.recaptcha_key): + else: raise TypeError("ReCaptcha key not found") js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k": key}, cookies=True) -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/internal/CaptchaService.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index d325d7928..b247ba654 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import re + from random import random -- cgit v1.2.3 From 0c2c1f9e7c514a77fdb04329322fab2ed601df01 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 26 Sep 2014 19:09:47 +0200 Subject: [CaptchaService] Fix ReCaptcha key recognition Fix: https://github.com/pyload/pyload/issues/751 --- module/plugins/internal/CaptchaService.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index b247ba654..26482379d 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.05" + __version__ = "0.06" __description__ = """Captcha service plugin""" __author_name__ = "pyLoad Team" @@ -28,6 +28,7 @@ class ReCaptcha: def __init__(self, plugin): self.plugin = plugin + def detect_key(self, html): m = re.search(self.RECAPTCHA_KEY_PATTERN, html) if m is None: @@ -38,11 +39,13 @@ class ReCaptcha: else: return None + def challenge(self, key=None): - if key is None and self.recaptcha_key: - key = self.recaptcha_key - else: - raise TypeError("ReCaptcha key not found") + if not key: + if self.recaptcha_key: + key = self.recaptcha_key + else: + raise TypeError("ReCaptcha key not found") js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k": key}, cookies=True) @@ -55,6 +58,7 @@ class ReCaptcha: return challenge, result + def result(self, server, challenge): return self.plugin.decryptCaptcha("%simage" % server, get={"c": challenge}, cookies=True, forceUser=True, imgtype="jpg") @@ -74,6 +78,7 @@ class AdsCaptcha(CaptchaService): return challenge, result + def result(self, server, challenge): return self.plugin.decryptCaptcha("%sChallenge.aspx" % server, get={"cid": challenge, "dummy": random()}, cookies=True, imgtype="jpg") @@ -92,5 +97,6 @@ class SolveMedia(CaptchaService): return challenge, result + def result(self, challenge): return self.plugin.decryptCaptcha("http://api.solvemedia.com/papi/media?c=%s" % challenge, imgtype="gif") -- cgit v1.2.3 From 37e66401e68c082900ff98da6e38ca092a024933 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 3 Oct 2014 09:08:53 +0200 Subject: [CaptchaService] Improved --- module/plugins/internal/CaptchaService.py | 169 +++++++++++++++++++++++------- 1 file changed, 134 insertions(+), 35 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 26482379d..72a8f8789 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,96 +7,195 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.06" + __version__ = "0.07" - __description__ = """Captcha service plugin""" + __description__ = """Base captcha service plugin""" __author_name__ = "pyLoad Team" __author_mail__ = "admin@pyload.org" + KEY_PATTERN = None + + key = None + def __init__(self, plugin): self.plugin = plugin -class ReCaptcha: - RECAPTCHA_KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+)" - RECAPTCHA_KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P\w+)[\"']\s*," + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = "%s html missing" % self.__name__ + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.KEY_PATTERN, html) + if m: + self.key = m.group("KEY") + self.plugin.logDebug("%s key: %s" % (self.__name__, self.key) + return self.key + else: + self.plugin.logDebug("%s key not found" % self.__name__) + return None + + + def challenge(self, key): + raise NotImplementedError - recaptcha_key = None + def result(self, server, challenge): + raise NotImplementedError - def __init__(self, plugin): - self.plugin = plugin +class ReCaptcha(CaptchaService): + __name__ = "ReCaptcha" + __version__ = "0.02" - def detect_key(self, html): - m = re.search(self.RECAPTCHA_KEY_PATTERN, html) + __description__ = """ReCaptcha captcha service plugin""" + __author_name__ = "pyLoad Team" + __author_mail__ = "admin@pyload.org" + + + KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+?)" + KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P\w+)[\"']\s*," + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = "ReCaptcha html missing" + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.KEY_PATTERN, html) if m is None: - m = re.search(self.RECAPTCHA_KEY_AJAX_PATTERN, html) + m = re.search(self.KEY_AJAX_PATTERN, html) if m: - self.recaptcha_key = m.group('key') - return self.recaptcha_key + self.key = m.group("KEY") + self.plugin.logDebug("ReCaptcha key: %s" % self.key) + return self.key else: + self.plugin.logDebug("ReCaptcha key not found") return None - def challenge(self, key=None): + def challenge(self, key=key): if not key: - if self.recaptcha_key: - key = self.recaptcha_key - else: - raise TypeError("ReCaptcha key not found") + errmsg = "ReCaptcha key missing" + self.plugin.fail(errmsg) + raise TypeError(errmsg) - js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k": key}, cookies=True) + js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}, cookies=True) try: - challenge = re.search("challenge : '(.*?)',", js).group(1) - server = re.search("server : '(.*?)',", js).group(1) + challenge = re.search("challenge : '(.+?)',", js).group(1) + server = re.search("server : '(.+?)',", js).group(1) except: - self.plugin.fail("recaptcha error") + self.plugin.parseError("ReCaptcha challenge pattern not found") + result = self.result(server, challenge) return challenge, result def result(self, server, challenge): - return self.plugin.decryptCaptcha("%simage" % server, get={"c": challenge}, + return self.plugin.decryptCaptcha("%simage" % server, get={'c': challenge}, cookies=True, forceUser=True, imgtype="jpg") class AdsCaptcha(CaptchaService): + __name__ = "AdsCaptcha" + __version__ = "0.02" - def challenge(self, src): - js = self.plugin.req.load(src, cookies=True) + __description__ = """AdsCaptcha captcha service plugin""" + __author_name__ = "pyLoad Team" + __author_mail__ = "admin@pyload.org" + + + ID_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P\d+)' + KEY_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P[\w-]+)' + + + def detect_key(self, html=None): + if not html: + if hasattr(self.plugin, "html") and self.plugin.html: + html = self.plugin.html + else: + errmsg = "AdsCaptcha html missing" + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + m = re.search(self.ID_PATTERN, html) + n = re.search(self.KEY_PATTERN, html) + if m and n: + self.key = (m.group("ID"), m.group("KEY")) + self.plugin.logDebug("AdsCaptcha id|key: %s | %s" % self.key) + return self.key + else: + self.plugin.logDebug("AdsCaptcha id or key not found") + return None + + + def challenge(self, key=key): #: key is tuple(CaptchaId, PublicKey) + CaptchaId, PublicKey = key + + if not CaptchaId or not PublicKey: + errmsg = "AdsCaptcha key missing" + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}, cookies=True) try: - challenge = re.search("challenge: '(.*?)',", js).group(1) - server = re.search("server: '(.*?)',", js).group(1) + challenge = re.search("challenge: '(.+?)',", js).group(1) + server = re.search("server: '(.+?)',", js).group(1) except: - self.plugin.fail("adscaptcha error") + self.plugin.parseError("AdsCaptcha challenge pattern not found") + 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()}, + return self.plugin.decryptCaptcha("%sChallenge.aspx" % server, get={'cid': challenge, 'dummy': random()}, cookies=True, imgtype="jpg") class SolveMedia(CaptchaService): + __name__ = "SolveMedia" + __version__ = "0.02" - def challenge(self, src): - html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript?k=%s" % src, cookies=True) + __description__ = """SolveMedia captcha service plugin""" + __author_name__ = "pyLoad Team" + __author_mail__ = "admin@pyload.org" + + + KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)"' + + + def challenge(self, key=key): + if not key: + errmsg = "SolveMedia key missing" + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}, cookies=True) try: challenge = re.search(r'', html).group(1) + server = "http://api.solvemedia.com/papi/media" except: - self.plugin.fail("solvemedia error") - result = self.result(challenge) + self.plugin.parseError("SolveMedia challenge pattern not found") + + result = self.result(server, challenge) return challenge, result - def result(self, challenge): - return self.plugin.decryptCaptcha("http://api.solvemedia.com/papi/media?c=%s" % challenge, imgtype="gif") + def result(self, server, challenge): + return self.plugin.decryptCaptcha(server, get={'c': challenge}, imgtype="gif") -- cgit v1.2.3 From 7b3e630f60ab2a917106cc6e09b92123001a0083 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 3 Oct 2014 09:25:46 +0200 Subject: [CaptchaService] Fix code indentation typo --- module/plugins/internal/CaptchaService.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 72a8f8789..caac14d61 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.07" + __version__ = "0.08" __description__ = """Base captcha service plugin""" __author_name__ = "pyLoad Team" @@ -83,7 +83,7 @@ class ReCaptcha(CaptchaService): return None - def challenge(self, key=key): + def challenge(self, key=key): if not key: errmsg = "ReCaptcha key missing" self.plugin.fail(errmsg) -- cgit v1.2.3 From 8e9afb4c9c83a2a46cc491fe9f48d22284759bf0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 3 Oct 2014 10:52:14 +0200 Subject: [CaptchaService] Fix typo --- module/plugins/internal/CaptchaService.py | 41 +++++++++++++++++++------------ 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index caac14d61..45e56ba42 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.08" + __version__ = "0.09" __description__ = """Base captcha service plugin""" __author_name__ = "pyLoad Team" @@ -34,7 +34,7 @@ class CaptchaService: m = re.search(self.KEY_PATTERN, html) if m: self.key = m.group("KEY") - self.plugin.logDebug("%s key: %s" % (self.__name__, self.key) + self.plugin.logDebug("%s key: %s" % (self.__name__, self.key)) return self.key else: self.plugin.logDebug("%s key not found" % self.__name__) @@ -83,11 +83,14 @@ class ReCaptcha(CaptchaService): return None - def challenge(self, key=key): + def challenge(self, key): if not key: - errmsg = "ReCaptcha key missing" - self.plugin.fail(errmsg) - raise TypeError(errmsg) + if self.key: + key = self.key + else: + errmsg = "ReCaptcha key missing" + self.plugin.fail(errmsg) + raise TypeError(errmsg) js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}, cookies=True) @@ -140,13 +143,16 @@ class AdsCaptcha(CaptchaService): return None - def challenge(self, key=key): #: key is tuple(CaptchaId, PublicKey) - CaptchaId, PublicKey = key + def challenge(self, key): #: key is tuple(CaptchaId, PublicKey) + if not key: + if self.key: + key = self.key + else: + errmsg = "AdsCaptcha key missing" + self.plugin.fail(errmsg) + raise TypeError(errmsg) - if not CaptchaId or not PublicKey: - errmsg = "AdsCaptcha key missing" - self.plugin.fail(errmsg) - raise TypeError(errmsg) + CaptchaId, PublicKey = key js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}, cookies=True) @@ -178,11 +184,14 @@ class SolveMedia(CaptchaService): KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)"' - def challenge(self, key=key): + def challenge(self, key): if not key: - errmsg = "SolveMedia key missing" - self.plugin.fail(errmsg) - raise TypeError(errmsg) + if self.key: + key = self.key + else: + errmsg = "SolveMedia key missing" + self.plugin.fail(errmsg) + raise TypeError(errmsg) html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}, cookies=True) try: -- cgit v1.2.3 From 0d4b92d58e6d4e959aeaa780cf29b8d88f46610a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 3 Oct 2014 14:00:46 +0200 Subject: Spare code cosmetics --- module/plugins/internal/CaptchaService.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 45e56ba42..b2fba0652 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -41,7 +41,7 @@ class CaptchaService: return None - def challenge(self, key): + def challenge(self, key=None): raise NotImplementedError @@ -83,7 +83,7 @@ class ReCaptcha(CaptchaService): return None - def challenge(self, key): + def challenge(self, key=None): if not key: if self.key: key = self.key @@ -143,7 +143,7 @@ class AdsCaptcha(CaptchaService): return None - def challenge(self, key): #: key is tuple(CaptchaId, PublicKey) + def challenge(self, key=None): #: key is tuple(CaptchaId, PublicKey) if not key: if self.key: key = self.key @@ -184,7 +184,7 @@ class SolveMedia(CaptchaService): KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)"' - def challenge(self, key): + def challenge(self, key=None): if not key: if self.key: key = self.key -- cgit v1.2.3 From 1047c706d41dec4a49a747496c2ec01ed3bf7801 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 5 Oct 2014 01:54:58 +0200 Subject: Use load instead req.load in all crypters and CaptchaService --- module/plugins/internal/CaptchaService.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index b2fba0652..35074bc63 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -92,7 +92,7 @@ class ReCaptcha(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}, cookies=True) + js = self.plugin.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}, cookies=True) try: challenge = re.search("challenge : '(.+?)',", js).group(1) @@ -154,7 +154,7 @@ class AdsCaptcha(CaptchaService): CaptchaId, PublicKey = key - js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}, cookies=True) + js = self.plugin.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}, cookies=True) try: challenge = re.search("challenge: '(.+?)',", js).group(1) @@ -193,7 +193,7 @@ class SolveMedia(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}, cookies=True) + html = self.plugin.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}, cookies=True) try: challenge = re.search(r'', html).group(1) -- cgit v1.2.3 From 6ec5c8215a774455b405db28ad9d936a5ee60215 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 6 Oct 2014 13:26:06 +0200 Subject: [CaptchaService] Restore req.load --- module/plugins/internal/CaptchaService.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 35074bc63..b2fba0652 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -92,7 +92,7 @@ class ReCaptcha(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - js = self.plugin.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}, cookies=True) + js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}, cookies=True) try: challenge = re.search("challenge : '(.+?)',", js).group(1) @@ -154,7 +154,7 @@ class AdsCaptcha(CaptchaService): CaptchaId, PublicKey = key - js = self.plugin.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}, cookies=True) + js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}, cookies=True) try: challenge = re.search("challenge: '(.+?)',", js).group(1) @@ -193,7 +193,7 @@ class SolveMedia(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - html = self.plugin.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}, cookies=True) + html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}, cookies=True) try: challenge = re.search(r'', html).group(1) -- cgit v1.2.3 From b0868ae6446078bacf1635dde5e4ab316b4a94cb Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Oct 2014 18:57:59 +0200 Subject: New __authors__ key replaces __author_name__ and __author_mail__ + Whitespaces and EOF fixup --- module/plugins/internal/CaptchaService.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index b2fba0652..dad537bec 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -10,8 +10,8 @@ class CaptchaService: __version__ = "0.09" __description__ = """Base captcha service plugin""" - __author_name__ = "pyLoad Team" - __author_mail__ = "admin@pyload.org" + __authors__ = [("pyLoad Team", "admin@pyload.org")] + KEY_PATTERN = None @@ -54,8 +54,7 @@ class ReCaptcha(CaptchaService): __version__ = "0.02" __description__ = """ReCaptcha captcha service plugin""" - __author_name__ = "pyLoad Team" - __author_mail__ = "admin@pyload.org" + __authors__ = [("pyLoad Team", "admin@pyload.org")] KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+?)" @@ -115,8 +114,7 @@ class AdsCaptcha(CaptchaService): __version__ = "0.02" __description__ = """AdsCaptcha captcha service plugin""" - __author_name__ = "pyLoad Team" - __author_mail__ = "admin@pyload.org" + __authors__ = [("pyLoad Team", "admin@pyload.org")] ID_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P\d+)' @@ -177,8 +175,7 @@ class SolveMedia(CaptchaService): __version__ = "0.02" __description__ = """SolveMedia captcha service plugin""" - __author_name__ = "pyLoad Team" - __author_mail__ = "admin@pyload.org" + __authors__ = [("pyLoad Team", "admin@pyload.org")] KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)"' -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- module/plugins/internal/CaptchaService.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index dad537bec..187170660 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -10,6 +10,7 @@ class CaptchaService: __version__ = "0.09" __description__ = """Base captcha service plugin""" + __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] @@ -54,6 +55,7 @@ class ReCaptcha(CaptchaService): __version__ = "0.02" __description__ = """ReCaptcha captcha service plugin""" + __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] @@ -114,6 +116,7 @@ class AdsCaptcha(CaptchaService): __version__ = "0.02" __description__ = """AdsCaptcha captcha service plugin""" + __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] @@ -175,6 +178,7 @@ class SolveMedia(CaptchaService): __version__ = "0.02" __description__ = """SolveMedia captcha service plugin""" + __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] -- cgit v1.2.3 From 343e246e94548cf2cc713aed92212e12d28ce658 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 10 Oct 2014 16:00:34 +0200 Subject: [CaptchaService] Fix ReCaptcha KEY pattern --- module/plugins/internal/CaptchaService.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 187170660..9d8fd85f2 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.09" + __version__ = "0.10" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,15 +52,15 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.02" + __version__ = "0.03" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+?)" - KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P\w+)[\"']\s*," + KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+)" + KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P\w+)" def detect_key(self, html=None): -- cgit v1.2.3 From 8939f015a688a07ec7d0bd14b6a3704f6a2cb4a0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 11 Oct 2014 15:12:40 +0200 Subject: Pattern update 3 --- module/plugins/internal/CaptchaService.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 9d8fd85f2..db4ed41a4 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -59,8 +59,8 @@ class ReCaptcha(CaptchaService): __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+)" - KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P\w+)" + KEY_PATTERN = r'https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+)' + KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P\w+)' def detect_key(self, html=None): -- cgit v1.2.3 From 0adc51cf4c58aa3e0f1073c28b9a8781a298fe89 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 11 Oct 2014 22:59:24 +0200 Subject: [CaptchaService] Fix KEY pattern --- module/plugins/internal/CaptchaService.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index db4ed41a4..b2b549617 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.10" + __version__ = "0.11" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,15 +52,15 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.03" + __version__ = "0.04" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P\w+)' - KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P\w+)' + KEY_PATTERN = r'https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P[\w-]+)' + KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P[\w-]+)' def detect_key(self, html=None): @@ -175,14 +175,14 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): __name__ = "SolveMedia" - __version__ = "0.02" + __version__ = "0.03" __description__ = """SolveMedia captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)"' + KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)["\']' def challenge(self, key=None): -- cgit v1.2.3 From 1f48f481740863c7697064bde286a78e977e4a1b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Oct 2014 15:12:06 +0200 Subject: Update other plugins to support self.error --- module/plugins/internal/CaptchaService.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index b2b549617..203dda82e 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.11" + __version__ = "0.12" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,7 +52,7 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.04" + __version__ = "0.05" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" @@ -99,7 +99,7 @@ class ReCaptcha(CaptchaService): challenge = re.search("challenge : '(.+?)',", js).group(1) server = re.search("server : '(.+?)',", js).group(1) except: - self.plugin.parseError("ReCaptcha challenge pattern not found") + self.plugin.error("ReCaptcha challenge pattern not found") result = self.result(server, challenge) @@ -113,7 +113,7 @@ class ReCaptcha(CaptchaService): class AdsCaptcha(CaptchaService): __name__ = "AdsCaptcha" - __version__ = "0.02" + __version__ = "0.03" __description__ = """AdsCaptcha captcha service plugin""" __license__ = "GPLv3" @@ -161,7 +161,7 @@ class AdsCaptcha(CaptchaService): challenge = re.search("challenge: '(.+?)',", js).group(1) server = re.search("server: '(.+?)',", js).group(1) except: - self.plugin.parseError("AdsCaptcha challenge pattern not found") + self.plugin.error("AdsCaptcha challenge pattern not found") result = self.result(server, challenge) @@ -175,7 +175,7 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): __name__ = "SolveMedia" - __version__ = "0.03" + __version__ = "0.04" __description__ = """SolveMedia captcha service plugin""" __license__ = "GPLv3" @@ -200,7 +200,7 @@ class SolveMedia(CaptchaService): html).group(1) server = "http://api.solvemedia.com/papi/media" except: - self.plugin.parseError("SolveMedia challenge pattern not found") + self.plugin.error("SolveMedia challenge pattern not found") result = self.result(server, challenge) -- cgit v1.2.3 From fe5c86946dfc2c539b4e2a59128275c1fe506493 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 14:31:45 +0200 Subject: [CaptchaService] Fix KEY_PATTERN --- module/plugins/internal/CaptchaService.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 203dda82e..28374899d 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.12" + __version__ = "0.13" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,14 +52,14 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.05" + __version__ = "0.06" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P[\w-]+)' + KEY_PATTERN = r'recaptcha/api/challenge\?k=(?P[\w-]+)' KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P[\w-]+)' @@ -113,15 +113,15 @@ class ReCaptcha(CaptchaService): class AdsCaptcha(CaptchaService): __name__ = "AdsCaptcha" - __version__ = "0.03" + __version__ = "0.04" __description__ = """AdsCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - ID_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P\d+)' - KEY_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P[\w-]+)' + ID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P\d+)' + KEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P[\w-]+)' def detect_key(self, html=None): @@ -175,14 +175,14 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): __name__ = "SolveMedia" - __version__ = "0.04" + __version__ = "0.05" __description__ = """SolveMedia captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)["\']' + KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)["\']' def challenge(self, key=None): -- cgit v1.2.3 From 1b096b2eb2634e8dea80b06ab9ecde206b198b35 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 19:47:00 +0200 Subject: Spare code cosmetics --- module/plugins/internal/CaptchaService.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 28374899d..6d3fc0feb 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -16,7 +16,7 @@ class CaptchaService: KEY_PATTERN = None - key = None + key = None #: last key detected def __init__(self, plugin): @@ -28,7 +28,7 @@ class CaptchaService: if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "%s html missing" % self.__name__ + errmsg = "%s html not found" % self.__name__ self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -68,7 +68,7 @@ class ReCaptcha(CaptchaService): if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "ReCaptcha html missing" + errmsg = "ReCaptcha not found" self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -86,10 +86,10 @@ class ReCaptcha(CaptchaService): def challenge(self, key=None): if not key: - if self.key: + if self.detect_key(): key = self.key else: - errmsg = "ReCaptcha key missing" + errmsg = "ReCaptcha key not found" self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -129,7 +129,7 @@ class AdsCaptcha(CaptchaService): if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "AdsCaptcha html missing" + errmsg = "AdsCaptcha html not found" self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -144,12 +144,12 @@ class AdsCaptcha(CaptchaService): return None - def challenge(self, key=None): #: key is tuple(CaptchaId, PublicKey) + def challenge(self, key=None): #: key is a tuple(CaptchaId, PublicKey) if not key: - if self.key: + if self.detect_key(): key = self.key else: - errmsg = "AdsCaptcha key missing" + errmsg = "AdsCaptcha key not found" self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -187,10 +187,10 @@ class SolveMedia(CaptchaService): def challenge(self, key=None): if not key: - if self.key: + if self.detect_key(): key = self.key else: - errmsg = "SolveMedia key missing" + errmsg = "SolveMedia key not found" self.plugin.fail(errmsg) raise TypeError(errmsg) -- cgit v1.2.3 From 85ba09f7bd27461ab5900487fd9da705cc7ff3a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 22 Oct 2014 21:14:50 +0200 Subject: [CaptchaService] Update ReCaptcha KEY_PATTERN --- module/plugins/internal/CaptchaService.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 6d3fc0feb..11b34755b 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.13" + __version__ = "0.14" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,14 +52,14 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.06" + __version__ = "0.07" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'recaptcha/api/challenge\?k=(?P[\w-]+)' + KEY_PATTERN = r'recaptcha(/api|\.net)/(challenge|noscript)\?k=(?P[\w-]+)' KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P[\w-]+)' -- cgit v1.2.3 From 7b67f68c1636014fe02286da71bdc6c13dc3eeee Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 23 Oct 2014 00:50:23 +0200 Subject: Simplify captcha challenge calls --- module/plugins/internal/CaptchaService.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 11b34755b..a1ec633e8 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -29,7 +29,7 @@ class CaptchaService: html = self.plugin.html else: errmsg = "%s html not found" % self.__name__ - self.plugin.fail(errmsg) + self.plugin.fail(errmsg) #@TODO: replace all plugin.fail(errmsg) with plugin.error(errmsg) in 0.4.10 raise TypeError(errmsg) m = re.search(self.KEY_PATTERN, html) @@ -72,9 +72,7 @@ class ReCaptcha(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - m = re.search(self.KEY_PATTERN, html) - if m is None: - m = re.search(self.KEY_AJAX_PATTERN, html) + m = re.search(self.KEY_PATTERN, html) or re.search(self.KEY_AJAX_PATTERN, html) if m: self.key = m.group("KEY") self.plugin.logDebug("ReCaptcha key: %s" % self.key) -- cgit v1.2.3 From 9f2ebe486a3e155fb6a60e07cccb77ab6a772eb2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 26 Oct 2014 02:31:54 +0200 Subject: Extend translation support in plugins + a lot of code cosmetics and typo fixes --- module/plugins/internal/CaptchaService.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index a1ec633e8..aa8758344 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -28,7 +28,7 @@ class CaptchaService: if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "%s html not found" % self.__name__ + errmsg = _("%s html not found") % self.__name__ self.plugin.fail(errmsg) #@TODO: replace all plugin.fail(errmsg) with plugin.error(errmsg) in 0.4.10 raise TypeError(errmsg) @@ -68,7 +68,7 @@ class ReCaptcha(CaptchaService): if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "ReCaptcha not found" + errmsg = _("ReCaptcha html not found") self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -87,7 +87,7 @@ class ReCaptcha(CaptchaService): if self.detect_key(): key = self.key else: - errmsg = "ReCaptcha key not found" + errmsg = _("ReCaptcha key not found") self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -127,7 +127,7 @@ class AdsCaptcha(CaptchaService): if hasattr(self.plugin, "html") and self.plugin.html: html = self.plugin.html else: - errmsg = "AdsCaptcha html not found" + errmsg = _("AdsCaptcha html not found") self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -147,7 +147,7 @@ class AdsCaptcha(CaptchaService): if self.detect_key(): key = self.key else: - errmsg = "AdsCaptcha key not found" + errmsg = _("AdsCaptcha key not found") self.plugin.fail(errmsg) raise TypeError(errmsg) @@ -188,7 +188,7 @@ class SolveMedia(CaptchaService): if self.detect_key(): key = self.key else: - errmsg = "SolveMedia key not found" + errmsg = _("SolveMedia key not found") self.plugin.fail(errmsg) raise TypeError(errmsg) -- cgit v1.2.3 From 34984dae733c3f3d47b41a0acfba3724d53c65a1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 28 Oct 2014 16:52:10 +0100 Subject: Code cosmetics: plugin class attributes --- module/plugins/internal/CaptchaService.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index aa8758344..2143e23df 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -6,12 +6,12 @@ from random import random class CaptchaService: - __name__ = "CaptchaService" + __name__ = "CaptchaService" __version__ = "0.14" __description__ = """Base captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] KEY_PATTERN = None @@ -51,12 +51,12 @@ class CaptchaService: class ReCaptcha(CaptchaService): - __name__ = "ReCaptcha" + __name__ = "ReCaptcha" __version__ = "0.07" __description__ = """ReCaptcha captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] KEY_PATTERN = r'recaptcha(/api|\.net)/(challenge|noscript)\?k=(?P[\w-]+)' @@ -110,12 +110,12 @@ class ReCaptcha(CaptchaService): class AdsCaptcha(CaptchaService): - __name__ = "AdsCaptcha" + __name__ = "AdsCaptcha" __version__ = "0.04" __description__ = """AdsCaptcha captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] ID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P\d+)' @@ -172,12 +172,12 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): - __name__ = "SolveMedia" + __name__ = "SolveMedia" __version__ = "0.05" __description__ = """SolveMedia captcha service plugin""" - __license__ = "GPLv3" - __authors__ = [("pyLoad Team", "admin@pyload.org")] + __license__ = "GPLv3" + __authors__ = [("pyLoad Team", "admin@pyload.org")] KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)["\']' -- cgit v1.2.3 From 59f72bfc5ed721c80c821bd0ca1bc8daf0d49880 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 9 Nov 2014 03:12:41 +0100 Subject: Code cosmetics --- module/plugins/internal/CaptchaService.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 2143e23df..38775f519 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -91,7 +91,7 @@ class ReCaptcha(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}, cookies=True) + js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) try: challenge = re.search("challenge : '(.+?)',", js).group(1) @@ -153,7 +153,7 @@ class AdsCaptcha(CaptchaService): CaptchaId, PublicKey = key - js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}, cookies=True) + js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}) try: challenge = re.search("challenge: '(.+?)',", js).group(1) @@ -192,7 +192,7 @@ class SolveMedia(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}, cookies=True) + html = self.plugin.req.load("http://api.solvemedia.com/papi/challenge.noscript", get={'k': key}) try: challenge = re.search(r'', html).group(1) -- cgit v1.2.3 From 2b14c07bfe427f40288b2c73db1813c0dc11659a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 23 Nov 2014 23:18:39 +0100 Subject: [CaptchaService] More debug logging --- module/plugins/internal/CaptchaService.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 38775f519..7009e6986 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -7,7 +7,7 @@ from random import random class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.14" + __version__ = "0.15" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -52,7 +52,7 @@ class CaptchaService: class ReCaptcha(CaptchaService): __name__ = "ReCaptcha" - __version__ = "0.07" + __version__ = "0.08" __description__ = """ReCaptcha captcha service plugin""" __license__ = "GPLv3" @@ -92,7 +92,6 @@ class ReCaptcha(CaptchaService): raise TypeError(errmsg) js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) - try: challenge = re.search("challenge : '(.+?)',", js).group(1) server = re.search("server : '(.+?)',", js).group(1) @@ -101,6 +100,8 @@ class ReCaptcha(CaptchaService): result = self.result(server, challenge) + self.plugin.logDebug("ReCaptcha result: %s" % result, "challenge: %s" % challenge) + return challenge, result @@ -111,7 +112,7 @@ class ReCaptcha(CaptchaService): class AdsCaptcha(CaptchaService): __name__ = "AdsCaptcha" - __version__ = "0.04" + __version__ = "0.05" __description__ = """AdsCaptcha captcha service plugin""" __license__ = "GPLv3" @@ -154,7 +155,6 @@ class AdsCaptcha(CaptchaService): CaptchaId, PublicKey = key js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}) - try: challenge = re.search("challenge: '(.+?)',", js).group(1) server = re.search("server: '(.+?)',", js).group(1) @@ -163,6 +163,8 @@ class AdsCaptcha(CaptchaService): result = self.result(server, challenge) + self.plugin.logDebug("AdsCaptcha result: %s" % result, "challenge: %s" % challenge) + return challenge, result @@ -173,7 +175,7 @@ class AdsCaptcha(CaptchaService): class SolveMedia(CaptchaService): __name__ = "SolveMedia" - __version__ = "0.05" + __version__ = "0.06" __description__ = """SolveMedia captcha service plugin""" __license__ = "GPLv3" @@ -202,6 +204,8 @@ class SolveMedia(CaptchaService): result = self.result(server, challenge) + self.plugin.logDebug("SolveMedia result: %s" % result, "challenge: %s" % challenge) + return challenge, result -- cgit v1.2.3 From 58656ab0b1b7f79ee31c38b7675f0587269f014f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 10 Dec 2014 02:59:27 +0100 Subject: [CaptchaService] New service AdYouLike + AdsCaptcha detect_key fixup --- module/plugins/internal/CaptchaService.py | 203 +++++++++++++++++++++++------- 1 file changed, 161 insertions(+), 42 deletions(-) (limited to 'module/plugins/internal/CaptchaService.py') diff --git a/module/plugins/internal/CaptchaService.py b/module/plugins/internal/CaptchaService.py index 7009e6986..965799e8e 100644 --- a/module/plugins/internal/CaptchaService.py +++ b/module/plugins/internal/CaptchaService.py @@ -4,10 +4,12 @@ import re from random import random +from module.common.json_layer import json_loads + class CaptchaService: __name__ = "CaptchaService" - __version__ = "0.15" + __version__ = "0.16" __description__ = """Base captcha service plugin""" __license__ = "GPLv3" @@ -34,7 +36,7 @@ class CaptchaService: m = re.search(self.KEY_PATTERN, html) if m: - self.key = m.group("KEY") + self.key = m.group(1).strip() self.plugin.logDebug("%s key: %s" % (self.__name__, self.key)) return self.key else: @@ -59,8 +61,8 @@ class ReCaptcha(CaptchaService): __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'recaptcha(/api|\.net)/(challenge|noscript)\?k=(?P[\w-]+)' - KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P[\w-]+)' + KEY_PATTERN = r'recaptcha(?:/api|\.net)/(?:challenge|noscript)\?k=([\w-]+)' + KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\']([\w-]+)' def detect_key(self, html=None): @@ -74,7 +76,7 @@ class ReCaptcha(CaptchaService): m = re.search(self.KEY_PATTERN, html) or re.search(self.KEY_AJAX_PATTERN, html) if m: - self.key = m.group("KEY") + self.key = m.group(1).strip() self.plugin.logDebug("ReCaptcha key: %s" % self.key) return self.key else: @@ -91,36 +93,43 @@ class ReCaptcha(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) + html = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={'k': key}) try: - challenge = re.search("challenge : '(.+?)',", js).group(1) - server = re.search("server : '(.+?)',", js).group(1) + challenge = re.search("challenge : '(.+?)',", html).group(1) + server = re.search("server : '(.+?)',", html).group(1) except: - self.plugin.error("ReCaptcha challenge pattern not found") - - result = self.result(server, challenge) + errmsg = _("ReCaptcha challenge pattern not found") + self.plugin.fail(errmsg) + raise ValueError(errmsg) - self.plugin.logDebug("ReCaptcha result: %s" % result, "challenge: %s" % challenge) + self.plugin.logDebug("ReCaptcha challenge: %s" % challenge) - return challenge, result + return challenge, self.result(server, challenge) def result(self, server, challenge): - return self.plugin.decryptCaptcha("%simage" % server, get={'c': challenge}, - cookies=True, forceUser=True, imgtype="jpg") + result = self.plugin.decryptCaptcha("%simage" % server, + get={'c': challenge}, + cookies=True, + forceUser=True, + imgtype="jpg") + + self.plugin.logDebug("ReCaptcha result: %s" % result) + + return result class AdsCaptcha(CaptchaService): __name__ = "AdsCaptcha" - __version__ = "0.05" + __version__ = "0.06" __description__ = """AdsCaptcha captcha service plugin""" __license__ = "GPLv3" __authors__ = [("pyLoad Team", "admin@pyload.org")] - ID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P\d+)' - KEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P[\w-]+)' + CAPTCHAID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(\d+)' + PUBLICKEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=([\w-]+)' def detect_key(self, html=None): @@ -132,18 +141,18 @@ class AdsCaptcha(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - m = re.search(self.ID_PATTERN, html) - n = re.search(self.KEY_PATTERN, html) + m = re.search(self.PUBLICKEY_PATTERN, html) + n = re.search(self.CAPTCHAID_PATTERN, html) if m and n: - self.key = (m.group("ID"), m.group("KEY")) - self.plugin.logDebug("AdsCaptcha id|key: %s | %s" % self.key) + self.key = (m.group(1).strip(), n.group(1).strip()) #: key is the tuple(PublicKey, CaptchaId) + self.plugin.logDebug("AdsCaptcha key|id: %s | %s" % self.key) return self.key else: - self.plugin.logDebug("AdsCaptcha id or key not found") + self.plugin.logDebug("AdsCaptcha key or id not found") return None - def challenge(self, key=None): #: key is a tuple(CaptchaId, PublicKey) + def challenge(self, key=None): if not key: if self.detect_key(): key = self.key @@ -152,25 +161,31 @@ class AdsCaptcha(CaptchaService): self.plugin.fail(errmsg) raise TypeError(errmsg) - CaptchaId, PublicKey = key + PublicKey, CaptchaId = key - js = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}) + html = self.plugin.req.load("http://api.adscaptcha.com/Get.aspx", get={'CaptchaId': CaptchaId, 'PublicKey': PublicKey}) try: - challenge = re.search("challenge: '(.+?)',", js).group(1) - server = re.search("server: '(.+?)',", js).group(1) + challenge = re.search("challenge: '(.+?)',", html).group(1) + server = re.search("server: '(.+?)',", html).group(1) except: - self.plugin.error("AdsCaptcha challenge pattern not found") - - result = self.result(server, challenge) + errmsg = _("AdsCaptcha challenge pattern not found") + self.plugin.fail(errmsg) + raise ValueError(errmsg) - self.plugin.logDebug("AdsCaptcha result: %s" % result, "challenge: %s" % challenge) + self.plugin.logDebug("AdsCaptcha challenge: %s" % challenge) - return challenge, result + return challenge, self.result(server, challenge) def result(self, server, challenge): - return self.plugin.decryptCaptcha("%sChallenge.aspx" % server, get={'cid': challenge, 'dummy': random()}, - cookies=True, imgtype="jpg") + result = self.plugin.decryptCaptcha("%sChallenge.aspx" % server, + get={'cid': challenge, 'dummy': random()}, + cookies=True, + imgtype="jpg") + + self.plugin.logDebug("AdsCaptcha result: %s" % result) + + return result class SolveMedia(CaptchaService): @@ -182,7 +197,7 @@ class SolveMedia(CaptchaService): __authors__ = [("pyLoad Team", "admin@pyload.org")] - KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P.+?)["\']' + KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(?:no)?script\?k=(.+?)["\']' def challenge(self, key=None): @@ -198,16 +213,120 @@ class SolveMedia(CaptchaService): try: challenge = re.search(r'', html).group(1) - server = "http://api.solvemedia.com/papi/media" + server = "http://api.solvemedia.com/papi/media" except: - self.plugin.error("SolveMedia challenge pattern not found") + errmsg = _("SolveMedia challenge pattern not found") + self.plugin.fail(errmsg) + raise ValueError(errmsg) + + self.plugin.logDebug("SolveMedia challenge: %s" % challenge) + + return challenge, self.result(server, challenge) + + + def result(self, server, challenge): + result = self.plugin.decryptCaptcha(server, get={'c': challenge}, imgtype="gif") + + self.plugin.logDebug("SolveMedia result: %s" % result) + + return result + + +class AdYouLike(CaptchaService): + __name__ = "AdYouLike" + __version__ = "0.02" + + __description__ = """AdYouLike captcha service plugin""" + __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: + html = self.plugin.html + else: + errmsg = _("AdYouLike html not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) - result = self.result(server, challenge) + m = re.search(self.AYL_PATTERN, html) + n = re.search(self.CALLBACK_PATTERN, html) + if m and n: + self.key = (m.group(1).strip(), n.group(1).strip()) + self.plugin.logDebug("AdYouLike ayl|callback: %s | %s" % self.key) + return self.key #: key is the tuple(ayl, callback) + else: + self.plugin.logDebug("AdYouLike ayl or callback not found") + return None - self.plugin.logDebug("SolveMedia result: %s" % result, "challenge: %s" % challenge) - return challenge, result + def challenge(self, key=None): + if not key: + if self.detect_key(): + key = self.key + else: + errmsg = _("AdYouLike key not found") + self.plugin.fail(errmsg) + raise TypeError(errmsg) + + ayl, callback = key + + # {"adyoulike":{"key":"P~zQ~O0zV0WTiAzC-iw0navWQpCLoYEP"}, + # "all":{"element_id":"ayl_private_cap_92300","lang":"fr","env":"prod"}} + ayl = json_loads(ayl) + + html = self.plugin.req.load("http://api-ayl.appspot.com/challenge", + get={'key' : ayl['adyoulike']['key'], + 'env' : ayl['all']['env'], + 'callback': callback}) + try: + challenge = json_loads(re.search(callback + r'\s*\((.+?)\)', html).group(1)) + except: + errmsg = _("AdYouLike challenge pattern not found") + self.plugin.fail(errmsg) + raise ValueError(errmsg) + + self.plugin.logDebug("AdYouLike challenge: %s" % challenge) + + return self.result(ayl, challenge) def result(self, server, challenge): - return self.plugin.decryptCaptcha(server, get={'c': challenge}, imgtype="gif") + # Adyoulike.g._jsonp_5579316662423138 + # ({"translations":{"fr":{"instructions_visual":"Recopiez « Soonnight » ci-dessous :"}}, + # "site_under":true,"clickable":true,"pixels":{"VIDEO_050":[],"DISPLAY":[],"VIDEO_000":[],"VIDEO_100":[], + # "VIDEO_025":[],"VIDEO_075":[]},"medium_type":"image/adyoulike", + # "iframes":{"big":""},"shares":{},"id":256, + # "token":"e6QuI4aRSnbIZJg02IsV6cp4JQ9~MjA1","formats":{"small":{"y":300,"x":0,"w":300,"h":60}, + # "big":{"y":0,"x":0,"w":300,"h":250},"hover":{"y":440,"x":0,"w":300,"h":60}}, + # "tid":"SqwuAdxT1EZoi4B5q0T63LN2AkiCJBg5"}) + + if isinstance(server, basestring): + server = json_loads(server) + + if isinstance(challenge, basestring): + challenge = json_loads(challenge) + + try: + instructions_visual = challenge['translations'][server['all']['lang']]['instructions_visual'] + result = re.search(u'«(.+?)»', instructions_visual).group(1).strip() + except: + errmsg = _("AdYouLike result not found") + self.plugin.fail(errmsg) + raise ValueError(errmsg) + + result = {'_ayl_captcha_engine' : "adyoulike", + '_ayl_env' : server['all']['env'], + '_ayl_tid' : challenge['tid'], + '_ayl_token_challenge': challenge['token'], + '_ayl_response' : response} + + self.plugin.logDebug("AdYouLike result: %s" % result) + + return result -- cgit v1.2.3