summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts/RapideoPl.py
diff options
context:
space:
mode:
authorGravatar lazlev <lazlev@yopmail.com> 2015-08-09 00:50:54 +0200
committerGravatar lazlev <lazlev@yopmail.com> 2015-08-09 00:50:54 +0200
commitb0ef3f1673e1930916604bb1264ca3a38414bc8d (patch)
treec97936e4d2a4cd6eb1072c65c8a08a7d18816b18 /module/plugins/accounts/RapideoPl.py
parent[XFileSharingPro][XFileSharingProFolder] Added default __pattern__ (diff)
parentFix https://github.com/pyload/pyload/issues/1707 (diff)
downloadpyload-b0ef3f1673e1930916604bb1264ca3a38414bc8d.tar.xz
Merge pull request #1 from pyload/stable
sync with stable
Diffstat (limited to 'module/plugins/accounts/RapideoPl.py')
-rw-r--r--module/plugins/accounts/RapideoPl.py81
1 files changed, 42 insertions, 39 deletions
diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py
index 3e9d52fe8..42d084bdb 100644
--- a/module/plugins/accounts/RapideoPl.py
+++ b/module/plugins/accounts/RapideoPl.py
@@ -4,77 +4,80 @@ import datetime
import hashlib
import time
-from module.plugins.Account import Account
-from module.common.json_layer import json_loads as loads
+from module.common.json_layer import json_loads
+from module.plugins.internal.Account import Account
class RapideoPl(Account):
- __name__ = "RapideoPl"
- __version__ = "0.01"
- __type__ = "account"
+ __name__ = "RapideoPl"
+ __type__ = "account"
+ __version__ = "0.03"
+ __status__ = "testing"
+
__description__ = "Rapideo.pl account plugin"
- __license__ = "GPLv3"
- __authors__ = [("goddie", "dev@rapideo.pl")]
+ __license__ = "GPLv3"
+ __authors__ = [("goddie", "dev@rapideo.pl")]
- _api_url = "http://enc.rapideo.pl"
- _api_query = {
- "site": "newrd",
- "username": "",
- "password": "",
- "output": "json",
- "loc": "1",
- "info": "1"
- }
+ API_URL = "http://enc.rapideo.pl"
+ API_QUERY = {'site' : "newrd",
+ 'username': "" ,
+ 'password': "" ,
+ 'output' : "json" ,
+ 'loc' : "1" ,
+ 'info' : "1" }
_req = None
_usr = None
_pwd = None
- def loadAccountInfo(self, name, req):
+
+ def parse_info(self, name, req):
self._req = req
try:
- result = loads(self.runAuthQuery())
+ result = json_loads(self.run_auth_query())
except Exception:
- # todo: return or let it be thrown?
+ #@TODO: return or let it be thrown?
return
premium = False
valid_untill = -1
- if "expire" in result.keys() and result["expire"]:
+
+ if "expire" in result.keys() and result['expire']:
premium = True
- valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result["expire"])).timetuple())
+ valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result['expire'])).timetuple())
- traffic_left = result["balance"]
+ traffic_left = result['balance']
- return ({
- "validuntil": valid_untill,
- "trafficleft": traffic_left,
- "premium": premium
- })
+ return {'validuntil' : valid_untill,
+ 'trafficleft': traffic_left,
+ 'premium' : premium }
- def login(self, user, data, req):
+
+ def login(self, user, password, data, req):
self._usr = user
- self._pwd = hashlib.md5(data["password"]).hexdigest()
+ self._pwd = hashlib.md5(password).hexdigest()
self._req = req
+
try:
- response = loads(self.runAuthQuery())
+ response = json_loads(self.run_auth_query())
except Exception:
- self.wrongPassword()
+ self.login_fail()
if "errno" in response.keys():
- self.wrongPassword()
+ self.login_fail()
+
data['usr'] = self._usr
data['pwd'] = self._pwd
- def createAuthQuery(self):
- query = self._api_query
- query["username"] = self._usr
- query["password"] = self._pwd
+ def create_auth_query(self):
+ query = self.API_QUERY
+ query['username'] = self._usr
+ query['password'] = self._pwd
return query
- def runAuthQuery(self):
- data = self._req.load(self._api_url, post=self.createAuthQuery())
- return data \ No newline at end of file
+ def run_auth_query(self):
+ return self.load(self.API_URL,
+ post=self.create_auth_query())