diff options
Diffstat (limited to 'module/plugins/accounts/SmoozedCom.py')
-rw-r--r-- | module/plugins/accounts/SmoozedCom.py | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index 1c303331b..9c2451794 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -20,37 +20,38 @@ except ImportError: return b2a_hex(pbkdf2(self.passphrase, self.salt, self.iterations, octets)) from module.common.json_layer import json_loads -from module.plugins.Account import Account +from module.plugins.internal.Account import Account class SmoozedCom(Account): __name__ = "SmoozedCom" __type__ = "account" - __version__ = "0.05" + __version__ = "0.07" + __status__ = "testing" __description__ = """Smoozed.com account plugin""" __license__ = "GPLv3" __authors__ = [("", "")] - def loadAccountInfo(self, user, req): - status = self.getAccountStatus(user, req) + def parse_info(self, user, password, data, req): + status = self.get_account_status(user, password, req) - self.logDebug(status) + self.log_debug(status) if status['state'] != 'ok': info = {'validuntil' : None, 'trafficleft': None, 'premium' : False} else: - # Parse account info - info = {'validuntil' : float(status["data"]["user"]["user_premium"]), - 'trafficleft': max(0, status["data"]["traffic"][1] - status["data"]["traffic"][0]), - 'session' : status["data"]["session_key"], - 'hosters' : [hoster["name"] for hoster in status["data"]["hoster"]]} + #: Parse account info + info = {'validuntil' : float(status['data']['user']['user_premium']), + 'trafficleft': max(0, status['data']['traffic'][1] - status['data']['traffic'][0]), + 'session' : status['data']['session_key'], + 'hosters' : [hoster['name'] for hoster in status['data']['hoster']]} if info['validuntil'] < time.time(): - if float(status["data"]["user"].get("user_trial", 0)) > time.time(): + if float(status['data']['user'].get("user_trial", 0)) > time.time(): info['premium'] = True else: info['premium'] = False @@ -60,19 +61,20 @@ class SmoozedCom(Account): return info - def login(self, user, data, req): - # Get user data from premiumize.me - status = self.getAccountStatus(user, req) + def login(self, user, password, data, req): + #: Get user data from premiumize.me + status = self.get_account_status(user, password, req) - # Check if user and password are valid + #: Check if user and password are valid if status['state'] != 'ok': - self.wrongPassword() + self.login_fail() - def getAccountStatus(self, user, req): - password = self.getAccountData(user)['password'] + def get_account_status(self, user, password, req): + password = password salt = hashlib.sha256(password).hexdigest() encrypted = PBKDF2(password, salt, iterations=1000).hexread(32) - return json_loads(req.load("http://www2.smoozed.com/api/login", - get={'auth': user, 'password': encrypted})) + return json_loads(self.load("http://www2.smoozed.com/api/login", + get={'auth': user, + 'password': encrypted})) |