MCPcopy Create free account
hub / github.com/pyload/pyload / Captcha

Class Captcha

module/plugins/internal/Captcha.py:13–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13class Captcha(Plugin):
14 __name__ = "Captcha"
15 __type__ = "captcha"
16 __version__ = "0.57"
17 __status__ = "stable"
18
19 __description__ = """Base anti-captcha plugin"""
20 __license__ = "GPLv3"
21 __authors__ = [("Walter Purcaro", "vuolter@gmail.com")]
22
23 def __init__(self, pyfile):
24 self._init(pyfile.m.core)
25
26 self.pyfile = pyfile
27 self.task = None #: captchaManager task
28
29 self.init()
30
31 def _log(self, level, plugintype, pluginname, messages):
32 messages = (self.__name__,) + messages
33 return self.pyfile.plugin._log(level, plugintype, self.pyfile.plugin.__name__, messages)
34
35 def recognize(self, image):
36 """
37 Extend to build your custom anti-captcha ocr
38 """
39 pass
40
41 def decrypt(self, url, get={}, post={}, ref=False, cookies=True, req=None,
42 input_type='jpg', output_type='textual', ocr=True, timeout=120):
43 img = self.load(
44 url,
45 get=get,
46 post=post,
47 ref=ref,
48 cookies=cookies,
49 decode=False,
50 req=req or self.pyfile.plugin.req)
51 return self.decrypt_image(img, input_type, output_type, ocr, timeout)
52
53 def decrypt_image(self, img, input_type='jpg',
54 output_type='textual', ocr=False, timeout=120):
55 """
56 Loads a captcha and decrypts it with ocr, plugin, user input
57
58 :param img: image raw data
59 :param get: get part for request
60 :param post: post part for request
61 :param cookies: True if cookies should be enabled
62 :param input_type: Type of the Image
63 :param output_type: 'textual' if text is written on the captcha\
64 or 'positional' for captcha where the user have to click\
65 on a specific region on the captcha
66 :param ocr: if True, builtin ocr is used. if string, the OCR plugin name is used
67
68 :return: result of decrypting
69 """
70 result = None

Callers 5

signinMethod · 0.90
signinMethod · 0.90
signinMethod · 0.90
__init__Method · 0.90
setupMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected