summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal/Captcha.py
diff options
context:
space:
mode:
authorGravatar Nitzo <nitzo2001@yahoo.com> 2016-01-02 03:30:51 +0100
committerGravatar Nitzo <nitzo2001@yahoo.com> 2016-01-02 03:30:51 +0100
commit3d5ef19f8654bacfafc7e1dab1d4e0adf6d75fd1 (patch)
treeec2f8a07fba9c1b20bc81b25b2e1a9d3d60eb58e /module/plugins/internal/Captcha.py
parent[Plugin] Fix dump_html() (diff)
downloadpyload-3d5ef19f8654bacfafc7e1dab1d4e0adf6d75fd1.tar.xz
[Captcha] Update
Diffstat (limited to 'module/plugins/internal/Captcha.py')
-rw-r--r--module/plugins/internal/Captcha.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py
index 1929fcc9f..dde92816b 100644
--- a/module/plugins/internal/Captcha.py
+++ b/module/plugins/internal/Captcha.py
@@ -12,7 +12,7 @@ from module.plugins.internal.misc import encode
class Captcha(Plugin):
__name__ = "Captcha"
__type__ = "captcha"
- __version__ = "0.50"
+ __version__ = "0.51"
__status__ = "stable"
__description__ = """Base anti-captcha plugin"""
@@ -59,7 +59,7 @@ class Captcha(Plugin):
:param output_type: 'textual' if text is written on the captcha\
or 'positional' for captcha where the user have to click\
on a specific region on the captcha
- :param ocr: if True, ocr is not used
+ :param ocr: if True, builtin ocr is used. if string, the OCR plugin name is used
:return: result of decrypting
"""
@@ -67,19 +67,24 @@ class Captcha(Plugin):
time_ref = ("%.2f" % time.time())[-6:].replace(".", "")
with open(os.path.join("tmp", "captcha_image_%s_%s.%s" % (self.pyfile.plugin.__name__, time_ref, input_type)), "wb") as img_f:
- img_f.write(encode(img))
+ img_f.write(img)
if ocr:
+ self.log_warning(_("Using OCR to decrypt captcha"))
+
if isinstance(ocr, basestring):
_OCR = self.pyload.pluginManager.loadClass("captcha", ocr) #: Rename `captcha` to `ocr` in 0.4.10
result = _OCR(self.pyfile).recognize(img_f.name)
else:
result = self.recognize(img_f.name)
- if not result:
- if ocr:
- self.log_warning(_("No OCR result"))
+ if not result:
+ self.log_warning(_("No OCR result"))
+ else:
+ self.log_warning(_("OCR was not used"))
+
+ if not result:
captchaManager = self.pyload.captchaManager
try: