diff options
Diffstat (limited to 'module/plugins/accounts/FilecloudIo.py')
-rw-r--r-- | module/plugins/accounts/FilecloudIo.py | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/module/plugins/accounts/FilecloudIo.py b/module/plugins/accounts/FilecloudIo.py index f2becb8c9..d20f756f3 100644 --- a/module/plugins/accounts/FilecloudIo.py +++ b/module/plugins/accounts/FilecloudIo.py @@ -1,44 +1,30 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - from module.plugins.Account import Account from module.common.json_layer import json_loads class FilecloudIo(Account): - __name__ = "FilecloudIo" - __version__ = "0.02" - __type__ = "account" + __name__ = "FilecloudIo" + __type__ = "account" + __version__ = "0.03" + __description__ = """FilecloudIo account plugin""" - __author_name__ = ("zoidberg", "stickell") - __author_mail__ = ("zoidberg@mujmail.cz", "l.stickell@yahoo.it") + __license__ = "GPLv3" + __authors__ = [("zoidberg", "zoidberg@mujmail.cz"), + ("stickell", "l.stickell@yahoo.it")] + def loadAccountInfo(self, user, req): # It looks like the first API request always fails, so we retry 5 times, it should work on the second try - for _ in xrange(5): + for _i in xrange(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") + self.logError(_("Wrong username or password")) return {"valid": False, "premium": False} else: return {"premium": False} @@ -50,10 +36,11 @@ class FilecloudIo(Account): rep = json_loads(rep) if rep['is_premium'] == 1: - return {"validuntil": int(rep["premium_until"]), "trafficleft": -1} + return {"validuntil": float(rep['premium_until']), "trafficleft": -1} else: return {"premium": False} + def login(self, user, data, req): req.cj.setCookie("secure.filecloud.io", "lang", "en") html = req.load('https://secure.filecloud.io/user-login.html') @@ -61,8 +48,8 @@ class FilecloudIo(Account): if not hasattr(self, "form_data"): self.form_data = {} - self.form_data["username"] = user - self.form_data["password"] = data['password'] + self.form_data['username'] = user + self.form_data['password'] = data['password'] html = req.load('https://secure.filecloud.io/user-login_p.html', post=self.form_data, |