diff options
Diffstat (limited to 'module/plugins/internal')
-rw-r--r-- | module/plugins/internal/Captcha.py | 26 | ||||
-rw-r--r-- | module/plugins/internal/Hoster.py | 4 |
2 files changed, 18 insertions, 12 deletions
diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py index fe0830693..763783f82 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.48" + __version__ = "0.49" __status__ = "stable" __description__ = """Base anti-captcha plugin""" @@ -63,7 +63,7 @@ class Captcha(Plugin): :return: result of decrypting """ - result = "" + result = None 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: @@ -77,6 +77,9 @@ class Captcha(Plugin): result = self.recognize(img_f.name) if not result: + if ocr: + self.log_warning(_("No OCR result")) + captchaManager = self.pyload.captchaManager try: @@ -92,19 +95,20 @@ class Captcha(Plugin): finally: captchaManager.removeTask(self.task) + result = self.task.result + if self.task.error: - self.fail(self.task.error) + self.pyfile.plugin.retry_captcha(msg=self.task.error) - elif not self.task.result: - self.pyfile.plugin.retry_captcha(msg=_("No captcha result obtained in appropriate time")) + if self.task.result: + self.log_info(_("Captcha result: `%s`") % result) - result = self.task.result + else: + self.pyfile.plugin.retry_captcha(msg=_("No captcha result obtained in appropriate timing")) if not self.pyload.debug: self.remove(img_f.name, trash=False) - # self.log_info(_("Captcha result: ") + result) #@TODO: Remove from here? - return result @@ -112,13 +116,15 @@ class Captcha(Plugin): if not self.task: return - self.log_warning(_("Invalid captcha")) + self.log_warning(_("Invalid captcha"), self.task.result) self.task.invalid() + self.task = None def correct(self): if not self.task: return - self.log_info(_("Correct captcha")) + self.log_info(_("Correct captcha"), self.task.result) self.task.correct() + self.task = None diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py index 4f5bf6156..a87066502 100644 --- a/module/plugins/internal/Hoster.py +++ b/module/plugins/internal/Hoster.py @@ -34,7 +34,7 @@ if not hasattr(__builtin__.property, "setter"): class Hoster(Base): __name__ = "Hoster" __type__ = "hoster" - __version__ = "0.48" + __version__ = "0.49" __status__ = "stable" __pattern__ = r'^unmatchable$' @@ -239,7 +239,6 @@ class Hoster(Base): self.pyfile.name = dl_basename - self.captcha.correct() self.check_duplicates() self.pyfile.setStatus("downloading") @@ -285,6 +284,7 @@ class Hoster(Base): finally: self.pyfile.size = self.req.size + self.captcha.correct() if self.req.code in (404, 410): bad_file = fsjoin(dl_dirname, newname) |