summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/captcha
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-15 07:26:01 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-11-15 07:26:01 +0100
commiteb61d1bb0a30fd32f99b93f847346c610fbc91d2 (patch)
treef889dd1b19c0496f3f88c478445165abd98f9c7a /pyload/plugins/captcha
parent[HTTPRequest] Raise Fail if write response fails (diff)
downloadpyload-eb61d1bb0a30fd32f99b93f847346c610fbc91d2.tar.xz
Update plugins after merging
Diffstat (limited to 'pyload/plugins/captcha')
-rw-r--r--pyload/plugins/captcha/AdsCaptcha.py26
-rw-r--r--pyload/plugins/captcha/ReCaptcha.py28
-rw-r--r--pyload/plugins/captcha/SolveMedia.py20
3 files changed, 39 insertions, 35 deletions
diff --git a/pyload/plugins/captcha/AdsCaptcha.py b/pyload/plugins/captcha/AdsCaptcha.py
index 8d4e12e28..4eabfbf9b 100644
--- a/pyload/plugins/captcha/AdsCaptcha.py
+++ b/pyload/plugins/captcha/AdsCaptcha.py
@@ -4,19 +4,21 @@ import re
from random import random
-from pyload.plugins.base.Captcha import Captcha
+from pyload.plugins.internal.Captcha import Captcha
class AdsCaptcha(Captcha):
- __name__ = "AdsCaptcha"
- __version__ = "0.02"
+ __name__ = "AdsCaptcha"
+ __type__ = "captcha"
+ __version__ = "0.04"
__description__ = """AdsCaptcha captcha service plugin"""
- __authors__ = [("pyLoad Team", "admin@pyload.org")]
+ __license__ = "GPLv3"
+ __authors__ = [("pyLoad Team", "admin@pyload.org")]
- ID_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P<ID>\d+)'
- KEY_PATTERN = r'http://api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P<KEY>[\w-]+)'
+ ID_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*CaptchaId=(?P<ID>\d+)'
+ KEY_PATTERN = r'api\.adscaptcha\.com/Get\.aspx\?[^"\']*PublicKey=(?P<KEY>[\w-]+)'
def detect_key(self, html=None):
@@ -24,7 +26,7 @@ class AdsCaptcha(Captcha):
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)
@@ -39,24 +41,24 @@ class AdsCaptcha(Captcha):
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)
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)
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)
diff --git a/pyload/plugins/captcha/ReCaptcha.py b/pyload/plugins/captcha/ReCaptcha.py
index 445f6b361..d68584c9d 100644
--- a/pyload/plugins/captcha/ReCaptcha.py
+++ b/pyload/plugins/captcha/ReCaptcha.py
@@ -2,19 +2,21 @@
import re
-from pyload.plugins.base.Captcha import Captcha
+from pyload.plugins.internal.Captcha import Captcha
class ReCaptcha(Captcha):
- __name__ = "ReCaptcha"
- __version__ = "0.02"
+ __name__ = "ReCaptcha"
+ __type__ = "captcha"
+ __version__ = "0.07"
__description__ = """ReCaptcha captcha service plugin"""
- __authors__ = [("pyLoad Team", "admin@pyload.org")]
+ __license__ = "GPLv3"
+ __authors__ = [("pyLoad Team", "admin@pyload.org")]
- KEY_PATTERN = r"https?://(?:www\.)?google\.com/recaptcha/api/challenge\?k=(?P<KEY>\w+?)"
- KEY_AJAX_PATTERN = r"Recaptcha\.create\s*\(\s*[\"'](?P<KEY>\w+)[\"']\s*,"
+ KEY_PATTERN = r'recaptcha(/api|\.net)/(challenge|noscript)\?k=(?P<KEY>[\w-]+)'
+ KEY_AJAX_PATTERN = r'Recaptcha\.create\s*\(\s*["\'](?P<KEY>[\w-]+)'
def detect_key(self, html=None):
@@ -22,13 +24,11 @@ class ReCaptcha(Captcha):
if hasattr(self.plugin, "html") and self.plugin.html:
html = self.plugin.html
else:
- errmsg = "ReCaptcha html missing"
+ errmsg = _("ReCaptcha html not found")
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)
@@ -40,20 +40,20 @@ class ReCaptcha(Captcha):
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)
- 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)
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)
diff --git a/pyload/plugins/captcha/SolveMedia.py b/pyload/plugins/captcha/SolveMedia.py
index c8e87bb7a..d1b9eba6a 100644
--- a/pyload/plugins/captcha/SolveMedia.py
+++ b/pyload/plugins/captcha/SolveMedia.py
@@ -2,36 +2,38 @@
import re
-from pyload.plugins.base.Captcha import Captcha
+from pyload.plugins.internal.Captcha import Captcha
class SolveMedia(Captcha):
- __name__ = "SolveMedia"
- __version__ = "0.02"
+ __name__ = "SolveMedia"
+ __type__ = "captcha"
+ __version__ = "0.05"
__description__ = """SolveMedia captcha service plugin"""
- __authors__ = [("pyLoad Team", "admin@pyload.org")]
+ __license__ = "GPLv3"
+ __authors__ = [("pyLoad Team", "admin@pyload.org")]
- KEY_PATTERN = r'http://api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P<KEY>.+?)"'
+ KEY_PATTERN = r'api\.solvemedia\.com/papi/challenge\.(no)?script\?k=(?P<KEY>.+?)["\']'
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)
- 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'<input type=hidden name="adcopy_challenge" id="adcopy_challenge" value="([^"]+)">',
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)