summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/Captcha9Kw.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-07-07 01:23:55 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-07-07 01:23:55 +0200
commitb1759bc440cd6013837697eb8de540914f693ffd (patch)
treed170caf63d7f65e44d23ea2d91a65759a1665928 /module/plugins/hooks/Captcha9Kw.py
parent[Plugin] Fix decoding in load method (diff)
downloadpyload-b1759bc440cd6013837697eb8de540914f693ffd.tar.xz
No camelCase style anymore
Diffstat (limited to 'module/plugins/hooks/Captcha9Kw.py')
-rw-r--r--module/plugins/hooks/Captcha9Kw.py72
1 files changed, 36 insertions, 36 deletions
diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py
index aaea232f7..0ef67e54d 100644
--- a/module/plugins/hooks/Captcha9Kw.py
+++ b/module/plugins/hooks/Captcha9Kw.py
@@ -14,7 +14,7 @@ from module.plugins.internal.Hook import Hook, threaded
class Captcha9Kw(Hook):
__name__ = "Captcha9Kw"
__type__ = "hook"
- __version__ = "0.29"
+ __version__ = "0.30"
__config__ = [("check_client" , "bool" , "Don't use if client is connected" , True ),
("confirm" , "bool" , "Confirm Captcha (cost +6 credits)" , False ),
@@ -42,30 +42,30 @@ class Captcha9Kw(Hook):
self.info = {} #@TODO: Remove in 0.4.10
- def getCredits(self):
+ def get_credits(self):
res = self.load(self.API_URL,
- get={'apikey': self.getConfig('passkey'),
+ get={'apikey': self.get_config('passkey'),
'pyload': "1",
'source': "pyload",
'action': "usercaptchaguthaben"})
if res.isdigit():
- self.logInfo(_("%s credits left") % res)
+ self.log_info(_("%s credits left") % res)
credits = self.info['credits'] = int(res)
return credits
else:
- self.logError(res)
+ self.log_error(res)
return 0
@threaded
- def _processCaptcha(self, task):
+ def _process_captcha(self, task):
try:
with open(task.captchaFile, 'rb') as f:
data = f.read()
except IOError, e:
- self.logError(e)
+ self.log_error(e)
return
pluginname = re.search(r'_([^_]*)_\d+.\w+', task.captchaFile).group(1)
@@ -75,14 +75,14 @@ class Captcha9Kw(Hook):
'numeric' : 0,
'case_sensitive': 0,
'math' : 0,
- 'prio' : min(max(self.getConfig('prio'), 0), 10),
- 'confirm' : self.getConfig('confirm'),
- 'timeout' : min(max(self.getConfig('timeout'), 300), 3999),
- 'selfsolve' : self.getConfig('selfsolve'),
- 'cph' : self.getConfig('captchaperhour'),
- 'cpm' : self.getConfig('captchapermin')}
+ 'prio' : min(max(self.get_config('prio'), 0), 10),
+ 'confirm' : self.get_config('confirm'),
+ 'timeout' : min(max(self.get_config('timeout'), 300), 3999),
+ 'selfsolve' : self.get_config('selfsolve'),
+ 'cph' : self.get_config('captchaperhour'),
+ 'cpm' : self.get_config('captchapermin')}
- for opt in str(self.getConfig('hoster_options').split('|')):
+ for opt in str(self.get_config('hoster_options').split('|')):
details = map(str.strip, opt.split(':'))
@@ -101,7 +101,7 @@ class Captcha9Kw(Hook):
break
- post_data = {'apikey' : self.getConfig('passkey'),
+ post_data = {'apikey' : self.get_config('passkey'),
'prio' : option['prio'],
'confirm' : option['confirm'],
'maxtimeout' : option['timeout'],
@@ -131,16 +131,16 @@ class Captcha9Kw(Hook):
if res and res.isdigit():
break
else:
- self.logError(_("Bad upload: %s") % res)
+ self.log_error(_("Bad upload: %s") % res)
return
- self.logDebug("NewCaptchaID ticket: %s" % res, task.captchaFile)
+ self.log_debug("NewCaptchaID ticket: %s" % res, task.captchaFile)
task.data['ticket'] = res
- for _i in xrange(int(self.getConfig('timeout') / 5)):
+ for _i in xrange(int(self.get_config('timeout') / 5)):
result = self.load(self.API_URL,
- get={'apikey': self.getConfig('passkey'),
+ get={'apikey': self.get_config('passkey'),
'id' : res,
'pyload': "1",
'info' : "1",
@@ -152,10 +152,10 @@ class Captcha9Kw(Hook):
else:
break
else:
- self.logDebug("Could not send request: %s" % res)
+ self.log_debug("Could not send request: %s" % res)
result = None
- self.logInfo(_("Captcha result for ticket %s: %s") % (res, result))
+ self.log_info(_("Captcha result for ticket %s: %s") % (res, result))
task.setResult(result)
@@ -164,20 +164,20 @@ class Captcha9Kw(Hook):
if not task.isTextual() and not task.isPositional():
return
- if not self.getConfig('passkey'):
+ if not self.get_config('passkey'):
return
- if self.core.isClientConnected() and self.getConfig('check_client'):
+ if self.core.isClientConnected() and self.get_config('check_client'):
return
- credits = self.getCredits()
+ credits = self.get_credits()
if not credits:
- self.logError(_("Your captcha 9kw.eu account has not enough credits"))
+ self.log_error(_("Your captcha 9kw.eu account has not enough credits"))
return
- queue = min(self.getConfig('queue'), 999)
- timeout = min(max(self.getConfig('timeout'), 300), 3999)
+ queue = min(self.get_config('queue'), 999)
+ timeout = min(max(self.get_config('timeout'), 300), 3999)
pluginname = re.search(r'_([^_]*)_\d+.\w+', task.captchaFile).group(1)
for _i in xrange(5):
@@ -189,7 +189,7 @@ class Captcha9Kw(Hook):
else:
self.fail(_("Too many captchas in queue"))
- for opt in str(self.getConfig('hoster_options').split('|')):
+ for opt in str(self.get_config('hoster_options').split('|')):
details = map(str.strip, opt.split(':'))
if not details or details[0].lower() != pluginname.lower():
@@ -209,17 +209,17 @@ class Captcha9Kw(Hook):
task.setWaiting(timeout)
- self._processCaptcha(task)
+ self._process_captcha(task)
- def _captchaResponse(self, task, correct):
+ def _captcha_response(self, task, correct):
type = "correct" if correct else "refund"
if 'ticket' not in task.data:
- self.logDebug("No CaptchaID for %s request (task: %s)" % (type, task))
+ self.log_debug("No CaptchaID for %s request (task: %s)" % (type, task))
return
- passkey = self.getConfig('passkey')
+ passkey = self.get_config('passkey')
for _i in xrange(3):
res = self.load(self.API_URL,
@@ -231,19 +231,19 @@ class Captcha9Kw(Hook):
'source' : "pyload",
'id' : task.data['ticket']})
- self.logDebug("Request %s: %s" % (type, res))
+ self.log_debug("Request %s: %s" % (type, res))
if res == "OK":
break
time.sleep(5)
else:
- self.logDebug("Could not send %s request: %s" % (type, res))
+ self.log_debug("Could not send %s request: %s" % (type, res))
def captcha_correct(self, task):
- self._captchaResponse(task, True)
+ self._captcha_response(task, True)
def captcha_invalid(self, task):
- self._captchaResponse(task, False)
+ self._captcha_response(task, False)