diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-10-03 14:49:16 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-10-03 14:49:16 +0200 |
commit | 3ef26c71cb3c23a876b95af77f6541c06227a937 (patch) | |
tree | 481462718d3c99410cad9dd4e8ffab7eed8e1f6f | |
parent | share-online premium fix (revert to old design, coz new one is still buggy) (diff) | |
download | pyload-3ef26c71cb3c23a876b95af77f6541c06227a937.tar.xz |
-rw-r--r-- | module/AccountManager.py | 2 | ||||
-rw-r--r-- | module/FileDatabase.py | 5 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 6 | ||||
-rw-r--r-- | module/plugins/accounts/HotfileCom.py | 7 | ||||
-rw-r--r-- | module/plugins/hooks/UpdateManager.py | 4 | ||||
-rw-r--r-- | module/plugins/hoster/HotfileCom.py | 4 | ||||
-rw-r--r-- | module/plugins/hoster/UploadedTo.py | 118 | ||||
-rw-r--r-- | module/web/pyload/views.py | 7 | ||||
-rw-r--r-- | module/web/templates/default/settings.html | 6 |
9 files changed, 87 insertions, 72 deletions
diff --git a/module/AccountManager.py b/module/AccountManager.py index 0ca3c75a8..7ef986600 100644 --- a/module/AccountManager.py +++ b/module/AccountManager.py @@ -165,7 +165,7 @@ class AccountManager(): p = self.getAccountPlugin(p) data[p.__name__] = p.getAllAccounts(force) else: - data[p] = {} + data[p] = [] return data def cacheAccountInfos(self): diff --git a/module/FileDatabase.py b/module/FileDatabase.py index 4f1c1a541..793a4a69e 100644 --- a/module/FileDatabase.py +++ b/module/FileDatabase.py @@ -20,7 +20,6 @@ from Queue import Queue from os import remove from os.path import exists from shutil import move -import sqlite3 from threading import Lock from threading import RLock from threading import Thread @@ -33,6 +32,10 @@ from module.PullEvents import ReloadAllEvent from module.PullEvents import RemoveEvent from module.PullEvents import UpdateEvent +try: + from pysqlite2 import dbapi2 as sqlite3 +except: + import sqlite3 DB_VERSION = 2 diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index af164c3a5..e34543100 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -343,3 +343,9 @@ class Plugin(object): if delete: remove(self.lastDownload) return name + + def resetAccount(self): + """ invalidates an account, so it will not be used """ + if self.account: + data = self.account.getAccountData(self.user) + data["valid"] = False diff --git a/module/plugins/accounts/HotfileCom.py b/module/plugins/accounts/HotfileCom.py index 5a3fdd6a5..f623e56f1 100644 --- a/module/plugins/accounts/HotfileCom.py +++ b/module/plugins/accounts/HotfileCom.py @@ -51,12 +51,9 @@ class HotfileCom(Account): def apiCall(self, method, post={}, user=None): if user: - data = None - for account in self.accounts.items(): - if account[0] == user: - data = account[1] + data = self.getAccountData(user) else: - user, data = self.accounts.items()[0] + user, data = self.selectAccount() req = self.getAccountRequest(user) diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 02ba6a6ff..6a1a31ade 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -57,7 +57,7 @@ class UpdateManager(Hook): self.log.info(_("*** Get it here: http://pyload.org/download ***")) return True except: - self.log.error(_("Not able to connect server")) + self.log.error(_("Not able to connect server for updates")) return False @@ -67,7 +67,7 @@ class UpdateManager(Hook): try: updates = getURL("http://get.pyload.org/plugins/check/") except: - self.log.warning(_("Plugins could not be updated")) + self.log.warning(_("Not able to connect server for updates")) return False updates = updates.splitlines() diff --git a/module/plugins/hoster/HotfileCom.py b/module/plugins/hoster/HotfileCom.py index 78fd14cf6..f3c6b67dd 100644 --- a/module/plugins/hoster/HotfileCom.py +++ b/module/plugins/hoster/HotfileCom.py @@ -53,7 +53,7 @@ class HotfileCom(Hoster): if not self.account and login: return elif self.account and login: - return self.account.apiCall(method, post) + return self.account.apiCall(method, post, self.user) post.update({"action": method}) return self.load("http://api.hotfile.com/", post=post) @@ -79,7 +79,7 @@ class HotfileCom(Hoster): self.freeDownload() else: - dl = self.account.apiCall("getdirectdownloadlink", {"link":self.pyfile.url}) + dl = self.account.apiCall("getdirectdownloadlink", {"link":self.pyfile.url}, self.user) self.download(dl) def downloadHTML(self): diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 933feab39..4cd98fc3e 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -4,6 +4,7 @@ import re from module.plugins.Hoster import Hoster from module.network.Request import getURL from module.plugins.Plugin import chunks +from module.plugins.ReCaptcha import ReCaptcha def getInfo(urls): pattern = re.compile(UploadedTo.__pattern__) @@ -34,57 +35,72 @@ class UploadedTo(Hoster): self.html = None self.api_data = None self.multiDL = False + self.url = False if self.account: self.multiDL = True self.req.canContinue = True + def process(self, pyfile): - self.url = False - self.pyfile = pyfile - self.prepare() - self.proceed() - - - def getInfo(self): + self.download_html() + + if not self.file_exists(): + self.offline() + self.download_api_data() - self.pyfile.name = self.api_data["filename"] - self.pyfile.sync() - - def prepare(self): - tries = 0 - - while not self.url: - self.download_html() - - if not self.file_exists(): - self.offline() - - self.download_api_data() - - # self.pyfile.name = self.get_file_name() - - if self.account: - info = self.account.getAccountInfo(self.user, True) - self.log.debug(_("%(name)s: Use Premium Account (%(left)sGB left)") % {"name" :self.__name__, "left" : info["trafficleft"]/1024/1024}) - if self.api_data["size"]/1024 > info["trafficleft"]: - self.log.info(_("%s: Not enough traffic left" % self.__name__)) - #self.resetAcount() #@TODO implement - else: - self.url = self.get_file_url() - self.pyfile.name = self.get_file_name() - return True - - self.url = self.get_file_url() - - self.setWait(self.get_waiting_time()) + + # self.pyfile.name = self.get_file_name() + + if self.account: + info = self.account.getAccountInfo(self.user, True) + self.log.debug(_("%(name)s: Use Premium Account (%(left)sGB left)") % {"name" :self.__name__, "left" : info["trafficleft"]/1024/1024}) + if self.api_data["size"]/1024 > info["trafficleft"]: + self.log.info(_("%s: Not enough traffic left" % self.__name__)) + self.resetAccount() + self.fail(_("Traffic exceeded")) + else: + self.url = self.get_file_url() + pyfile.name = self.get_file_name() + self.download(self.url+"?redirect", cookies=True) + + return True + + + self.url = self.get_file_url() + + wait = self.get_waiting_time() + if wait: + self.setWait(wait, True) self.wait() + self.process(pyfile) + return + else: + self.setWait(30, False) + + time = re.search(r'name="time" value="([^"]+)', self.html).group(1) + time_secure = re.search(r'name="time_secure" value="([^"]+)', self.html).group(1) + file_password = re.search(r'name="file_password" value="([^"]*)', self.html).group(1) + + challenge = re.search(r"recaptcha/api/challenge\?k=([0-9A-Za-z]+)", self.html) + + options = {"time": time, "time_secure": time_secure, "file_password": file_password} + + if challenge: + re_captcha = ReCaptcha(self) + challenge, result = re_captcha.challenge(challenge.group(1)) + options["recaptcha_challenge_field"] = challenge + options["recaptcha_response_field"] = result + + self.wait() + + pyfile.name = self.get_file_name() + + self.download(self.url, post=options) - self.pyfile.name = self.get_file_name() + check = self.checkDownload({"wrong_captcha": "Wrong captcha."}) + if check == "wrong_captcha": + self.process(pyfile) - tries += 1 - if tries > 5: - self.fail("Error while preparing DL") - return True def download_api_data(self, force=False): if self.api_data and not force: @@ -113,14 +129,7 @@ class UploadedTo(Hoster): return 0 def get_file_url(self): - if self.account: - self.start_dl = True - return self.cleanUrl(self.pyfile.url) - try: - file_url_pattern = r".*<form name=\"download_form\" method=\"post\" action=\"(.*)\">" - return re.search(file_url_pattern, self.html).group(1) - except: - return None + return self.cleanUrl(self.pyfile.url) def get_file_name(self): try: @@ -139,16 +148,11 @@ class UploadedTo(Hoster): return False else: return True + def cleanUrl(self, url): url = url.replace("ul.to/", "uploaded.to/file/") url = url.replace("/?id=", "/file/") url = url.replace("?id=", "file/") url = re.sub("/\?(.*?)&id=", "/file/", url, 1) - return url - - def proceed(self): - if self.account: - self.download(self.url+"?redirect", cookies=True) - else: - self.download(self.url, cookies=False, post={"download_submit": "Free Download"}) + return url
\ No newline at end of file diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py index 04a58ea68..678884790 100644 --- a/module/web/pyload/views.py +++ b/module/web/pyload/views.py @@ -328,21 +328,20 @@ def config(request): messages.append(_("All options were set correctly.")) accs = settings.PYLOAD.get_accounts() - for plugin,accounts in accs.iteritems(): + for accounts in accs.itervalues(): for data in accounts: if data["trafficleft"] == -1: data["trafficleft"] = _("unlimited") elif not data["trafficleft"]: - data["trafficleft"] = "" + data["trafficleft"] = _("not available") if data["validuntil"] == -1: data["validuntil"] = _("unlimited") elif not data["validuntil"]: - data["validuntil"] = "" + data["validuntil"] = _("not available") else: t = localtime(data["validuntil"]) data["validuntil"] = strftime("%d-%m-%Y",t) - return render_to_response(join(settings.TEMPLATE, 'settings.html'), RequestContext(request, {'conf': {'Plugin':plugin, 'General':conf, 'Accounts': accs}, 'errors': messages}, [status_proc])) diff --git a/module/web/templates/default/settings.html b/module/web/templates/default/settings.html index a4d3ceb25..f23027210 100644 --- a/module/web/templates/default/settings.html +++ b/module/web/templates/default/settings.html @@ -137,19 +137,25 @@ </td> <td> {% trans "Status:" %} + <span style="font-weight: bold;"> {% if account.valid %} {% trans "valid" %} {% else %} {% trans "not valid" %} {% endif %} + </span> |</td> <td> {% trans "Valid until:" %} + <span style="font-weight: bold;"> {{ account.validuntil }} + </span> |</td> <td> {% trans "Traffic left:" %} + <span style="font-weight: bold;"> {{ account.trafficleft }} + </span> |</td> <td> {% trans "Delete? " %} |