diff options
Diffstat (limited to 'module/plugins/accounts/ZeveraCom.py')
-rw-r--r-- | module/plugins/accounts/ZeveraCom.py | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/module/plugins/accounts/ZeveraCom.py b/module/plugins/accounts/ZeveraCom.py index e8e3431e3..d679f5aad 100644 --- a/module/plugins/accounts/ZeveraCom.py +++ b/module/plugins/accounts/ZeveraCom.py @@ -8,43 +8,52 @@ from module.plugins.Account import Account class ZeveraCom(Account): __name__ = "ZeveraCom" __type__ = "account" - __version__ = "0.22" + __version__ = "0.23" __description__ = """Zevera.com account plugin""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] + + + API_URL = "http://api.zevera.com/jDownloader.ashx" def loadAccountInfo(self, user, req): - data = self.getAPIData(req) - if data == "No traffic": - account_info = {"trafficleft": 0, "validuntil": 0, "premium": False} - else: - account_info = { - "trafficleft": float(data['availabletodaytraffic']) * 1024, - "validuntil": mktime(strptime(data['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")), - "premium": True - } - return account_info + validuntil = None + trafficleft = None + premium = False + + api = self.api_response(req) + + if api != "No trafic": + validuntil = mktime(strptime(api['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")) + trafficleft = float(api['availabletodaytraffic']) * 1024 if api['orondaytrafficlimit'] != '0' else -1 + premium = True + + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} def login(self, user, data, req): - self.loginname = user + self.user = user self.password = data['password'] - if self.getAPIData(req) == "No traffic": + + if self.api_response(req) == "No trafic": self.wrongPassword() - def getAPIData(self, req, just_header=False, **kwargs): - get_data = { - 'cmd': 'accountinfo', - 'login': self.loginname, - 'pass': self.password - } + def api_response(self, req, just_header=False, **kwargs): + get_data = {'cmd' : "accountinfo", + 'login': self.user, + 'pass' : self.password} + get_data.update(kwargs) - res = req.load("http://www.zevera.com/jDownloader.ashx", get=get_data, - decode=True, just_header=just_header) + res = req.load(self.API_URL, + get=get_data, + just_header=just_header, + decode=True) + self.logDebug(res) if ':' in res: |