summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/captcha/AdsCaptcha.py
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/AdsCaptcha.py
parent[HTTPRequest] Raise Fail if write response fails (diff)
downloadpyload-eb61d1bb0a30fd32f99b93f847346c610fbc91d2.tar.xz
Update plugins after merging
Diffstat (limited to 'pyload/plugins/captcha/AdsCaptcha.py')
-rw-r--r--pyload/plugins/captcha/AdsCaptcha.py26
1 files changed, 14 insertions, 12 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)