diff options
Diffstat (limited to 'pyload/plugins/accounts')
-rw-r--r-- | pyload/plugins/accounts/DdlstorageCom.py | 44 | ||||
-rw-r--r-- | pyload/plugins/accounts/FilebeerInfo.py | 57 | ||||
-rw-r--r-- | pyload/plugins/accounts/FilecloudIo.py | 31 | ||||
-rw-r--r-- | pyload/plugins/accounts/SpeedLoadOrg.py | 13 |
4 files changed, 68 insertions, 77 deletions
diff --git a/pyload/plugins/accounts/DdlstorageCom.py b/pyload/plugins/accounts/DdlstorageCom.py index 6c610aa84..7404348a4 100644 --- a/pyload/plugins/accounts/DdlstorageCom.py +++ b/pyload/plugins/accounts/DdlstorageCom.py @@ -1,13 +1,51 @@ # -*- coding: utf-8 -*- +from hashlib import md5 +from time import mktime, strptime + from module.plugins.internal.XFSPAccount import XFSPAccount +from module.common.json_layer import json_loads +from module.utils import parseFileSize + +# DDLStorage API Documentation: +# http://www.ddlstorage.com/cgi-bin/api_req.cgi?req_type=doc class DdlstorageCom(XFSPAccount): __name__ = "DdlstorageCom" - __version__ = "0.01" + __version__ = "1.00" __type__ = "account" __description__ = """DDLStorage.com account plugin""" - __author_name__ = ("zoidberg") - __author_mail__ = ("zoidberg@mujmail.cz") + __author_name__ = ("stickell") + __author_mail__ = ("l.stickell@yahoo.it") MAIN_PAGE = "http://ddlstorage.com/" + + def loadAccountInfo(self, user, req): + password = self.accounts[user]['password'] + api_data = req.load('http://www.ddlstorage.com/cgi-bin/api_req.cgi', + post={'req_type': 'user_info', + 'client_id': 53472, + 'user_login': user, + 'user_password': md5(password).hexdigest(), + 'sign': md5('user_info%d%s%s%s' % (53472, user, md5(password).hexdigest(), + '25JcpU2dPOKg8E2OEoRqMSRu068r0Cv3')).hexdigest()}) + api_data = api_data.replace('<pre>', '').replace('</pre>', '') + self.logDebug('Account Info API data: ' + api_data) + api_data = json_loads(api_data) + + if api_data['status'] != 'OK': # 'status' must be always OK for a working account + return {"premium": False, "valid": False} + + if api_data['account_type'] == 'REGISTERED': + premium = False + validuntil = None + else: + premium = True + validuntil = int(mktime(strptime(api_data['premium_expire'], "%Y-%m-%d %H:%M:%S"))) + + if api_data['usr_bandwidth_available'] == 'UNLIMITED': + trafficleft = -1 + else: + trafficleft = parseFileSize(api_data['usr_bandwidth_available']) / 1024 + + return {"premium": premium, "validuntil": validuntil, "trafficleft": trafficleft} diff --git a/pyload/plugins/accounts/FilebeerInfo.py b/pyload/plugins/accounts/FilebeerInfo.py deleted file mode 100644 index 3c3a9edfd..000000000 --- a/pyload/plugins/accounts/FilebeerInfo.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- 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 -""" - -import re -from time import mktime, strptime -from module.plugins.Account import Account - - -class FilebeerInfo(Account): - __name__ = "FilebeerInfo" - __version__ = "0.02" - __type__ = "account" - __description__ = """filebeer.info account plugin""" - __author_name__ = ("zoidberg") - __author_mail__ = ("zoidberg@mujmail.cz") - - VALID_UNTIL_PATTERN = r'Reverts To Free Account:\s</td>\s*<td>\s*(.*?)\s*</td>' - - def loadAccountInfo(self, user, req): - html = req.load("http://filebeer.info/upgrade.php", decode=True) - premium = not 'Free User </td>' in html - - validuntil = None - if premium: - try: - validuntil = mktime(strptime(re.search(self.VALID_UNTIL_PATTERN, html).group(1), "%d/%m/%Y %H:%M:%S")) - except Exception, e: - self.logError("Unable to parse account info", e) - - return {"validuntil": validuntil, "trafficleft": -1, "premium": premium} - - def login(self, user, data, req): - html = req.load('http://filebeer.info/login.php', post={ - "submit": 'Login', - "loginPassword": data['password'], - "loginUsername": user, - "submitme": '1' - }, decode=True) - - if "<ul class='pageErrors'>" in html or ">Your username and password are invalid<" in html: - self.wrongPassword() diff --git a/pyload/plugins/accounts/FilecloudIo.py b/pyload/plugins/accounts/FilecloudIo.py index 5de722ea7..93ae02006 100644 --- a/pyload/plugins/accounts/FilecloudIo.py +++ b/pyload/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/pyload/plugins/accounts/SpeedLoadOrg.py b/pyload/plugins/accounts/SpeedLoadOrg.py deleted file mode 100644 index bb9fb05fb..000000000 --- a/pyload/plugins/accounts/SpeedLoadOrg.py +++ /dev/null @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- -from module.plugins.internal.XFSPAccount import XFSPAccount - - -class SpeedLoadOrg(XFSPAccount): - __name__ = "SpeedLoadOrg" - __version__ = "0.01" - __type__ = "account" - __description__ = """SpeedLoadOrg account plugin""" - __author_name__ = ("stickell") - __author_mail__ = ("l.stickell@yahoo.it") - - MAIN_PAGE = "http://speedload.org/" |