diff options
author | Stefano <l.stickell@yahoo.it> | 2013-10-08 16:38:43 +0200 |
---|---|---|
committer | Stefano <l.stickell@yahoo.it> | 2013-10-08 16:38:43 +0200 |
commit | 37251667fed7fcbb77ea55df7ca98f2d5bef1b19 (patch) | |
tree | 1bda07aa846b3e2af634758ca58b15e8ef37c2b8 | |
parent | SimpleHoster: workaround load cookies 0.4.9 bug (diff) | |
download | pyload-37251667fed7fcbb77ea55df7ca98f2d5bef1b19.tar.xz |
FilecloudIo: premium support
-rw-r--r-- | module/plugins/accounts/FilecloudIo.py | 31 | ||||
-rw-r--r-- | module/plugins/hoster/FilecloudIo.py | 17 |
2 files changed, 42 insertions, 6 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") diff --git a/module/plugins/hoster/FilecloudIo.py b/module/plugins/hoster/FilecloudIo.py index 92735d579..c7684a05d 100644 --- a/module/plugins/hoster/FilecloudIo.py +++ b/module/plugins/hoster/FilecloudIo.py @@ -26,9 +26,9 @@ class FilecloudIo(SimpleHoster): __name__ = "FilecloudIo" __type__ = "hoster" __pattern__ = r"http://(?:\w*\.)*(?:filecloud\.io|ifile\.it|mihd\.net)/(?P<ID>\w+).*" - __version__ = "0.01" + __version__ = "0.02" __description__ = """Filecloud.io (formerly Ifile.it) plugin - free account only""" - __author_name__ = ("zoidberg") + __author_name__ = ("zoidberg", "stickell") FILE_SIZE_PATTERN = r'{var __ab1 = (?P<S>\d+);}' FILE_NAME_PATTERN = r'id="aliasSpan">(?P<N>.*?) <' @@ -109,5 +109,18 @@ class FilecloudIo(SimpleHoster): else: self.fail("Unexpected server response") + def handlePremium(self): + akey = self.account.getAccountData(self.user)['akey'] + ukey = self.file_info['ID'] + self.logDebug("Akey: %s | Ukey: %s" % (akey, ukey)) + rep = self.load("http://api.filecloud.io/api-fetch_download_url.api", + post={"akey": akey, "ukey": ukey}) + self.logDebug("FetchDownloadUrl: " + rep) + rep = json_loads(rep) + if rep['status'] == 'ok': + self.download(rep['download_url'], disposition=True) + else: + self.fail(rep['message']) + getInfo = create_getInfo(FilecloudIo) |