diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-07-24 18:27:10 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-07-24 18:27:10 +0200 |
commit | 7f1c321187415e215bac07394ebb05e74c501fd8 (patch) | |
tree | 8ca05eae2953b97d20ea5265b19c3b4b7b700477 | |
parent | improved login mechanism (diff) | |
download | pyload-7f1c321187415e215bac07394ebb05e74c501fd8.tar.xz |
more fixed for plugin tester
-rw-r--r-- | tests/HosterPluginTester.py | 2 | ||||
-rw-r--r-- | tests/helper/PluginTester.py | 79 | ||||
-rwxr-xr-x | tests/hosterlinks.txt | 2 |
3 files changed, 26 insertions, 57 deletions
diff --git a/tests/HosterPluginTester.py b/tests/HosterPluginTester.py index 3a6eca84b..4f32ee9e7 100644 --- a/tests/HosterPluginTester.py +++ b/tests/HosterPluginTester.py @@ -102,8 +102,6 @@ for f in sections["files"]: del sections["files"] -print HosterPluginTester.files - urls = [] status = {} diff --git a/tests/helper/PluginTester.py b/tests/helper/PluginTester.py index 2bfb16af7..b3c93311c 100644 --- a/tests/helper/PluginTester.py +++ b/tests/helper/PluginTester.py @@ -7,7 +7,6 @@ from shutil import move from sys import exc_clear, exc_info from logging import log, DEBUG from time import sleep, time -from random import randint from glob import glob from pycurl import LOW_SPEED_TIME, FORM_FILE @@ -15,7 +14,7 @@ from json import loads from Stubs import Thread, Core, noop -from pyload.network.RequestFactory import getRequest, getURL +from pyload.network.RequestFactory import getRequest from pyload.plugins.Base import Abort, Fail from pyload.plugins.Hoster import Hoster @@ -50,74 +49,44 @@ def decryptCaptcha(self, url, get={}, post={}, cookies=False, forceUser=False, i temp_file.write(img) temp_file.close() - Ocr = self.core.pluginManager.loadClass("captcha", self.__name__) - - if Ocr: - log(DEBUG, "Using tesseract for captcha") - sleep(randint(3000, 5000) / 1000.0) - if self.pyfile.abort: raise Abort - - ocr = Ocr() - result = ocr.get_captcha(temp_file.name) - else: - log(DEBUG, "Using ct for captcha") - # put username and passkey into two lines in ct.conf - conf = join(expanduser("~"), "ct.conf") - if not exists(conf): raise Exception("CaptchaTrader config %s not found." % conf) - f = open(conf, "rb") - req = getRequest() - - #raise timeout threshold - req.c.setopt(LOW_SPEED_TIME, 80) - - try: - json = req.load("http://captchatrader.com/api/submit", - post={"api_key": "9f65e7f381c3af2b076ea680ae96b0b7", - "username": f.readline().strip(), - "password": f.readline().strip(), - "value": (FORM_FILE, temp_file.name), - "type": "file"}, multipart=True) - finally: - f.close() - req.close() - - response = loads(json) - log(DEBUG, str(response)) - result = response[1] - - self.cTask = response[0] - - return result - -Hoster.decryptCaptcha = decryptCaptcha - - -def respond(ticket, value): + log(DEBUG, "Using ct for captcha") + # put username and passkey into two lines in ct.conf conf = join(expanduser("~"), "ct.conf") + if not exists(conf): raise Exception("CaptchaService config %s not found." % conf) f = open(conf, "rb") + req = getRequest() + + #raise timeout threshold + req.c.setopt(LOW_SPEED_TIME, 300) + try: - getURL("http://captchatrader.com/api/respond", - post={"is_correct": value, + json = req.load("http://captchatrader.com/api/submit", + post={"api_key": "9f65e7f381c3af2b076ea680ae96b0b7", "username": f.readline().strip(), "password": f.readline().strip(), - "ticket": ticket}) - except Exception, e : - print "CT Exception:", e - log(DEBUG, str(e)) + "value": (FORM_FILE, temp_file.name), + "type": "file"}, multipart=True) finally: f.close() + req.close() + + response = loads(json) + log(DEBUG, str(response)) + result = response[1] + + self.cTask = response[0] + + return result + +Hoster.decryptCaptcha = decryptCaptcha def invalidCaptcha(self): log(DEBUG, "Captcha invalid") - if self.cTask: - respond(self.cTask, 0) Hoster.invalidCaptcha = invalidCaptcha def correctCaptcha(self): log(DEBUG, "Captcha correct") - if self.cTask: - respond(self.cTask, 1) Hoster.correctCaptcha = correctCaptcha diff --git a/tests/hosterlinks.txt b/tests/hosterlinks.txt index 32418a66f..f717fee28 100755 --- a/tests/hosterlinks.txt +++ b/tests/hosterlinks.txt @@ -6,6 +6,8 @@ # Two variants of filename with special chars räándöóm.bin 5dde9e312311d964572f5a33a0992a2c random (机会,ឱកស,ランダム,隨機,лчаный,cơhội,შანსი,కంħن↓∂ƒ_স€קสม®¢äöář_æžĐşiồй_ныứ&+).bin 5dde9e312311d964572f5a33a0992a2c +# One host changed the name to this, with one little difference +random (机会,ឱកស,ランダム,隨機,лчаный,cơhội,შანსი,కంħن↓∂ƒ_স€קสม®¢äöář_æžđşiồй_ныứ&+).bin 5dde9e312311d964572f5a33a0992a2c random100.bin f346c3ea47d8bfce3a12033129dec8ff |