summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2011-01-31 19:06:22 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2011-01-31 19:06:22 +0100
commitcca1c563a0acc1c5dbd0552b4d610f1325f53559 (patch)
tree7fc238d5f7d724ef21a0d99ed89f567e1d1b6def /module/plugins
parentAdded tag v0.4.4 for changeset e328358b2009 (diff)
downloadpyload-cca1c563a0acc1c5dbd0552b4d610f1325f53559.tar.xz
added captchatrader.com support, fixed lof.cc
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/Plugin.py44
-rw-r--r--module/plugins/ReCaptcha.py4
-rw-r--r--module/plugins/container/CCF.py2
-rw-r--r--module/plugins/crypter/LofCc.py2
-rw-r--r--module/plugins/crypter/SerienjunkiesOrg.py2
5 files changed, 44 insertions, 10 deletions
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index 8e48e0ff3..3630e5222 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -38,6 +38,8 @@ if os.name != "nt":
from itertools import islice
+from thread import start_new_thread
+
from module.utils import save_join
def chunks(iterable, size):
@@ -108,6 +110,7 @@ class Plugin(object):
self.lastDownload = "" # location where the last call to download was saved
self.lastCheck = None #re match of last checked matched
self.js = self.core.js # js engine
+ self.ctresult = None
self.html = None #some plugins store html code here
@@ -218,15 +221,17 @@ class Plugin(object):
def retry(self):
""" begin again from the beginning """
+ if self.ctresult:
+ self.self.ctresult.fail()
raise Retry
- def decryptCaptcha(self, url, get={}, post={}, cookies=False, forceUser=False):
+ def decryptCaptcha(self, url, get={}, post={}, cookies=False, forceUser=False, imgtype="jpg"):
""" loads the catpcha and decrypt it or ask the user for input """
content = self.load(url, get=get, post=post, cookies=cookies)
id = ("%.2f" % time())[-6:]
- temp = open(join("tmp","tmpCaptcha_%s_%s" % (self.__name__, id)), "wb")
+ temp = open(join("tmp","tmpCaptcha_%s_%s.%s" % (self.__name__, id, imgtype)), "wb")
temp.write(content)
temp.close()
@@ -245,17 +250,46 @@ class Plugin(object):
ocr = Ocr()
result = ocr.get_captcha(temp.name)
else:
+
captchaManager = self.core.captchaManager
task = captchaManager.newTask(self)
- task.setCaptcha(content, None) #@TODO mimetype really needed?
+ task.setCaptcha(content, imgtype)
task.setWaiting()
+
+ ct = None
+ if self.core.config["captchatrader"]["username"] and self.core.config["captchatrader"]["password"]:
+ task.setWatingForUser(exclusive=True)
+ from module.lib.captchatrader import CaptchaTrader
+ ct = CaptchaTrader(self.core.config["captchatrader"]["username"], self.core.config["captchatrader"]["password"])
+ if ct.getCredits < 10:
+ self.log.info("Not enough credits for CaptchaTrader")
+ task.setWaiting()
+ else:
+ self.log.info("Submitting to CaptchaTrader")
+ def threaded(ct):
+ cf = open(join("tmp","tmpCaptcha_%s_%s.%s" % (self.__name__, id, imgtype)), "rb")
+ try:
+ result = ct.submit(cf)
+ except:
+ self.log.warning("CaptchaTrader error!")
+ if self.core.debug:
+ from traceback import print_exc
+ print_exc()
+ ct = None
+ task.setWaiting()
+ else:
+ self.ctresult = result
+ task.setResult(result.getResult())
+ task.setDone()
+ start_new_thread(threaded, (ct, ))
+
while not task.getStatus() == "done":
if not self.core.isClientConnected():
task.removeTask()
#temp.unlink(temp.name)
- if has_plugin:
+ if has_plugin and not ct:
self.fail(_("Pil and tesseract not installed and no Client connected for captcha decrypting"))
- else:
+ elif not ct:
self.fail(_("No Client connected for captcha decrypting"))
if self.pyfile.abort:
task.removeTask()
diff --git a/module/plugins/ReCaptcha.py b/module/plugins/ReCaptcha.py
index d29530a64..ec366695a 100644
--- a/module/plugins/ReCaptcha.py
+++ b/module/plugins/ReCaptcha.py
@@ -5,13 +5,13 @@ class ReCaptcha():
self.plugin = plugin
def challenge(self, id):
- js = self.plugin.req.load("http://api.recaptcha.net/challenge", get={"k":id}, cookies=True)
+ js = self.plugin.req.load("http://www.google.com/recaptcha/api/challenge", get={"k":id}, cookies=True)
try:
challenge = re.search("challenge : '(.*?)',", js).group(1)
server = re.search("server : '(.*?)',", js).group(1)
except:
self.plugin.fail("recaptcha error")
- result = self.plugin.decryptCaptcha("%simage"%server, get={"c":challenge}, cookies=True)
+ result = self.plugin.decryptCaptcha("%simage"%server, get={"c":challenge}, cookies=True, imgtype="jpg")
return challenge, result
diff --git a/module/plugins/container/CCF.py b/module/plugins/container/CCF.py
index 90502c001..d7da2f93b 100644
--- a/module/plugins/container/CCF.py
+++ b/module/plugins/container/CCF.py
@@ -5,7 +5,7 @@ import re
from urllib2 import build_opener
from module.plugins.Container import Container
-from module.network.MultipartPostHandler import MultipartPostHandler
+from module.lib.MultipartPostHandler import MultipartPostHandler
from os import makedirs
from os.path import exists, join
diff --git a/module/plugins/crypter/LofCc.py b/module/plugins/crypter/LofCc.py
index cd3a6fe4d..3785ce600 100644
--- a/module/plugins/crypter/LofCc.py
+++ b/module/plugins/crypter/LofCc.py
@@ -23,7 +23,7 @@ class LofCc(Crypter):
def decrypt(self, pyfile):
html = self.req.load(self.pyfile.url, cookies=True)
- m = re.search(r"src=\"http://api.recaptcha.net/challenge\?k=(.*?)\"></script>", html)
+ m = re.search(r"src=\"http://www.google.com/recaptcha/api/challenge\?k=(.*?)\"></script>", html)
if not m:
self.offline()
diff --git a/module/plugins/crypter/SerienjunkiesOrg.py b/module/plugins/crypter/SerienjunkiesOrg.py
index 193f6b417..7d637369e 100644
--- a/module/plugins/crypter/SerienjunkiesOrg.py
+++ b/module/plugins/crypter/SerienjunkiesOrg.py
@@ -131,7 +131,7 @@ class SerienjunkiesOrg(Crypter):
self.retry()
captchaUrl = "http://download.serienjunkies.org"+captchaTag["src"]
- result = self.decryptCaptcha(str(captchaUrl))
+ result = self.decryptCaptcha(str(captchaUrl), imgtype="png")
sinp = form.find(attrs={"name":"s"})
self.req.lastUrl = url