summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/CaptchaBrotherhood.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks/CaptchaBrotherhood.py')
-rw-r--r--module/plugins/hooks/CaptchaBrotherhood.py38
1 files changed, 17 insertions, 21 deletions
diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py
index 3c08f5e36..6dbb67335 100644
--- a/module/plugins/hooks/CaptchaBrotherhood.py
+++ b/module/plugins/hooks/CaptchaBrotherhood.py
@@ -4,17 +4,16 @@ from __future__ import with_statement
import StringIO
import pycurl
+import time
+import urllib
try:
from PIL import Image
except ImportError:
import Image
-from time import sleep
-from urllib import urlencode
-
from module.network.RequestFactory import getURL, getRequest
-from module.plugins.Hook import Hook, threaded
+from module.plugins.internal.Hook import Hook, threaded
class CaptchaBrotherhoodException(Exception):
@@ -38,7 +37,7 @@ class CaptchaBrotherhoodException(Exception):
class CaptchaBrotherhood(Hook):
__name__ = "CaptchaBrotherhood"
__type__ = "hook"
- __version__ = "0.08"
+ __version__ = "0.09"
__config__ = [("username", "str", "Username", ""),
("force", "bool", "Force CT even if client is connected", False),
@@ -46,16 +45,13 @@ class CaptchaBrotherhood(Hook):
__description__ = """Send captchas to CaptchaBrotherhood.com"""
__license__ = "GPLv3"
- __authors__ = [("RaNaN", "RaNaN@pyload.org"),
+ __authors__ = [("RaNaN" , "RaNaN@pyload.org" ),
("zoidberg", "zoidberg@mujmail.cz")]
- API_URL = "http://www.captchabrotherhood.com/"
-
+ interval = 0 #@TODO: Remove in 0.4.10
- #@TODO: Remove in 0.4.10
- def initPeriodical(self):
- pass
+ API_URL = "http://www.captchabrotherhood.com/"
def setup(self):
@@ -64,7 +60,7 @@ class CaptchaBrotherhood(Hook):
def getCredits(self):
res = getURL(self.API_URL + "askCredits.aspx",
- get={"username": self.getConfig("username"), "password": self.getConfig("passkey")})
+ get={"username": self.getConfig('username'), "password": self.getConfig('passkey')})
if not res.startswith("OK"):
raise CaptchaBrotherhoodException(res)
else:
@@ -93,10 +89,10 @@ class CaptchaBrotherhood(Hook):
req = getRequest()
url = "%ssendNewCaptcha.aspx?%s" % (self.API_URL,
- urlencode({'username' : self.getConfig("username"),
- 'password' : self.getConfig("passkey"),
- 'captchaSource': "pyLoad",
- 'timeout' : "80"}))
+ urllib.urlencode({'username' : self.getConfig('username'),
+ 'password' : self.getConfig('passkey'),
+ 'captchaSource': "pyLoad",
+ 'timeout' : "80"}))
req.c.setopt(pycurl.URL, url)
req.c.setopt(pycurl.POST, 1)
@@ -117,7 +113,7 @@ class CaptchaBrotherhood(Hook):
ticket = res[3:]
for _i in xrange(15):
- sleep(5)
+ time.sleep(5)
res = self.api_response("askCaptchaResult", ticket)
if res.startswith("OK-answered"):
return ticket, res[12:]
@@ -127,8 +123,8 @@ class CaptchaBrotherhood(Hook):
def api_response(self, api, ticket):
res = getURL("%s%s.aspx" % (self.API_URL, api),
- get={"username": self.getConfig("username"),
- "password": self.getConfig("passkey"),
+ get={"username": self.getConfig('username'),
+ "password": self.getConfig('passkey'),
"captchaID": ticket})
if not res.startswith("OK"):
raise CaptchaBrotherhoodException("Unknown response: %s" % res)
@@ -143,10 +139,10 @@ class CaptchaBrotherhood(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
if self.getCredits() > 10: