From 80ecab8f0c664bc43b9db10bee0cb815a96c1039 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 4 Jan 2015 20:20:34 +0100 Subject: Improve processCaptcha thread in hook plugins --- module/plugins/hooks/DeathByCaptcha.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index f03ac4567..98412c218 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -6,13 +6,12 @@ import re from base64 import b64encode from pycurl import FORM_FILE, HTTPHEADER -from thread import start_new_thread from time import sleep from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader from module.network.RequestFactory import getRequest -from module.plugins.Hook import Hook +from module.plugins.Hook import Hook, threaded class DeathByCaptchaException(Exception): @@ -52,7 +51,7 @@ class DeathByCaptchaException(Exception): class DeathByCaptcha(Hook): __name__ = "DeathByCaptcha" __type__ = "hook" - __version__ = "0.04" + __version__ = "0.05" __config__ = [("username", "str", "Username", ""), ("passkey", "password", "Password", ""), @@ -195,7 +194,7 @@ class DeathByCaptcha(Hook): task.handler.append(self) task.data['service'] = self.__name__ task.setWaiting(180) - start_new_thread(self.processCaptcha, (task,)) + self._processCaptcha(task) def captchaInvalid(self, task): @@ -210,7 +209,8 @@ class DeathByCaptcha(Hook): self.logError(e) - def processCaptcha(self, task): + @threaded + def _processCaptcha(self, task): c = task.captchaFile try: ticket, result = self.submit(c) -- cgit v1.2.3 From e977be3c78ea9d976e9b2338244b214a4b3a5199 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 8 Jan 2015 23:40:17 +0100 Subject: "New Year" Update: hook plugins --- module/plugins/hooks/DeathByCaptcha.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 98412c218..050b6fe15 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -51,7 +51,7 @@ class DeathByCaptchaException(Exception): class DeathByCaptcha(Hook): __name__ = "DeathByCaptcha" __type__ = "hook" - __version__ = "0.05" + __version__ = "0.06" __config__ = [("username", "str", "Username", ""), ("passkey", "password", "Password", ""), @@ -75,7 +75,7 @@ class DeathByCaptcha(Hook): self.info = {} #@TODO: Remove in 0.4.10 - def call_api(self, api="captcha", post=False, multipart=False): + def api_response(self, api="captcha", post=False, multipart=False): req = getRequest() req.c.setopt(HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) @@ -117,7 +117,7 @@ class DeathByCaptcha(Hook): def getCredits(self): - res = self.call_api("user", True) + res = self.api_response("user", True) if 'is_banned' in res and res['is_banned']: raise DeathByCaptchaException('banned') @@ -128,7 +128,7 @@ class DeathByCaptcha(Hook): def getStatus(self): - res = self.call_api("status", False) + res = self.api_response("status", False) if 'is_service_overloaded' in res and res['is_service_overloaded']: raise DeathByCaptchaException('service-overload') @@ -145,7 +145,7 @@ class DeathByCaptcha(Hook): data = f.read() data = "base64:" + b64encode(data) - res = self.call_api("captcha", {"captchafile": data}, multipart) + res = self.api_response("captcha", {"captchafile": data}, multipart) if "captcha" not in res: raise DeathByCaptchaException(res) @@ -153,7 +153,7 @@ class DeathByCaptcha(Hook): for _i in xrange(24): sleep(5) - res = self.call_api("captcha/%d" % ticket, False) + res = self.api_response("captcha/%d" % ticket, False) if res['text'] and res['is_correct']: break else: @@ -200,7 +200,7 @@ class DeathByCaptcha(Hook): def captchaInvalid(self, task): if task.data['service'] == self.__name__ and "ticket" in task.data: try: - res = self.call_api("captcha/%d/report" % task.data['ticket'], True) + res = self.api_response("captcha/%d/report" % task.data['ticket'], True) except DeathByCaptchaException, e: self.logError(e.getDesc()) -- cgit v1.2.3 From cf4ded052964047de88d676045329b8fa4fca2dc Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 22 Jan 2015 21:31:19 +0100 Subject: Update plugins after CaptchaService changes --- module/plugins/hooks/DeathByCaptcha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 050b6fe15..d513c446d 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -135,7 +135,7 @@ class DeathByCaptcha(Hook): def submit(self, captcha, captchaType="file", match=None): - #workaround multipart-post bug in HTTPRequest.py + #@NOTE: Workaround multipart-post bug in HTTPRequest.py if re.match("^\w*$", self.getConfig("passkey")): multipart = True data = (FORM_FILE, captcha) -- cgit v1.2.3 From 6f7002bcc3520c47fafe5122b0e0cbada313887d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 23:39:59 +0100 Subject: Whitespace cosmetics --- module/plugins/hooks/DeathByCaptcha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index d513c446d..a67e70c7e 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -59,7 +59,7 @@ class DeathByCaptcha(Hook): __description__ = """Send captchas to DeathByCaptcha.com""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.org"), + __authors__ = [("RaNaN" , "RaNaN@pyload.org" ), ("zoidberg", "zoidberg@mujmail.cz")] -- cgit v1.2.3 From 7beb65e991bc6d1913c3b5bb2ef69e659d5b8342 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 01:55:52 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/DeathByCaptcha.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index a67e70c7e..4eefb2bff 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -82,8 +82,8 @@ class DeathByCaptcha(Hook): if post: if not isinstance(post, dict): post = {} - post.update({"username": self.getConfig("username"), - "password": self.getConfig("passkey")}) + post.update({"username": self.getConfig('username'), + "password": self.getConfig('passkey')}) res = None try: @@ -136,7 +136,7 @@ class DeathByCaptcha(Hook): def submit(self, captcha, captchaType="file", match=None): #@NOTE: Workaround multipart-post bug in HTTPRequest.py - if re.match("^\w*$", self.getConfig("passkey")): + if re.match("^\w*$", self.getConfig('passkey')): multipart = True data = (FORM_FILE, captcha) else: @@ -172,10 +172,10 @@ class DeathByCaptcha(Hook): if not task.isTextual(): return False - if not self.getConfig("username") or not self.getConfig("passkey"): + if not self.getConfig('username') or not self.getConfig('passkey'): return False - if self.core.isClientConnected() and not self.getConfig("force"): + if self.core.isClientConnected() and not self.getConfig('force'): return False try: -- cgit v1.2.3 From e65d19ee3a1e435bf2896ed829e5581eeef92dd2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 14 Mar 2015 11:07:54 +0100 Subject: Import cleanup for datetime and time modules --- module/plugins/hooks/DeathByCaptcha.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 4eefb2bff..e408dcab7 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -3,10 +3,10 @@ from __future__ import with_statement import re +import time from base64 import b64encode from pycurl import FORM_FILE, HTTPHEADER -from time import sleep from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader @@ -152,7 +152,7 @@ class DeathByCaptcha(Hook): ticket = res['captcha'] for _i in xrange(24): - sleep(5) + time.sleep(5) res = self.api_response("captcha/%d" % ticket, False) if res['text'] and res['is_correct']: break -- cgit v1.2.3 From f1ce338ed31e49373cea5453a2fbdb6c686ca510 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 26 Mar 2015 10:16:04 +0100 Subject: interval code cosmetics --- module/plugins/hooks/DeathByCaptcha.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index e408dcab7..501de0c1a 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -63,12 +63,9 @@ class DeathByCaptcha(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - API_URL = "http://api.dbcapi.me/api/" - + interval = 0 #@TODO: Remove in 0.4.10 - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + API_URL = "http://api.dbcapi.me/api/" def setup(self): -- cgit v1.2.3 From 1ef93e913238275f7657d496ba3d2e7eeb5a30a2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 May 2015 01:06:01 +0200 Subject: Use 'import' instead 'from' --- module/plugins/hooks/DeathByCaptcha.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/DeathByCaptcha.py') diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 501de0c1a..f9618f011 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -2,11 +2,11 @@ from __future__ import with_statement +import pycurl import re import time from base64 import b64encode -from pycurl import FORM_FILE, HTTPHEADER from module.common.json_layer import json_loads from module.network.HTTPRequest import BadHeader @@ -74,7 +74,7 @@ class DeathByCaptcha(Hook): def api_response(self, api="captcha", post=False, multipart=False): req = getRequest() - req.c.setopt(HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) + req.c.setopt(pycurl.HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) if post: if not isinstance(post, dict): @@ -135,7 +135,7 @@ class DeathByCaptcha(Hook): #@NOTE: Workaround multipart-post bug in HTTPRequest.py if re.match("^\w*$", self.getConfig('passkey')): multipart = True - data = (FORM_FILE, captcha) + data = (pycurl.FORM_FILE, captcha) else: multipart = False with open(captcha, 'rb') as f: -- cgit v1.2.3