summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/accounts/DdlstorageCom.py
diff options
context:
space:
mode:
authorGravatar Stefano <l.stickell@yahoo.it> 2013-10-02 15:28:37 +0200
committerGravatar Stefano <l.stickell@yahoo.it> 2013-10-07 11:24:58 +0200
commit250b64d1a45d47be3fbf85efdcf845f5656cf7fb (patch)
treefafa83a2c2fb50baf8955655de4e6d05f85d8858 /pyload/plugins/accounts/DdlstorageCom.py
parentGamefrontCom: unlimited chunks even for free users (diff)
downloadpyload-250b64d1a45d47be3fbf85efdcf845f5656cf7fb.tar.xz
DDLStorage: rewritten to use API.
(cherry picked from commit b2e735273ee83820a7e9633f159168e0712c4e75)
Diffstat (limited to 'pyload/plugins/accounts/DdlstorageCom.py')
-rw-r--r--pyload/plugins/accounts/DdlstorageCom.py44
1 files changed, 41 insertions, 3 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}