summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-07-31 03:18:42 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-07-31 03:18:42 +0200
commit1b890dd55ff49ca7d6282f6e92f2fb483fb07eea (patch)
treedcc305224d358fc6b3598c1fc562c5775a976d5b /module/plugins
parent[Addon] Fix unload method not called on exit (diff)
downloadpyload-1b890dd55ff49ca7d6282f6e92f2fb483fb07eea.tar.xz
[ShareonlineBiz] Improve account
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/accounts/ShareonlineBiz.py63
1 files changed, 35 insertions, 28 deletions
diff --git a/module/plugins/accounts/ShareonlineBiz.py b/module/plugins/accounts/ShareonlineBiz.py
index 1945b2743..d7a3c8ed2 100644
--- a/module/plugins/accounts/ShareonlineBiz.py
+++ b/module/plugins/accounts/ShareonlineBiz.py
@@ -8,7 +8,7 @@ from module.plugins.internal.Account import Account
class ShareonlineBiz(Account):
__name__ = "ShareonlineBiz"
__type__ = "account"
- __version__ = "0.35"
+ __version__ = "0.36"
__status__ = "testing"
__description__ = """Share-online.biz account plugin"""
@@ -17,40 +17,45 @@ class ShareonlineBiz(Account):
def api_response(self, user, password, req):
- return self.load("http://api.share-online.biz/cgi-bin",
- get={'q' : "userdetails",
- 'aux' : "traffic",
- 'username': user,
- 'password': password})
+ res = self.load("http://api.share-online.biz/cgi-bin",
+ get={'q' : "userdetails",
+ 'aux' : "traffic",
+ 'username': user,
+ 'password': password})
-
- def parse_info(self, user, password, data, req):
- premium = False
- validuntil = None
- trafficleft = -1
- maxtraffic = 100 * 1024 * 1024 * 1024 #: 100 GB
+ self.log_debug(res)
api = {}
- for line in self.api_response(user, password, req).splitlines():
+ for line in res.splitlines():
if "=" in line:
key, value = line.split("=")
api[key] = value
- self.log_debug(api)
+ if not api['a']:
+ self.login_fail(_("Invalid username/password"))
- if api['a'].lower() != "not_available":
- req.cj.setCookie("share-online.biz", 'a', api['a'])
+ if api['a'].lower() == "not_available":
+ self.login_fail(_("No info available"))
+
+ return api
- premium = api['group'] in ("PrePaid", "Premium", "Penalty-Premium")
- validuntil = float(api['expire_date'])
+ def parse_info(self, user, password, data, req):
+ premium = False
+ validuntil = None
+ trafficleft = -1
+ maxtraffic = 100 * 1024 * 1024 * 1024 #: 100 GB
+
+ 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
@@ -62,8 +67,10 @@ class ShareonlineBiz(Account):
def login(self, user, password, data, req):
- html = self.api_response(user, password, req)
- err = re.search(r'\*\*(.+?)\*\*', html)
- if err:
- self.log_error(err.group(1).strip())
- self.login_fail()
+ api = self.api_response(user, password, req)
+ err = re.search(r'\*\*(.+?)\*\*', api)
+
+ if not err:
+ req.cj.setCookie("share-online.biz", 'a', api['a'])
+ else:
+ self.login_fail(err.group(1))