summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/account/RPNetBiz.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2014-10-03 19:58:02 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2014-10-03 19:58:02 +0200
commit43e6a6376625ac73067403ddae3b45a80618d6c8 (patch)
treeceb458c3da1f19e0a91731bc254ee3a158682d0b /pyload/plugins/account/RPNetBiz.py
parent[ConfigParser] Remove IGNORE feature (diff)
downloadpyload-43e6a6376625ac73067403ddae3b45a80618d6c8.tar.xz
Rename accounts directory to account
Diffstat (limited to 'pyload/plugins/account/RPNetBiz.py')
-rw-r--r--pyload/plugins/account/RPNetBiz.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/pyload/plugins/account/RPNetBiz.py b/pyload/plugins/account/RPNetBiz.py
new file mode 100644
index 000000000..c10122053
--- /dev/null
+++ b/pyload/plugins/account/RPNetBiz.py
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+
+from pyload.plugins.base.Account import Account
+from pyload.utils import json_loads
+
+
+class RPNetBiz(Account):
+ __name__ = "RPNetBiz"
+ __type__ = "account"
+ __version__ = "0.1"
+
+ __description__ = """RPNet.biz account plugin"""
+ __author_name__ = "Dman"
+ __author_mail__ = "dmanugm@gmail.com"
+
+
+ def loadAccountInfo(self, user, req):
+ # Get account information from rpnet.biz
+ response = self.getAccountStatus(user, req)
+ try:
+ if response['accountInfo']['isPremium']:
+ # Parse account info. Change the trafficleft later to support per host info.
+ account_info = {"validuntil": int(response['accountInfo']['premiumExpiry']),
+ "trafficleft": -1, "premium": True}
+ else:
+ account_info = {"validuntil": None, "trafficleft": None, "premium": False}
+
+ except KeyError:
+ #handle wrong password exception
+ account_info = {"validuntil": None, "trafficleft": None, "premium": False}
+
+ return account_info
+
+ def login(self, user, data, req):
+ # Get account information from rpnet.biz
+ response = self.getAccountStatus(user, req)
+
+ # If we have an error in the response, we have wrong login information
+ if 'error' in response:
+ self.wrongPassword()
+
+ def getAccountStatus(self, user, req):
+ # Using the rpnet API, check if valid premium account
+ response = req.load("https://premium.rpnet.biz/client_api.php",
+ get={"username": user, "password": self.accounts[user]['password'],
+ "action": "showAccountInformation"})
+ self.logDebug("JSON data: %s" % response)
+
+ return json_loads(response)