diff options
Diffstat (limited to 'module/plugins/accounts/SmoozedCom.py')
-rw-r--r-- | module/plugins/accounts/SmoozedCom.py | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index 8157806c8..d192f20cf 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -1,43 +1,48 @@ # -*- coding: utf-8 -*- -from module.plugins.Account import Account - -from module.common.json_layer import json_loads - -from time import time - import hashlib + from beaker.crypto.pbkdf2 import PBKDF2 +from time import time +from module.common.json_layer import json_loads +from module.plugins.Account import Account class SmoozedCom(Account): __name__ = "SmoozedCom" __type__ = "account" - __version__ = "0.01" + __version__ = "0.02" __description__ = """Smoozed.com account plugin""" __license__ = "GPLv3" - __authors__ = [] + __authors__ = [("", "")] def loadAccountInfo(self, user, req): # Get user data from premiumize.me status = self.getAccountStatus(user, req) - self.logDebug(status) - # Parse account info - account_info = {"validuntil": float(status["data"]["user"]["user_premium"]), - "trafficleft": max(0, status["data"]["traffic"][1] - status["data"]["traffic"][0]), - "session_key": status["data"]["session_key"], - "hoster": [hoster["name"] for hoster in status["data"]["hoster"]]} + self.logDebug(status) - if account_info["validuntil"] < time(): - account_info['premium'] = False + if status['state'] != 'ok': + info = {'validuntil' : None, + 'trafficleft': None, + 'premium' : False} else: - account_info['premium'] = True + # Parse account info + info = {'validuntil' : float(status["data"]["user"]["user_premium"]), + 'trafficleft': max(0, status["data"]["traffic"][1] - status["data"]["traffic"][0]), + 'session_key': status["data"]["session_key"], + 'hosters' : [hoster["name"] for hoster in status["data"]["hoster"]]} + + if info['validuntil'] < time(): + info['premium'] = False + else: + info['premium'] = True + + return info - return account_info def login(self, user, data, req): # Get user data from premiumize.me @@ -47,9 +52,11 @@ class SmoozedCom(Account): if status['state'] != 'ok': self.wrongPassword() + def getAccountStatus(self, user, req): - salt = hashlib.sha256(self.accounts[user]['password']).hexdigest() - encrypted = PBKDF2(self.accounts[user]['password'], salt, iterations=1000).hexread(32) - answer = req.load('http://www2.smoozed.com/api/login?auth=%s&password=%s' % ( - user, encrypted)) - return json_loads(answer) + password = self.getAccountData(user)['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})) |