diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-10-04 14:48:16 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-10-04 14:48:16 +0200 |
commit | dbc8882221eaca029994ec6c4483ab157cae9c11 (patch) | |
tree | bd897a4d5ec075536cfdbeec487b1b6286a438e7 /module | |
parent | closed #142 (diff) | |
download | pyload-dbc8882221eaca029994ec6c4483ab157cae9c11.tar.xz |
closed #116
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/Account.py | 25 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 8 | ||||
-rw-r--r-- | module/plugins/hoster/RapidshareCom.py | 3 | ||||
-rw-r--r-- | module/plugins/hoster/UploadedTo.py | 1 |
4 files changed, 27 insertions, 10 deletions
diff --git a/module/plugins/Account.py b/module/plugins/Account.py index 1d625f669..727356ee4 100644 --- a/module/plugins/Account.py +++ b/module/plugins/Account.py @@ -19,6 +19,7 @@ import re from random import choice +from time import time from traceback import print_exc class WrongPassword(Exception): @@ -130,20 +131,28 @@ class Account(): return self.accounts[user] def selectAccount(self): - """ returns an valid and account name""" + """ returns an valid account name and data""" usable = [] for user,data in self.accounts.iteritems(): if not data["valid"]: continue if data["options"].has_key("time"): - time = data["options"]["time"][0] + time_data = data["options"]["time"][0] try: - start, end = time.split("-") + start, end = time_data.split("-") if not self.core.compare_time(start.split(":"), end.split(":")): continue except: self.core.log.error(_("Your Time %s has wrong format, use: 1:22-3:44") % time) + if self.infos.has_key(user): + if self.infos[user].has_key("validuntil"): + if self.infos[user]["validuntil"] > 0 and time() > self.infos[user]["validuntil"]: + continue + if self.infos[user].has_key("trafficleft"): + if self.infos[user]["trafficleft"] == 0: + continue + usable.append((user, data)) @@ -168,3 +177,13 @@ class Account(): def wrongPassword(self): raise WrongPassword + + def empty(self, user): + if self.infos.has_key(user): + self.core.log.warning(_("%(plugin)s Account %(user)s has not enough trafficE") % {"plugin" : self.__name__, "user": user}) + self.infos[user].update({"trafficleft": 0}) + + def expired(self, user): + if self.infos.has_key(user): + self.core.log.warning(_("%(plugin)s Account %(user)s is expired") % {"plugin" : self.__name__, "user": user}) + self.infos[user].update({"validuntil": time() - 1}) diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index e34543100..04df13978 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -136,8 +136,10 @@ class Plugin(object): raise NotImplementedError def resetAccount(self): + """ dont use account and retry download """ self.account = None self.req = self.core.requestFactory.getRequest(self.__name__) + self.retry() def checksum(self, local_file=None): """ @@ -343,9 +345,3 @@ 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/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 8123f5a65..40fe05eeb 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -153,7 +153,8 @@ class RapidshareCom(Hoster): self.log.debug(_("%(name)s: Use Premium Account (%(left)sGB left)") % { "name" : self.__name__, "left": info["trafficleft"]/1000/1000 }) if self.api_data["size"] / 1024 > info["trafficleft"]: self.log.info(_("%s: Not enough traffic left" % self.__name__)) - #self.resetAcount() #@TODO implement + self.account.empty() + self.resetAccount() else: url = self.api_data["mirror"] self.download(url, get={"directstart":1}, cookies=True) diff --git a/module/plugins/hoster/UploadedTo.py b/module/plugins/hoster/UploadedTo.py index 4cd98fc3e..a798a145f 100644 --- a/module/plugins/hoster/UploadedTo.py +++ b/module/plugins/hoster/UploadedTo.py @@ -56,6 +56,7 @@ class UploadedTo(Hoster): 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.account.empty() self.resetAccount() self.fail(_("Traffic exceeded")) else: |