summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts
diff options
context:
space:
mode:
authorGravatar Paul King <devnull@localhost> 2011-05-07 01:44:17 +0200
committerGravatar Paul King <devnull@localhost> 2011-05-07 01:44:17 +0200
commit64c2f6e7d91cc6502fe31ffe8c3bd032f6e415c1 (patch)
treee07192db175146f7b20817370fd11271b98bad02 /module/plugins/accounts
parentFilesonicCom API fix, New hoster FilefactoryCom (diff)
downloadpyload-64c2f6e7d91cc6502fe31ffe8c3bd032f6e415c1.tar.xz
Fix 294 - refactor plugin
Diffstat (limited to 'module/plugins/accounts')
-rw-r--r--module/plugins/accounts/FilesonicCom.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/module/plugins/accounts/FilesonicCom.py b/module/plugins/accounts/FilesonicCom.py
index 08f6ab4d2..08d6a48cf 100644
--- a/module/plugins/accounts/FilesonicCom.py
+++ b/module/plugins/accounts/FilesonicCom.py
@@ -29,22 +29,36 @@ class FilesonicCom(Account):
__description__ = """filesonic.com account plugin"""
__author_name__ = ("RaNaN")
__author_mail__ = ("RaNaN@pyload.org")
+
+ def getDomain(self, req):
+ xml = req.load("http://api.filesonic.com/utility?method=getFilesonicDomainForCurrentIp&format=xml").decode("utf8")
+ return re.search(r"response>.*?(filesonic\..*?)</resp", xml).group(1)
def loadAccountInfo(self, user, req):
- src = req.load("http://www.filesonic.com/user/settings").decode("utf8")
-
- validuntil = re.search(r'\d+-\d+-\d+ \d+:\d+:\d+', src).group(0)
- validuntil = int(mktime(strptime(validuntil, "%Y-%m-%d %H:%M:%S")))
- tmp = {"validuntil": validuntil, "trafficleft": -1}
- return tmp
+ xml = req.load("http://api.filesonic.com/user?method=getInfo&format=xml",
+ post = {"u": user,
+ "p" : self.accounts[user]["password"]}
+ ).decode("utf8")
+ if re.search(r'<status>failed', xml):
+ self.core.log.error(_("%s: Invalid login retrieving user details" % self.__name__))
+ self.wrongPassword()
+ premium = bool(int(re.search(r'<is_premium>(\d+)',xml).group(1)))
+ if premium:
+ validuntil = re.search(r'<premium_expiration>\d+-\d+-\d+ \d+:\d+:\d+</', xml).group(1)
+ validuntil = int(mktime(strptime(validuntil, "%Y-%m-%d %H:%M:%S")))
+ else:
+ validuntil = -1
+ return {"validuntil": validuntil, "trafficleft": -1, "premium" : premium}
def login(self, user, data, req):
+ domain = self.getDomain(req)
+
post_vars = {
"email": user,
"password": data["password"],
"rememberMe" : 1
}
- page = req.load("http://www.filesonic.com/user/login", cookies=True, post=post_vars).decode("utf8")
+ page = req.load("http://www.%s/user/login" % domain, cookies=True, post=post_vars).decode("utf8")
if "Provided password does not match." in page or "You must be logged in to view this page." in page:
self.wrongPassword()