diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-12-13 15:56:57 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-12-13 15:56:57 +0100 |
commit | acc46fc3497a66a427b795b4a22c6e71d69185a1 (patch) | |
tree | 2d315b838a76435fc456b972c99c28d1732b2f70 /pyload/plugin/account/ZeveraCom.py | |
parent | Code fixes (diff) | |
download | pyload-acc46fc3497a66a427b795b4a22c6e71d69185a1.tar.xz |
Update
Diffstat (limited to 'pyload/plugin/account/ZeveraCom.py')
-rw-r--r-- | pyload/plugin/account/ZeveraCom.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/pyload/plugin/account/ZeveraCom.py b/pyload/plugin/account/ZeveraCom.py new file mode 100644 index 000000000..aab795e55 --- /dev/null +++ b/pyload/plugin/account/ZeveraCom.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- + +from time import mktime, strptime + +from pyload.plugin.Account import Account + + +class ZeveraCom(Account): + __name = "ZeveraCom" + __type = "account" + __version = "0.21" + + __description = """Zevera.com account plugin""" + __license = "GPLv3" + __authors = [("zoidberg", "zoidberg@mujmail.cz")] + + + def loadAccountInfo(self, user, req): + data = self.getAPIData(req) + if data == "No traffic": + account_info = {"trafficleft": 0, "validuntil": 0, "premium": False} + else: + account_info = { + "trafficleft": int(data['availabletodaytraffic']) * 1024, + "validuntil": mktime(strptime(data['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S")), + "premium": True + } + return account_info + + + def login(self, user, data, req): + self.loginname = user + self.password = data['password'] + if self.getAPIData(req) == "No traffic": + self.wrongPassword() + + + def getAPIData(self, req, just_header=False, **kwargs): + get_data = { + 'cmd': 'accountinfo', + 'login': self.loginname, + 'pass': self.password + } + get_data.update(kwargs) + + res = req.load("http://www.zevera.com/jDownloader.ashx", get=get_data, + decode=True, just_header=just_header) + self.logDebug(res) + + if ':' in res: + if not just_header: + res = res.replace(',', '\n') + return dict((y.strip().lower(), z.strip()) for (y, z) in + [x.split(':', 1) for x in res.splitlines() if ':' in x]) + else: + return res |