summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts/ShareonlineBiz.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/accounts/ShareonlineBiz.py')
-rw-r--r--module/plugins/accounts/ShareonlineBiz.py66
1 files changed, 42 insertions, 24 deletions
diff --git a/module/plugins/accounts/ShareonlineBiz.py b/module/plugins/accounts/ShareonlineBiz.py
index cdc4ebb63..4dd398d6d 100644
--- a/module/plugins/accounts/ShareonlineBiz.py
+++ b/module/plugins/accounts/ShareonlineBiz.py
@@ -23,35 +23,53 @@ import re
class ShareonlineBiz(Account):
__name__ = "ShareonlineBiz"
- __version__ = "0.23"
+ __version__ = "0.3"
__type__ = "account"
__description__ = """share-online.biz account plugin"""
- __author_name__ = ("mkaay", "zoidberg")
- __author_mail__ = ("mkaay@mkaay.de", "zoidberg@mujmail.cz")
+ __author_name__ = ("mkaay")
+ __author_mail__ = ("mkaay@mkaay.de")
- def getUserAPI(self, user, req):
- return req.load("http://api.share-online.biz/account.php?username=%s&password=%s&act=userDetails" % (user, self.accounts[user]["password"]))
-
- def loadAccountInfo(self, user, req):
- src = self.getUserAPI(user, req)
-
+ def getUserAPI(self, req):
+ src = req.load("http://api.share-online.biz/account.php?username=%s&password=%s&act=userDetails" % (self.loginname, self.password))
info = {}
for line in src.splitlines():
- if "=" in line:
- key, value = line.split("=")
- info[key] = value
- self.logDebug(info)
+ key, value = line.split("=")
+ info[key] = value
+ return info
+
+ def loadAccountInfo(self, user, req):
+ try:
+ info = self.getUserAPI(req)
+ return {"validuntil": int(info["expire_date"]), "trafficleft": -1, "premium": not info["group"] == "Sammler"}
+ except:
+ pass
+
+ #fallback
+ src = req.load("http://www.share-online.biz/members.php?setlang=en")
+ validuntil = re.search(r'<td align="left"><b>Package Expire Date:</b></td>\s*<td align="left">(\d+/\d+/\d+)</td>', src)
+ if validuntil:
+ validuntil = int(mktime(strptime(validuntil.group(1), "%m/%d/%y")))
+ else:
+ validuntil = -1
- if "dl" in info and info["dl"].lower() != "not_available":
- req.cj.setCookie("share-online.biz", "dl", info["dl"])
- if "a" in info and info["a"].lower() != "not_available":
- req.cj.setCookie("share-online.biz", "a", info["a"])
-
- return {"validuntil": int(info["expire_date"]) if "expire_date" in info else -1,
- "trafficleft": -1,
- "premium": True if ("dl" in info or "a" in info) and (info["group"] != "Sammler") else False}
+ acctype = re.search(r'<td align="left" ><b>Your Package:</b></td>\s*<td align="left">\s*<b>(.*?)</b>\s*</td>', src)
+ if acctype:
+ if acctype.group(1) == "Collector account (free)":
+ premium = False
+ else:
+ premium = True
+
+ tmp = {"validuntil": validuntil, "trafficleft": -1, "premium": premium}
+ return tmp
def login(self, user, data, req):
- src = self.getUserAPI(user, req)
- if "EXCEPTION" in src:
- self.wrongPassword() \ No newline at end of file
+ post_vars = {
+ "act": "login",
+ "location": "index.php",
+ "dieseid": "",
+ "user": user,
+ "pass": data["password"],
+ "login": "Login"
+ }
+ req.lastURL = "http://www.share-online.biz/"
+ req.load("https://www.share-online.biz/login.php", cookies=True, post=post_vars)