diff options
Diffstat (limited to 'module/plugins/accounts/ShareonlineBiz.py')
-rw-r--r-- | module/plugins/accounts/ShareonlineBiz.py | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/module/plugins/accounts/ShareonlineBiz.py b/module/plugins/accounts/ShareonlineBiz.py index 4214b4401..87bbc4632 100644 --- a/module/plugins/accounts/ShareonlineBiz.py +++ b/module/plugins/accounts/ShareonlineBiz.py @@ -2,54 +2,58 @@ import re -from module.plugins.Account import Account +from module.plugins.internal.Account import Account +from module.plugins.internal.Plugin import set_cookie class ShareonlineBiz(Account): __name__ = "ShareonlineBiz" __type__ = "account" - __version__ = "0.33" + __version__ = "0.39" + __status__ = "testing" __description__ = """Share-online.biz account plugin""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - def api_response(self, user, req): - return req.load("http://api.share-online.biz/cgi-bin", + def api_response(self, user, password, req): + res = self.load("https://api.share-online.biz/cgi-bin", get={'q' : "userdetails", 'aux' : "traffic", 'username': user, - 'password': self.getAccountData(user)['password']}) + 'password': password}, + decode=False) + self.log_debug(res) - def loadAccountInfo(self, user, req): - premium = False - validuntil = None - trafficleft = -1 - maxtraffic = 100 * 1024 * 1024 * 1024 #: 100 GB + api = dict(line.split("=") for line in res.splitlines() if "=" in line) + + if not 'a' in api: + self.login_fail(res.strip('*').strip()) - api = {} - for line in self.api_response(user, req).splitlines(): - if "=" in line: - key, value = line.split("=") - api[key] = value + if api['a'].lower() == "not_available": + self.login_fail(_("No info available")) - self.logDebug(api) + return api - if api['a'].lower() != "not_available": - req.cj.setCookie("share-online.biz", 'a', api['a']) - premium = api['group'] in ("PrePaid", "Premium", "Penalty-Premium") + def parse_info(self, user, password, data, req): + premium = False + validuntil = None + trafficleft = -1 + maxtraffic = 100 * 1024 * 1024 * 1024 #: 100 GB - validuntil = float(api['expire_date']) + api = self.api_response(user, password, req) - traffic = float(api['traffic_1d'].split(";")[0]) + premium = api['group'] in ("PrePaid", "Premium", "Penalty-Premium") + validuntil = float(api['expire_date']) + traffic = float(api['traffic_1d'].split(";")[0]) - if maxtraffic > traffic: - trafficleft = maxtraffic - traffic - else: - trafficleft = -1 + if maxtraffic > traffic: + trafficleft = maxtraffic - traffic + else: + trafficleft = -1 maxtraffic /= 1024 #@TODO: Remove `/ 1024` in 0.4.10 trafficleft /= 1024 #@TODO: Remove `/ 1024` in 0.4.10 @@ -60,9 +64,6 @@ class ShareonlineBiz(Account): 'maxtraffic' : maxtraffic} - def login(self, user, data, req): - html = self.api_response(user, req) - err = re.search(r'\*\*(.+?)\*\*', html) - if err: - self.logError(err.group(1)) - self.wrongPassword() + def login(self, user, password, data, req): + api = self.api_response(user, password, req) + set_cookie(req.cj, "share-online.biz", 'a', api['a']) |