summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/DeathByCaptcha.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks/DeathByCaptcha.py')
-rw-r--r--module/plugins/hooks/DeathByCaptcha.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py
index 5c1c89c88..62cfe7d16 100644
--- a/module/plugins/hooks/DeathByCaptcha.py
+++ b/module/plugins/hooks/DeathByCaptcha.py
@@ -2,16 +2,16 @@
from __future__ import with_statement
-import pycurl
+import base64
import re
import time
-from base64 import b64encode
+import pycurl
-from module.plugins.internal.utils import json
from module.network.HTTPRequest import BadHeader
from module.network.RequestFactory import getRequest as get_request
from module.plugins.internal.Addon import Addon, threaded
+from module.plugins.internal.misc import json
class DeathByCaptchaException(Exception):
@@ -51,7 +51,7 @@ class DeathByCaptchaException(Exception):
class DeathByCaptcha(Addon):
__name__ = "DeathByCaptcha"
__type__ = "hook"
- __version__ = "0.10"
+ __version__ = "0.11"
__status__ = "testing"
__config__ = [("activated" , "bool" , "Activated" , False),
@@ -75,8 +75,8 @@ class DeathByCaptcha(Addon):
if post:
if not isinstance(post, dict):
post = {}
- post.update({'username': self.get_config('username'),
- 'password': self.get_config('password')})
+ post.update({'username': self.config.get('username'),
+ 'password': self.config.get('password')})
res = None
try:
@@ -94,13 +94,13 @@ class DeathByCaptcha(Addon):
raise DeathByCaptchaException(str(res))
except BadHeader, e:
- if e.code == 403:
+ if e.code is 403:
raise DeathByCaptchaException('not-logged-in')
- elif e.code == 413:
+ elif e.code is 413:
raise DeathByCaptchaException('invalid-captcha')
- elif e.code == 503:
+ elif e.code is 503:
raise DeathByCaptchaException('service-overload')
elif e.code in (400, 405):
@@ -135,14 +135,14 @@ class DeathByCaptcha(Addon):
def submit(self, captcha, captchaType="file", match=None):
#@NOTE: Workaround multipart-post bug in HTTPRequest.py
- if re.match("^\w*$", self.get_config('password')):
+ if re.match("^\w*$", self.config.get('password')):
multipart = True
data = (pycurl.FORM_FILE, captcha)
else:
multipart = False
with open(captcha, 'rb') as f:
data = f.read()
- data = "base64:" + b64encode(data)
+ data = "base64:" + base64.b64encode(data)
res = self.api_response("captcha", {'captchafile': data}, multipart)
@@ -171,10 +171,10 @@ class DeathByCaptcha(Addon):
if not task.isTextual():
return False
- if not self.get_config('username') or not self.get_config('password'):
+ if not self.config.get('username') or not self.config.get('password'):
return False
- if self.pyload.isClientConnected() and self.get_config('check_client'):
+ if self.pyload.isClientConnected() and self.config.get('check_client'):
return False
try: