summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/account/RapidgatorNet.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/RapidgatorNet.py
parent[ConfigParser] Remove IGNORE feature (diff)
downloadpyload-43e6a6376625ac73067403ddae3b45a80618d6c8.tar.xz
Rename accounts directory to account
Diffstat (limited to 'pyload/plugins/account/RapidgatorNet.py')
-rw-r--r--pyload/plugins/account/RapidgatorNet.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/pyload/plugins/account/RapidgatorNet.py b/pyload/plugins/account/RapidgatorNet.py
new file mode 100644
index 000000000..2c2fd493e
--- /dev/null
+++ b/pyload/plugins/account/RapidgatorNet.py
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+
+from pyload.plugins.base.Account import Account
+from pyload.utils import json_loads
+
+
+class RapidgatorNet(Account):
+ __name__ = "RapidgatorNet"
+ __type__ = "account"
+ __version__ = "0.04"
+
+ __description__ = """Rapidgator.net account plugin"""
+ __author_name__ = "zoidberg"
+ __author_mail__ = "zoidberg@mujmail.cz"
+
+ API_URL = 'http://rapidgator.net/api/user'
+
+
+ def loadAccountInfo(self, user, req):
+ try:
+ sid = self.getAccountData(user).get('SID')
+ assert sid
+
+ json = req.load("%s/info?sid=%s" % (self.API_URL, sid))
+ self.logDebug("API:USERINFO", json)
+ json = json_loads(json)
+
+ if json['response_status'] == 200:
+ if "reset_in" in json['response']:
+ self.scheduleRefresh(user, json['response']['reset_in'])
+
+ return {"validuntil": json['response']['expire_date'],
+ "trafficleft": int(json['response']['traffic_left']) / 1024,
+ "premium": True}
+ else:
+ self.logError(json['response_details'])
+ except Exception, e:
+ self.logError(e)
+
+ return {"validuntil": None, "trafficleft": None, "premium": False}
+
+ def login(self, user, data, req):
+ try:
+ json = req.load('%s/login' % self.API_URL, post={"username": user, "password": data['password']})
+ self.logDebug("API:LOGIN", json)
+ json = json_loads(json)
+
+ if json['response_status'] == 200:
+ data['SID'] = str(json['response']['session_id'])
+ return
+ else:
+ self.logError(json['response_details'])
+ except Exception, e:
+ self.logError(e)
+
+ self.wrongPassword()