diff options
-rw-r--r-- | module/plugins/Account.py | 7 | ||||
-rw-r--r-- | module/plugins/accounts/RapidshareCom.py | 28 | ||||
-rw-r--r-- | module/plugins/hoster/RapidshareCom.py | 43 |
3 files changed, 47 insertions, 31 deletions
diff --git a/module/plugins/Account.py b/module/plugins/Account.py index 3588cd51e..ab3ad9ec5 100644 --- a/module/plugins/Account.py +++ b/module/plugins/Account.py @@ -39,6 +39,13 @@ class Account(): def login(self): pass + def getAccountInfo(self, name): + return { + "validuntil": None, + "login": None, + "trafficleft": None + } + def getAccountRequest(self, plugin): account = self.getAccountData(plugin) req = self.core.requestFactory.getRequest(self.__name__, account[0]) diff --git a/module/plugins/accounts/RapidshareCom.py b/module/plugins/accounts/RapidshareCom.py index f18fadd15..c9113afd7 100644 --- a/module/plugins/accounts/RapidshareCom.py +++ b/module/plugins/accounts/RapidshareCom.py @@ -27,8 +27,32 @@ class RapidshareCom(Account): __author_name__ = ("mkaay") __author_mail__ = ("mkaay@mkaay.de") - def getAccountInfo(self): - pass + def getAccountInfo(self, name): + req = self.core.requestFactory.getRequest(self.__name__, name) + data = None + for account in self.accounts: + if account[0] == name: + data = account + if not data: + return + api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" + api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", "login": data[0], "password": data[1]} + src = req.load(api_url_base, cookies=False, get=api_param_prem) + if src.startswith("ERROR"): + return + fields = src.split("\n") + info = {} + for t in fields: + if not t.strip(): + continue + k, v = t.split("=") + info[k] = v + out = {"validuntil":int(info["validuntil"]), "login":str(info["accountid"]), "trafficleft":int(info["premkbleft"])} + if int(info["plustrafficmode"]) == 1 or int(info["plustrafficmode"]) == 3: + out["trafficleft"] += int(info["bodkb"]) + if int(info["plustrafficmode"]) == 2 or int(info["plustrafficmode"]) == 3: + out["trafficleft"] += 15*1024*int(info["ppoints"]) + return out def login(self): for account in self.accounts: diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 6f7283d2f..c1f691af8 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -26,11 +26,11 @@ class RapidshareCom(Hoster): self.no_slots = True self.api_data = None self.url = self.parent.url - self.props = {} self.read_config() self.account = None self.multi_dl = False - if self.config['premium']: + self.usePremium = self.config['premium'] + if self.usePremium: self.account = self.parent.core.pluginManager.getAccountPlugin(self.__name__) req = self.account.getAccountRequest(self) if req: @@ -38,7 +38,7 @@ class RapidshareCom(Hoster): self.multi_dl = True self.req.canContinue = True else: - self.config['premium'] = False + self.usePremium = False self.start_dl = False @@ -51,10 +51,15 @@ class RapidshareCom(Hoster): if self.api_data["status"] == "1": self.pyfile.status.filename = self.get_file_name() - if self.config["premium"]: - self.logger.info(_("Rapidshare: Use Premium Account (%sGB left)") % (self.props["premkbleft"]/1000000)) - self.pyfile.status.url = self.parent.url - return True + if self.usePremium: + info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) + self.logger.info(_("Rapidshare: Use Premium Account (%sGB left)") % (info["trafficleft"]/1024/1024)) + if self.api_data["size"] / 1024 > info["trafficleft"]: + self.logger.info(_("Rapidshare: Not enough traffic left")) + self.usePremium = False + else: + self.pyfile.status.url = self.parent.url + return True self.download_html() while self.no_slots: @@ -91,7 +96,7 @@ class RapidshareCom(Hoster): self.api_data = {} self.api_data["fileid"] = fields[0] self.api_data["filename"] = fields[1] - self.api_data["size"] = fields[2] # in bytes + self.api_data["size"] = int(fields[2]) # in bytes self.api_data["serverid"] = fields[3] self.api_data["status"] = fields[4] """ @@ -109,23 +114,6 @@ class RapidshareCom(Hoster): self.api_data["mirror"] = "http://rs%(serverid)s%(shorthost)s.rapidshare.com/files/%(fileid)s/%(filename)s" % self.api_data - if self.config["premium"]: - api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", \ - "login": self.config['username'], "password": self.config['password']} - src = self.load(api_url_base, cookies=False, get=api_param_prem) - if src.startswith("ERROR"): - self.config["premium"] = False - self.logger.info("Rapidshare: Login failed") - return - fields = src.split("\n") - premkbleft = int(fields[18].split("=")[1]) - if premkbleft < int(self.api_data["size"][0:-3]): - self.logger.info(_("Rapidshare: Not enough traffic left")) - #self.config["premium"] = False - self.props["premkbleft"] = 0 - else: - self.props["premkbleft"] = premkbleft - def download_html(self): """ gets the url from self.parent.url saves html in self.html and parses """ @@ -178,10 +166,7 @@ class RapidshareCom(Hoster): return self.url.split("/")[-1] def proceed(self, url, location): - if self.config['premium']: - data = self.account.getAccountData(self) - self.req.add_auth(data[0], data[1]) - self.download(url, location, cookies=True) + self.download(url, location, get={"directstart":1}, cookies=True) def check_file(self, local_file): if self.api_data and self.api_data["checksum"]: |