diff options
Diffstat (limited to 'module/plugins/hooks/ImageTyperz.py')
-rw-r--r-- | module/plugins/hooks/ImageTyperz.py | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index 656ad0c25..24e1687a8 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -2,13 +2,14 @@ from __future__ import with_statement -import pycurl +import base64 import re -from base64 import b64encode +import pycurl from module.network.RequestFactory import getRequest as get_request -from module.plugins.internal.Addon import Addon, threaded +from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import threaded class ImageTyperzException(Exception): @@ -32,7 +33,7 @@ class ImageTyperzException(Exception): class ImageTyperz(Addon): __name__ = "ImageTyperz" __type__ = "hook" - __version__ = "0.09" + __version__ = "0.10" __status__ = "testing" __config__ = [("activated" , "bool" , "Activated" , False), @@ -54,8 +55,8 @@ class ImageTyperz(Addon): def get_credits(self): res = self.load(self.GETCREDITS_URL, post={'action': "REQUESTBALANCE", - 'username': self.get_config('username'), - 'password': self.get_config('password')}) + 'username': self.config.get('username'), + 'password': self.config.get('password')}) if res.startswith('ERROR'): raise ImageTyperzException(res) @@ -77,19 +78,19 @@ class ImageTyperz(Addon): try: #@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 = b64encode(data) + data = base64.b64encode(data) res = self.load(self.SUBMIT_URL, post={'action': "UPLOADCAPTCHA", - 'username': self.get_config('username'), - 'password': self.get_config('password'), 'file': data}, + 'username': self.config.get('username'), + 'password': self.config.get('password'), 'file': data}, multipart=multipart, req=req) finally: @@ -114,10 +115,10 @@ class ImageTyperz(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 if self.get_credits() > 0: @@ -134,8 +135,8 @@ class ImageTyperz(Addon): if task.data['service'] is self.classname and "ticket" in task.data: res = self.load(self.RESPOND_URL, post={'action': "SETBADIMAGE", - 'username': self.get_config('username'), - 'password': self.get_config('password'), + 'username': self.config.get('username'), + 'password': self.config.get('password'), 'imageid': task.data['ticket']}) if res == "SUCCESS": @@ -145,7 +146,7 @@ class ImageTyperz(Addon): @threaded - def _process_captcha(self, task): + def _process_captcha(self, task) c = task.captchaFile try: ticket, result = self.submit(c) |