MCPcopy Index your code
hub / github.com/pyload/pyload / CaptchaTask

Class CaptchaTask

module/CaptchaManager.py:87–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85
86
87class CaptchaTask():
88 def __init__(self, id, format, params={}, result_type='textual'):
89 self.id = str(id)
90 self.captchaParams = params
91 self.captchaFormat = format
92 self.captchaResultType = result_type
93 self.handler = [] #the hook plugins that will take care of the solution
94 self.result = None
95 self.waitUntil = None
96 self.error = None #error message
97
98 self.status = "init"
99 self.data = {} #handler can store data here
100
101 def getCaptcha(self):
102 return self.captchaParams, self.captchaFormat, self.captchaResultType
103
104 def setResult(self, result):
105 if self.isTextual() or self.isInteractive():
106 self.result = result
107
108 elif self.isPositional():
109 try:
110 parts = result.split(',')
111 self.result = (int(parts[0]), int(parts[1]))
112 except:
113 self.result = None
114
115 def getResult(self):
116 try:
117 res = self.result.encode("utf8", "replace")
118 except:
119 res = self.result
120
121 return res
122
123 def getStatus(self):
124 return self.status
125
126 def setWaiting(self, sec):
127 """ let the captcha wait secs for the solution """
128 self.waitUntil = max(time() + sec, self.waitUntil)
129 self.status = "waiting"
130
131 def isWaiting(self):
132 if self.result or self.error or time() > self.waitUntil:
133 return False
134
135 return True
136
137 def isTextual(self):
138 """ returns if text is written on the captcha """
139 return self.captchaResultType == 'textual'
140
141 def isPositional(self):
142 """ returns if user have to click a specific region on the captcha """
143 return self.captchaResultType == 'positional'
144

Callers 2

newTaskMethod · 0.70
getCaptchaTaskMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected