summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts/WebshareCz.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/accounts/WebshareCz.py')
-rw-r--r--module/plugins/accounts/WebshareCz.py48
1 files changed, 23 insertions, 25 deletions
diff --git a/module/plugins/accounts/WebshareCz.py b/module/plugins/accounts/WebshareCz.py
index f032e2317..bbfb90a92 100644
--- a/module/plugins/accounts/WebshareCz.py
+++ b/module/plugins/accounts/WebshareCz.py
@@ -6,13 +6,14 @@ import time
from passlib.hash import md5_crypt
-from module.plugins.Account import Account
+from module.plugins.internal.Account import Account
class WebshareCz(Account):
__name__ = "WebshareCz"
__type__ = "account"
- __version__ = "0.07"
+ __version__ = "0.10"
+ __status__ = "testing"
__description__ = """Webshare.cz account plugin"""
__license__ = "GPLv3"
@@ -24,45 +25,42 @@ class WebshareCz(Account):
TRAFFIC_LEFT_PATTERN = r'<bytes>(.+)</bytes>'
- def loadAccountInfo(self, user, req):
- html = req.load("https://webshare.cz/api/user_data/",
- post={'wst': self.infos['wst']},
- decode=True)
+ def parse_info(self, user, password, data, req):
+ html = self.load("https://webshare.cz/api/user_data/",
+ post={'wst': self.get_data(user).get('wst', None)})
- self.logDebug("Response: " + html)
+ self.log_debug("Response: " + html)
expiredate = re.search(self.VALID_UNTIL_PATTERN, html).group(1)
- self.logDebug("Expire date: " + expiredate)
+ self.log_debug("Expire date: " + expiredate)
validuntil = time.mktime(time.strptime(expiredate, "%Y-%m-%d %H:%M:%S"))
- trafficleft = self.parseTraffic(re.search(self.TRAFFIC_LEFT_PATTERN, html).group(1))
+ trafficleft = self.parse_traffic(re.search(self.TRAFFIC_LEFT_PATTERN, html).group(1))
premium = validuntil > time.time()
return {'validuntil': validuntil, 'trafficleft': -1, 'premium': premium}
- def login(self, user, data, req):
- salt = req.load("https://webshare.cz/api/salt/",
- post={'username_or_email': user,
- 'wst' : ""},
- decode=True)
+ def login(self, user, password, data, req):
+ salt = self.load("https://webshare.cz/api/salt/",
+ post={'username_or_email': user,
+ 'wst' : ""})
if "<status>OK</status>" not in salt:
- self.wrongPassword()
+ self.login_fail()
salt = re.search('<salt>(.+)</salt>', salt).group(1)
- password = hashlib.sha1(md5_crypt.encrypt(data["password"], salt=salt)).hexdigest()
+ password = hashlib.sha1(md5_crypt.encrypt(password, salt=salt)).hexdigest()
digest = hashlib.md5(user + ":Webshare:" + password).hexdigest()
- login = req.load("https://webshare.cz/api/login/",
- post={'digest' : digest,
- 'keep_logged_in' : 1,
- 'password' : password,
- 'username_or_email': user,
- 'wst' : ""},
- decode=True)
+ login = self.load("https://webshare.cz/api/login/",
+ post={'digest' : digest,
+ 'keep_logged_in' : 1,
+ 'password' : password,
+ 'username_or_email': user,
+ 'wst' : ""})
if "<status>OK</status>" not in login:
- self.wrongPassword()
+ self.login_fail()
- self.infos['wst'] = re.search('<token>(.+)</token>', login).group(1)
+ data['wst'] = re.search('<token>(.+)</token>', login).group(1)