diff options
author | fragonib <devnull@localhost> | 2011-05-30 23:29:34 +0200 |
---|---|---|
committer | fragonib <devnull@localhost> | 2011-05-30 23:29:34 +0200 |
commit | c600bbc3ab7c6fe22d213108086a44ad8f929ca4 (patch) | |
tree | d393dd647df212ba94264ead42032dacfb8581e3 /module/CaptchaManager.py | |
parent | Serveral Plugins: Clean up (diff) | |
download | pyload-c600bbc3ab7c6fe22d213108086a44ad8f929ca4.tar.xz |
Support for positional captchas
Diffstat (limited to 'module/CaptchaManager.py')
-rw-r--r-- | module/CaptchaManager.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/module/CaptchaManager.py b/module/CaptchaManager.py index 7672aa645..539e80744 100644 --- a/module/CaptchaManager.py +++ b/module/CaptchaManager.py @@ -29,8 +29,8 @@ class CaptchaManager(): self.ids = 0 #only for internal purpose - def newTask(self, img, type, temp): - task = CaptchaTask(self.ids, img, type, temp) + def newTask(self, img, format, file, result_type): + task = CaptchaTask(self.ids, img, format, file, result_type) self.ids += 1 return task @@ -81,11 +81,12 @@ class CaptchaManager(): class CaptchaTask(): - def __init__(self, id, img, type, temp): + def __init__(self, id, img, format, file, result_type='textual'): self.id = str(id) self.captchaImg = img - self.captchaType = type - self.captchaFile = temp + self.captchaFormat = format + self.captchaFile = file + self.captchaResultType = result_type self.handler = [] #the hook plugins that will take care of the solution self.result = None self.waitUntil = None @@ -95,10 +96,17 @@ class CaptchaTask(): self.data = {} #handler can store data here def getCaptcha(self): - return self.captchaImg, self.captchaType + return self.captchaImg, self.captchaFormat, self.captchaResultType - def setResult(self, result): - self.result = result + def setResult(self, text): + if self.captchaResultType == 'textual': + self.result = text + if self.captchaResultType == 'positional': + try: + parts = text.split(',') + self.result = (int(parts[0]), int(parts[1])) + except: + self.result = None def getResult(self): try: |