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.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py
index 050b6fe15..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 time import sleep
from module.common.json_layer import json_loads
from module.network.HTTPRequest import BadHeader
@@ -59,16 +59,13 @@ 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")]
- 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):
@@ -77,13 +74,13 @@ 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):
post = {}
- post.update({"username": self.getConfig("username"),
- "password": self.getConfig("passkey")})
+ post.update({"username": self.getConfig('username'),
+ "password": self.getConfig('passkey')})
res = None
try:
@@ -135,10 +132,10 @@ class DeathByCaptcha(Hook):
def submit(self, captcha, captchaType="file", match=None):
- #workaround multipart-post bug in HTTPRequest.py
- if re.match("^\w*$", self.getConfig("passkey")):
+ #@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:
@@ -152,7 +149,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
@@ -172,10 +169,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: