From 75b6540be746d66d3fba3ab364c78addbc50c485 Mon Sep 17 00:00:00 2001 From: Smoozed Date: Mon, 5 Jan 2015 16:49:39 +0100 Subject: Added multihoster smoozed.com --- module/plugins/accounts/SmoozedCom.py | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 module/plugins/accounts/SmoozedCom.py (limited to 'module/plugins/accounts/SmoozedCom.py') diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py new file mode 100644 index 000000000..8157806c8 --- /dev/null +++ b/module/plugins/accounts/SmoozedCom.py @@ -0,0 +1,55 @@ +# -*- 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 + + + +class SmoozedCom(Account): + __name__ = "SmoozedCom" + __type__ = "account" + __version__ = "0.01" + + __description__ = """Smoozed.com account plugin""" + __license__ = "GPLv3" + __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"]]} + + if account_info["validuntil"] < time(): + account_info['premium'] = False + else: + account_info['premium'] = True + + return account_info + + def login(self, user, data, req): + # Get user data from premiumize.me + status = self.getAccountStatus(user, req) + + # Check if user and password are valid + 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) -- cgit v1.2.3 From 36e60a23497ae05736c24fed2f4ce936fb61f744 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 8 Jan 2015 23:31:33 +0100 Subject: "New Year" Update: account plugins --- module/plugins/accounts/SmoozedCom.py | 53 ++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 23 deletions(-) (limited to 'module/plugins/accounts/SmoozedCom.py') 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})) -- cgit v1.2.3 From 187586c77f750340c2d8c84781c82a3e612f17c3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 11 Jan 2015 20:20:43 +0100 Subject: Fix getAccount in some plugins --- module/plugins/accounts/SmoozedCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/accounts/SmoozedCom.py') diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index d192f20cf..e6c25752b 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -12,7 +12,7 @@ from module.plugins.Account import Account class SmoozedCom(Account): __name__ = "SmoozedCom" __type__ = "account" - __version__ = "0.02" + __version__ = "0.03" __description__ = """Smoozed.com account plugin""" __license__ = "GPLv3" @@ -33,7 +33,7 @@ class SmoozedCom(Account): # 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"], + 'session' : status["data"]["session_key"], 'hosters' : [hoster["name"] for hoster in status["data"]["hoster"]]} if info['validuntil'] < time(): -- cgit v1.2.3 From e65d19ee3a1e435bf2896ed829e5581eeef92dd2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 14 Mar 2015 11:07:54 +0100 Subject: Import cleanup for datetime and time modules --- module/plugins/accounts/SmoozedCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/accounts/SmoozedCom.py') diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index e6c25752b..87efb89b3 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- import hashlib +import time from beaker.crypto.pbkdf2 import PBKDF2 -from time import time from module.common.json_layer import json_loads from module.plugins.Account import Account @@ -36,7 +36,7 @@ class SmoozedCom(Account): 'session' : status["data"]["session_key"], 'hosters' : [hoster["name"] for hoster in status["data"]["hoster"]]} - if info['validuntil'] < time(): + if info['validuntil'] < time.time(): info['premium'] = False else: info['premium'] = True -- cgit v1.2.3 From 71c997e75ee6b8d7ae638dd8612d7b805e4eb523 Mon Sep 17 00:00:00 2001 From: Armin Date: Fri, 10 Apr 2015 17:57:40 +0200 Subject: Fix OboomCom and SmoozedCom with beaker >= v1.7.x --- module/plugins/accounts/SmoozedCom.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'module/plugins/accounts/SmoozedCom.py') diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index 87efb89b3..3c8226704 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -3,7 +3,20 @@ import hashlib import time -from beaker.crypto.pbkdf2 import PBKDF2 +try: + from beaker.crypto.pbkdf2 import PBKDF2 + +except ImportError: + from beaker.crypto.pbkdf2 import pbkdf2 + from binascii import b2a_hex + class PBKDF2(object): + def __init__(self, passphrase, salt, iterations=1000): + self.passphrase = passphrase + self.salt = salt + self.iterations = iterations + + def hexread(self, octets): + 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 @@ -12,7 +25,7 @@ from module.plugins.Account import Account class SmoozedCom(Account): __name__ = "SmoozedCom" __type__ = "account" - __version__ = "0.03" + __version__ = "0.04" __description__ = """Smoozed.com account plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 1ef93e913238275f7657d496ba3d2e7eeb5a30a2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 1 May 2015 01:06:01 +0200 Subject: Use 'import' instead 'from' --- module/plugins/accounts/SmoozedCom.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/accounts/SmoozedCom.py') diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index 3c8226704..56cd1864a 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -9,6 +9,7 @@ try: except ImportError: from beaker.crypto.pbkdf2 import pbkdf2 from binascii import b2a_hex + class PBKDF2(object): def __init__(self, passphrase, salt, iterations=1000): self.passphrase = passphrase -- cgit v1.2.3 From 87164856d5d190c830609e296f47fde6820d023b Mon Sep 17 00:00:00 2001 From: smoozed Date: Mon, 11 May 2015 17:43:10 +0200 Subject: Fixed #1399 When the account is not premium, check if there is trial time left. --- module/plugins/accounts/SmoozedCom.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'module/plugins/accounts/SmoozedCom.py') diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index 56cd1864a..8fb997b54 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -34,7 +34,6 @@ class SmoozedCom(Account): def loadAccountInfo(self, user, req): - # Get user data from premiumize.me status = self.getAccountStatus(user, req) self.logDebug(status) @@ -51,7 +50,10 @@ class SmoozedCom(Account): 'hosters' : [hoster["name"] for hoster in status["data"]["hoster"]]} if info['validuntil'] < time.time(): - info['premium'] = False + if float(status["data"]["user"].get("user_trial", 0)) > time.time(): + info['premium'] = True + else: + info['premium'] = False else: info['premium'] = True -- cgit v1.2.3 From 6faf688fdd1657826d0db99fd9ff4f9c94582721 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 11 May 2015 20:10:40 +0200 Subject: [ShareonlineBiz][SmoozedCom] Version up --- module/plugins/accounts/SmoozedCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/accounts/SmoozedCom.py') diff --git a/module/plugins/accounts/SmoozedCom.py b/module/plugins/accounts/SmoozedCom.py index 8fb997b54..1c303331b 100644 --- a/module/plugins/accounts/SmoozedCom.py +++ b/module/plugins/accounts/SmoozedCom.py @@ -26,7 +26,7 @@ from module.plugins.Account import Account class SmoozedCom(Account): __name__ = "SmoozedCom" __type__ = "account" - __version__ = "0.04" + __version__ = "0.05" __description__ = """Smoozed.com account plugin""" __license__ = "GPLv3" -- cgit v1.2.3