diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2012-07-27 01:03:51 +0200 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2012-07-27 01:03:51 +0200 |
commit | 50c731a306f8d85aa1775c7867e945ecd138d8f6 (patch) | |
tree | 015cb8dc0edf883e4857f2b095beaa0faf33303b /module/plugins | |
parent | Uploaded.to Premium Account Fix (diff) | |
download | pyload-50c731a306f8d85aa1775c7867e945ecd138d8f6.tar.xz |
expertdecoders.com captcha solving
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/hooks/ExpertDecoders.py | 112 | ||||
-rw-r--r-- | module/plugins/hoster/UlozTo.py | 9 |
2 files changed, 117 insertions, 4 deletions
diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py new file mode 100644 index 000000000..2e66e49ca --- /dev/null +++ b/module/plugins/hooks/ExpertDecoders.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see <http://www.gnu.org/licenses/>. + + @author: mkaay, RaNaN, zoidberg +""" +from __future__ import with_statement + +from thread import start_new_thread +from pycurl import FORM_FILE, LOW_SPEED_TIME +from uuid import uuid4 +from base64 import b64encode + +from module.network.RequestFactory import getURL, getRequest +from module.network.HTTPRequest import BadHeader + +from module.plugins.Hook import Hook + +class ExpertDecoders(Hook): + __name__ = "ExpertDecoders" + __version__ = "0.01" + __description__ = """send captchas to expertdecoders.com""" + __config__ = [("activated", "bool", "Activated", False), + ("force", "bool", "Force CT even if client is connected", False), + ("passkey", "password", "Access key", ""),] + __author_name__ = ("RaNaN", "zoidberg") + __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz") + + API_URL = "http://www.fasttypers.org/imagepost.ashx" + + def setup(self): + self.info = {} + + def getCredits(self): + response = getURL(self.API_URL, post = { "key": self.getConfig("passkey"), "action": "balance" }) + + if response.isdigit(): + self.logInfo(_("%s credits left") % response) + self.info["credits"] = credits = int(response) + return credits + else: + self.logError(response) + return 0 + + def processCaptcha(self, task): + task.data["ticket"] = ticket = uuid4() + result = None + + with open(task.captchaFile, 'rb') as f: + data = f.read() + data = b64encode(data) + #self.logDebug("%s: %s : %s" % (ticket, task.captchaFile, data)) + + req = getRequest() + #raise timeout threshold + req.c.setopt(LOW_SPEED_TIME, 80) + + try: + result = req.load(self.API_URL, + post={ "action": "upload", + "key": self.getConfig("passkey"), + "file": data, + "gen_task_id": ticket } + ) + finally: + req.close() + + self.logDebug("result %s : %s" % (ticket, result)) + task.setResult(result) + + def newCaptchaTask(self, task): + if not task.isTextual(): + return False + + if not self.getConfig("passkey"): + return False + + if self.core.isClientConnected() and not self.getConfig("force"): + return False + + if self.getCredits() > 0: + task.handler.append(self) + task.setWaiting(100) + start_new_thread(self.processCaptcha, (task,)) + + else: + self.logInfo(_("Your ExpertDecoders Account has not enough credits")) + + def captchaInvalid(self, task): + if "ticket" in task.data: + + try: + response = getURL(self.API_URL, + post={ "action": "refund", + "key": self.getConfig("passkey"), + "gen_task_id": task.data["ticket"] } + ) + self.logInfo("Request refund: %s" % response) + + except BadHeader, e: + self.logError("Could not send refund request.", str(e))
\ No newline at end of file diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py index e4d9766d7..5344ee09c 100644 --- a/module/plugins/hoster/UlozTo.py +++ b/module/plugins/hoster/UlozTo.py @@ -27,12 +27,12 @@ class UlozTo(SimpleHoster): __name__ = "UlozTo" __type__ = "hoster" __pattern__ = r"http://(\w*\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj.cz|zachowajto.pl)/(?:live/)?(?P<id>\w+/[^/?]*)" - __version__ = "0.88" + __version__ = "0.89" __description__ = """uloz.to""" __author_name__ = ("zoidberg") FILE_NAME_PATTERN = r'<a href="#download" class="jsShowDownload">(?P<N>[^<]+)</a>' - FILE_SIZE_PATTERN = r'<span id="fileSize">(?P<S>[^<]+)</span>' + FILE_SIZE_PATTERN = r'<span id="fileSize">.*?(?P<S>[0-9.]+\s[kMG]B)</span>' FILE_INFO_PATTERN = r'<p>File <strong>(?P<N>[^<]+)</strong> is password protected</p>' FILE_OFFLINE_PATTERN = r'<title>404 - Page not found</title>|<h1 class="h1">File (has been deleted|was banned)</h1>' FILE_SIZE_REPLACEMENTS = [('([0-9.]+)\s([kMG])B', convertDecimalPrefix)] @@ -132,7 +132,7 @@ class UlozTo(SimpleHoster): "wrong_captcha": re.compile(r'<ul class="error">\s*<li>Error rewriting the text.</li>'), "offline": re.compile(self.FILE_OFFLINE_PATTERN), "passwd": self.PASSWD_PATTERN, - "paralell_dl": "<title>Uloz.to - Již stahuješ</title>", + "server_error": "<title>Ulo[zž].to - ([^<]+)</title>", #paralell dl, server overload etc. "not_found": "<title>Ulož.to</title>" }) @@ -145,7 +145,8 @@ class UlozTo(SimpleHoster): self.offline() elif check == "passwd": self.fail("Wrong password") - elif check == "paralell_dl": + elif check == "server_error": + self.logError("Server error: %s" % self.lastCheck.group(1)) self.multiDL = False self.setWait(300, True) self.wait() |