summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts/FilecloudIo.py
diff options
context:
space:
mode:
authorGravatar Stefano <l.stickell@yahoo.it> 2013-10-08 16:38:43 +0200
committerGravatar Stefano <l.stickell@yahoo.it> 2013-10-08 16:38:43 +0200
commit37251667fed7fcbb77ea55df7ca98f2d5bef1b19 (patch)
tree1bda07aa846b3e2af634758ca58b15e8ef37c2b8 /module/plugins/accounts/FilecloudIo.py
parentSimpleHoster: workaround load cookies 0.4.9 bug (diff)
downloadpyload-37251667fed7fcbb77ea55df7ca98f2d5bef1b19.tar.xz
FilecloudIo: premium support
Diffstat (limited to 'module/plugins/accounts/FilecloudIo.py')
-rw-r--r--module/plugins/accounts/FilecloudIo.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/module/plugins/accounts/FilecloudIo.py b/module/plugins/accounts/FilecloudIo.py
index 5de722ea7..93ae02006 100644
--- a/module/plugins/accounts/FilecloudIo.py
+++ b/module/plugins/accounts/FilecloudIo.py
@@ -18,18 +18,41 @@
"""
from module.plugins.Account import Account
+from module.common.json_layer import json_loads
class FilecloudIo(Account):
__name__ = "FilecloudIo"
- __version__ = "0.01"
+ __version__ = "0.02"
__type__ = "account"
__description__ = """FilecloudIo account plugin"""
- __author_name__ = ("zoidberg")
- __author_mail__ = ("zoidberg@mujmail.cz")
+ __author_name__ = ("zoidberg", "stickell")
+ __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it")
def loadAccountInfo(self, user, req):
- return {"validuntil": -1, "trafficleft": -1, "premium": False}
+ # It looks like the first API request always fails, so we retry 5 times, it should work on the second try
+ for _ in range(5):
+ rep = req.load("https://secure.filecloud.io/api-fetch_apikey.api",
+ post={"username": user, "password": self.accounts[user]['password']})
+ rep = json_loads(rep)
+ if rep['status'] == 'ok':
+ break
+ elif rep['status'] == 'error' and rep['message'] == 'no such user or wrong password':
+ self.logError("Wrong username or password")
+ return {"valid": False, "premium": False}
+ else:
+ return {"premium": False}
+
+ akey = rep['akey']
+ self.accounts[user]['akey'] = akey # Saved for hoster plugin
+ rep = req.load("http://api.filecloud.io/api-fetch_account_details.api",
+ post={"akey": akey})
+ rep = json_loads(rep)
+
+ if rep['is_premium'] == 1:
+ return {"validuntil": int(rep["premium_until"]), "trafficleft": -1}
+ else:
+ return {"premium": False}
def login(self, user, data, req):
req.cj.setCookie("secure.filecloud.io", "lang", "en")