Repository navigation
Expand file tree
/
Copy pathZeveraCom.py
More file actions
78 lines (52 loc) · 2.27 KB
/
Copy pathZeveraCom.py
File metadata and controls
78 lines (52 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# -*- coding: utf-8 -*-
import time
from module.plugins.internal.Account import Account
class ZeveraCom(Account):
__name__ = "ZeveraCom"
__type__ = "account"
__version__ = "0.28"
__status__ = "testing"
__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.log_error(_("Missing HOSTER_DOMAIN"))
if not hasattr(self, "API_URL"):
self.API_URL = "http://api.%s/jDownloader.ashx" % (self.HOSTER_DOMAIN or "")
def parse_info(self, user, password, data, req):
validuntil = None
trafficleft = None
premium = False
api = self.api_response(req)
if "No trafic" not in api and api['endsubscriptiondate'] != "Expired!":
validuntil = time.mktime(time.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, password, data, req):
self.user = user
self.password = password
if self.api_response(req) == "No trafic":
self.login_fail()
def api_response(self, req, just_header=False, **kwargs):
get_data = {'cmd' : "accountinfo",
'login': self.user,
'pass' : self.password}
get_data.update(kwargs)
res = self.load(self.API_URL,
get=get_data,
just_header=just_header)
self.log_debug(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