diff options
Diffstat (limited to 'module/plugins/accounts/NoPremiumPl.py')
-rw-r--r-- | module/plugins/accounts/NoPremiumPl.py | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/module/plugins/accounts/NoPremiumPl.py b/module/plugins/accounts/NoPremiumPl.py index f2223b7d9..4944ad4df 100644 --- a/module/plugins/accounts/NoPremiumPl.py +++ b/module/plugins/accounts/NoPremiumPl.py @@ -1,41 +1,41 @@ # -*- coding: utf-8 -*- -from datetime import datetime +import datetime import hashlib +import time -from module.plugins.Account import Account -from time import mktime -from module.common.json_layer import json_loads as loads +from module.common.json_layer import json_loads +from module.plugins.internal.Account import Account class NoPremiumPl(Account): - __name__ = "NoPremiumPl" - __version__ = "0.01" - __type__ = "account" + __name__ = "NoPremiumPl" + __type__ = "account" + __version__ = "0.02" + __description__ = "NoPremium.pl account plugin" - __license__ = "GPLv3" - __authors__ = [("goddie", "dev@nopremium.pl")] + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@nopremium.pl")] - _api_url = "http://crypt.nopremium.pl" - _api_query = { - "site": "nopremium", - "username": "", - "password": "", - "output": "json", - "loc": "1", - "info": "1" - } + API_URL = "http://crypt.nopremium.pl" + API_QUERY = {'site' : "nopremium", + 'username': "" , + 'password': "" , + 'output' : "json" , + 'loc' : "1" , + 'info' : "1" } _req = None _usr = None _pwd = None + def loadAccountInfo(self, name, req): self._req = req try: - result = loads(self.runAuthQuery()) - except: + result = json_loads(self.runAuthQuery()) + except Exception: # todo: return or let it be thrown? return @@ -44,14 +44,14 @@ class NoPremiumPl(Account): if "expire" in result.keys() and result["expire"]: premium = True - valid_untill = mktime(datetime.fromtimestamp(int(result["expire"])).timetuple()) + valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result["expire"])).timetuple()) + traffic_left = result["balance"] * 1024 - return ({ - "validuntil": valid_untill, - "trafficleft": traffic_left, - "premium": premium - }) + return {'validuntil' : valid_untill, + 'trafficleft': traffic_left, + 'premium' : premium } + def login(self, user, data, req): self._usr = user @@ -59,23 +59,23 @@ class NoPremiumPl(Account): self._req = req try: - response = loads(self.runAuthQuery()) - except: + response = json_loads(self.runAuthQuery()) + except Exception: self.wrongPassword() if "errno" in response.keys(): self.wrongPassword() + data['usr'] = self._usr data['pwd'] = self._pwd + def createAuthQuery(self): - query = self._api_query + query = self.API_QUERY query["username"] = self._usr query["password"] = self._pwd - return query - def runAuthQuery(self): - data = self._req.load(self._api_url, post=self.createAuthQuery()) - return data
\ No newline at end of file + def runAuthQuery(self): + return self._req.load(self.API_URL, post=self.createAuthQuery()) |