diff options
Diffstat (limited to 'module/plugins/accounts/RapidgatorNet.py')
-rw-r--r-- | module/plugins/accounts/RapidgatorNet.py | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/module/plugins/accounts/RapidgatorNet.py b/module/plugins/accounts/RapidgatorNet.py index 693b78547..7643f07d2 100644 --- a/module/plugins/accounts/RapidgatorNet.py +++ b/module/plugins/accounts/RapidgatorNet.py @@ -7,51 +7,65 @@ from pyload.utils import json_loads class RapidgatorNet(Account): __name__ = "RapidgatorNet" __type__ = "account" - __version__ = "0.04" + __version__ = "0.09" __description__ = """Rapidgator.net account plugin""" __license__ = "GPLv3" __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] - API_URL = 'http://rapidgator.net/api/user' + API_URL = "http://rapidgator.net/api/user" def loadAccountInfo(self, user, req): + validuntil = None + trafficleft = None + premium = False + sid = None + try: - sid = self.getAccountData(user).get('SID') + sid = self.getAccountData(user).get('sid') assert sid - json = req.load("%s/info?sid=%s" % (self.API_URL, sid)) - self.logDebug("API:USERINFO", json) - json = json_loads(json) + html = req.load("%s/info" % self.API_URL, get={'sid': sid}) + + self.logDebug("API:USERINFO", html) + + json = json_loads(html) if json['response_status'] == 200: if "reset_in" in json['response']: self.scheduleRefresh(user, json['response']['reset_in']) - return {"validuntil": json['response']['expire_date'], - "trafficleft": int(json['response']['traffic_left']), - "premium": True} + validuntil = json['response']['expire_date'] + trafficleft = float(json['response']['traffic_left']) / 1024 #@TODO: Remove `/ 1024` in 0.4.10 + premium = True else: self.logError(json['response_details']) + except Exception, e: self.logError(e) - return {"validuntil": None, "trafficleft": None, "premium": False} + return {'validuntil' : validuntil, + 'trafficleft': trafficleft, + 'premium' : premium, + 'sid' : sid} def login(self, user, data, req): try: - json = req.load('%s/login' % self.API_URL, post={"username": user, "password": data['password']}) - self.logDebug("API:LOGIN", json) - json = json_loads(json) + html = req.load('%s/login' % self.API_URL, post={"username": user, "password": data['password']}) + + self.logDebug("API:LOGIN", html) + + json = json_loads(html) if json['response_status'] == 200: - data['SID'] = str(json['response']['session_id']) + data['sid'] = str(json['response']['session_id']) return else: self.logError(json['response_details']) + except Exception, e: self.logError(e) |