From 36b5bfedc2e57bd000831559ca8fb4d7e7899e24 Mon Sep 17 00:00:00 2001 From: tjeh Date: Sun, 20 Jul 2014 21:49:27 +0200 Subject: Added support for Multihosters.com multihoster. --- module/plugins/accounts/MultihostersCom.py | 50 ++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 module/plugins/accounts/MultihostersCom.py (limited to 'module/plugins/accounts/MultihostersCom.py') diff --git a/module/plugins/accounts/MultihostersCom.py b/module/plugins/accounts/MultihostersCom.py new file mode 100644 index 000000000..3f96fdf41 --- /dev/null +++ b/module/plugins/accounts/MultihostersCom.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- + +from time import mktime, strptime +from module.plugins.Account import Account + +class MultihostersCom(Account): + __name__ = "MultihostersCom" + __version__ = "0.01" + __type__ = "account" + __description__ = """Multihosters.com account plugin""" + __author_name__ = "tjeh" + __author_mail__ = "tjeh@gmx.net" + + 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": int(data['availabletodaytraffic']) * 1024, + "validuntil": mktime(strptime(data['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")), + "premium": True + } + return account_info + + def login(self, user, data, req): + self.loginname = user + self.password = data['password'] + if self.getAPIData(req) == "No traffic": + self.wrongPassword() + + def getAPIData(self, req, just_header=False, **kwargs): + get_data = { + 'cmd': 'accountinfo', + 'login': self.loginname, + 'pass': self.password + } + get_data.update(kwargs) + + response = req.load("http://www.multihosters.com/jDownloader.ashx", get=get_data, + decode=True, just_header=just_header) + self.logDebug(response) + + if ':' in response: + if not just_header: + response = response.replace(',', '\n') + return dict((y.strip().lower(), z.strip()) for (y, z) in + [x.split(':', 1) for x in response.splitlines() if ':' in x]) + else: + return response -- 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/MultihostersCom.py | 52 ++++++------------------------ 1 file changed, 9 insertions(+), 43 deletions(-) (limited to 'module/plugins/accounts/MultihostersCom.py') diff --git a/module/plugins/accounts/MultihostersCom.py b/module/plugins/accounts/MultihostersCom.py index 3f96fdf41..0be64af7f 100644 --- a/module/plugins/accounts/MultihostersCom.py +++ b/module/plugins/accounts/MultihostersCom.py @@ -1,50 +1,16 @@ # -*- coding: utf-8 -*- -from time import mktime, strptime -from module.plugins.Account import Account +from module.plugins.accounts.ZeveraCom import ZeveraCom -class MultihostersCom(Account): - __name__ = "MultihostersCom" - __version__ = "0.01" - __type__ = "account" - __description__ = """Multihosters.com account plugin""" - __author_name__ = "tjeh" - __author_mail__ = "tjeh@gmx.net" - - 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": int(data['availabletodaytraffic']) * 1024, - "validuntil": mktime(strptime(data['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")), - "premium": True - } - return account_info - def login(self, user, data, req): - self.loginname = user - self.password = data['password'] - if self.getAPIData(req) == "No traffic": - self.wrongPassword() +class MultihostersCom(ZeveraCom): + __name__ = "MultihostersCom" + __type__ = "account" + __version__ = "0.02" - def getAPIData(self, req, just_header=False, **kwargs): - get_data = { - 'cmd': 'accountinfo', - 'login': self.loginname, - 'pass': self.password - } - get_data.update(kwargs) + __description__ = """Multihosters.com account plugin""" + __license__ = "GPLv3" + __authors__ = [("tjeh", "tjeh@gmx.net")] - response = req.load("http://www.multihosters.com/jDownloader.ashx", get=get_data, - decode=True, just_header=just_header) - self.logDebug(response) - if ':' in response: - if not just_header: - response = response.replace(',', '\n') - return dict((y.strip().lower(), z.strip()) for (y, z) in - [x.split(':', 1) for x in response.splitlines() if ':' in x]) - else: - return response + API_URL = "http://api.multihosters.com/jDownloader.ashx" -- cgit v1.2.3 From e17f58459d8d4e57ed447823a988768bf09f2703 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 10 Jan 2015 19:49:37 +0100 Subject: [ZeveraCom] Improve --- module/plugins/accounts/MultihostersCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/accounts/MultihostersCom.py') diff --git a/module/plugins/accounts/MultihostersCom.py b/module/plugins/accounts/MultihostersCom.py index 0be64af7f..e98f17b2d 100644 --- a/module/plugins/accounts/MultihostersCom.py +++ b/module/plugins/accounts/MultihostersCom.py @@ -6,11 +6,11 @@ from module.plugins.accounts.ZeveraCom import ZeveraCom class MultihostersCom(ZeveraCom): __name__ = "MultihostersCom" __type__ = "account" - __version__ = "0.02" + __version__ = "0.03" __description__ = """Multihosters.com account plugin""" __license__ = "GPLv3" __authors__ = [("tjeh", "tjeh@gmx.net")] - API_URL = "http://api.multihosters.com/jDownloader.ashx" + HOSTER_DOMAIN = "multihosters.com" -- cgit v1.2.3