summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts/RapidgatorNet.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-16 10:46:28 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-16 10:46:28 +0100
commitce1c2b6b05c08b669357947e61ae40efce7fc50f (patch)
tree0b5f7996960cf35c4eface53a89eba18a37519b7 /module/plugins/accounts/RapidgatorNet.py
parentFix filename case (diff)
downloadpyload-ce1c2b6b05c08b669357947e61ae40efce7fc50f.tar.xz
module temp
Diffstat (limited to 'module/plugins/accounts/RapidgatorNet.py')
-rw-r--r--module/plugins/accounts/RapidgatorNet.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/module/plugins/accounts/RapidgatorNet.py b/module/plugins/accounts/RapidgatorNet.py
new file mode 100644
index 000000000..693b78547
--- /dev/null
+++ b/module/plugins/accounts/RapidgatorNet.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+
+from pyload.plugin.Account import Account
+from pyload.utils import json_loads
+
+
+class RapidgatorNet(Account):
+ __name__ = "RapidgatorNet"
+ __type__ = "account"
+ __version__ = "0.04"
+
+ __description__ = """Rapidgator.net account plugin"""
+ __license__ = "GPLv3"
+ __authors__ = [("zoidberg", "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']),
+ "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()