diff options
-rw-r--r-- | module/RequestFactory.py | 5 | ||||
-rw-r--r-- | module/plugins/accounts/RapidshareCom.py | 24 | ||||
-rw-r--r-- | module/plugins/hoster/RapidshareCom.py | 2 |
3 files changed, 23 insertions, 8 deletions
diff --git a/module/RequestFactory.py b/module/RequestFactory.py index f66dfaf5d..975356254 100644 --- a/module/RequestFactory.py +++ b/module/RequestFactory.py @@ -21,6 +21,7 @@ from threading import Lock from module.network.Request import Request from module.network.XdccRequest import XdccRequest from module.network.FtpRequest import FtpRequest +from time import time import pycurl class RequestFactory(): @@ -81,3 +82,7 @@ class CookieJar(): def getCookie(self, name): return self.parseCookie(name) + + def setCookie(self, domain, name, value, path="/", exp=time()+3600*24*180): + s = ".%s TRUE %s FALSE %s %s %s" % (domain, path, exp, name, value) + self.cookies[name] = s diff --git a/module/plugins/accounts/RapidshareCom.py b/module/plugins/accounts/RapidshareCom.py index f494b17be..016c084c9 100644 --- a/module/plugins/accounts/RapidshareCom.py +++ b/module/plugins/accounts/RapidshareCom.py @@ -36,7 +36,7 @@ class RapidshareCom(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]} + api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", "login": data[0], "password": data[1], "withcookie": 1} src = req.load(api_url_base, cookies=False, get=api_param_prem) if src.startswith("ERROR"): return @@ -47,16 +47,26 @@ class RapidshareCom(Account): continue k, v = t.split("=") info[k] = v - out = {"validuntil":int(info["validuntil"]), "login":str(info["accountid"]), "trafficleft":int(info["premkbleft"]), "type":self.__name__} - 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"]) + out = {"validuntil":None, "login":str(info["accountid"]), "trafficleft":int(info["tskb"]), "type":self.__name__} + return out def login(self): for account in self.accounts: req = self.core.requestFactory.getRequest(self.__name__, account[0]) - html = req.load("https://ssl.rapidshare.com/cgi-bin/premiumzone.cgi", post={"login":account[0], "password":account[1], "uselandingpage":1}, cookies=True) + api_url_base = "http://api.rapidshare.com/cgi-bin/rsapi.cgi" + api_param_prem = {"sub": "getaccountdetails_v1", "type": "prem", "login": account[0], "password": account[1], "withcookie": 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 + cj = self.core.requestFactory.getCookieJar(self.__name__, account[0]) + cj.setCookie("rapidshare.com", "enc", info["cookie"]) diff --git a/module/plugins/hoster/RapidshareCom.py b/module/plugins/hoster/RapidshareCom.py index 63058b044..062923ff6 100644 --- a/module/plugins/hoster/RapidshareCom.py +++ b/module/plugins/hoster/RapidshareCom.py @@ -52,7 +52,7 @@ class RapidshareCom(Hoster): if self.usePremium: info = self.account.getAccountInfo(self.account.getAccountData(self)[0]) - self.logger.info(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1024/1024)) + self.logger.info(_("%s: Use Premium Account (%sGB left)") % (self.__name__, info["trafficleft"]/1000/1000)) if self.api_data["size"] / 1024 > info["trafficleft"]: self.logger.info(_("%s: Not enough traffic left" % self.__name__)) self.usePremium = False |