summaryrefslogtreecommitdiffstats
path: root/pyload/plugin/account/ZeveraCom.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-16 21:59:10 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-02-16 21:59:10 +0100
commit8e7d14bae4d3c836f029a1235eb227380acc3f75 (patch)
treeebd0679642cccb994e70a89a106b394189cb28bc /pyload/plugin/account/ZeveraCom.py
parentMerge branch 'stable' into 0.4.10 (diff)
downloadpyload-8e7d14bae4d3c836f029a1235eb227380acc3f75.tar.xz
Fix plugins to work on 0.4.10
Diffstat (limited to 'pyload/plugin/account/ZeveraCom.py')
-rw-r--r--pyload/plugin/account/ZeveraCom.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/pyload/plugin/account/ZeveraCom.py b/pyload/plugin/account/ZeveraCom.py
new file mode 100644
index 000000000..db23170f3
--- /dev/null
+++ b/pyload/plugin/account/ZeveraCom.py
@@ -0,0 +1,78 @@
+# -*- coding: utf-8 -*-
+
+from time import mktime, strptime
+
+from pyload.plugin.Account import Account
+
+
+class ZeveraCom(Account):
+ __name__ = "ZeveraCom"
+ __type__ = "account"
+ __version__ = "0.26"
+
+ __description__ = """Zevera.com account plugin"""
+ __license__ = "GPLv3"
+ __authors__ = [("zoidberg", "zoidberg@mujmail.cz"),
+ ("Walter Purcaro", "vuolter@gmail.com")]
+
+
+ HOSTER_DOMAIN = "zevera.com"
+
+
+ def __init__(self, manager, accounts): #@TODO: remove in 0.4.10
+ self.init()
+ return super(ZeveraCom, self).__init__(manager, accounts)
+
+
+ def init(self):
+ if not self.HOSTER_DOMAIN:
+ self.logError(_("Missing HOSTER_DOMAIN"))
+
+ if not hasattr(self, "API_URL"):
+ self.API_URL = "http://api.%s/jDownloader.ashx" % (self.HOSTER_DOMAIN or "")
+
+
+ def loadAccountInfo(self, user, req):
+ validuntil = None
+ trafficleft = None
+ premium = False
+
+ api = self.api_response(req)
+
+ if "No trafic" not in api and api['endsubscriptiondate'] != "Expired!":
+ validuntil = mktime(strptime(api['endsubscriptiondate'], "%Y/%m/%d %H:%M:%S"))
+ trafficleft = float(api['availabletodaytraffic']) * 1024 if api['orondaytrafficlimit'] != '0' else -1
+ premium = True
+
+ return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium}
+
+
+ def login(self, user, data, req):
+ self.user = user
+ self.password = data['password']
+
+ if self.api_response(req) == "No trafic":
+ self.wrongPassword()
+
+
+ def api_response(self, req, just_header=False, **kwargs):
+ get_data = {'cmd' : "accountinfo",
+ 'login': self.user,
+ 'pass' : self.password}
+
+ get_data.update(kwargs)
+
+ res = req.load(self.API_URL,
+ get=get_data,
+ just_header=just_header,
+ decode=True)
+
+ 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