diff options
Diffstat (limited to 'module/plugins/accounts/CatShareNet.py')
-rw-r--r-- | module/plugins/accounts/CatShareNet.py | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/module/plugins/accounts/CatShareNet.py b/module/plugins/accounts/CatShareNet.py index 8831b9014..b80cf59b9 100644 --- a/module/plugins/accounts/CatShareNet.py +++ b/module/plugins/accounts/CatShareNet.py @@ -9,17 +9,18 @@ from module.plugins.internal.Account import Account class CatShareNet(Account): __name__ = "CatShareNet" __type__ = "account" - __version__ = "0.12" + __version__ = "0.13" __status__ = "testing" __description__ = """Catshare.net account plugin""" __license__ = "GPLv3" - __authors__ = [("prOq", None)] + __authors__ = [("prOq", None ), + ("GammaC0de", "nitzo2001[AT]yahoo[DOT]com")] PREMIUM_PATTERN = r'<a href="/premium">Konto:[\s\n]*Premium' VALID_UNTIL_PATTERN = r'>Konto premium.*?<strong>(.*?)</strong></span>' - TRAFFIC_LEFT_PATTERN = r'<a href="/premium">([0-9.]+ [kMG]B)' + TRAFFIC_LEFT_PATTERN = r'<a href="/premium">(?P<S>[\d.,]+) (?P<U>[kMG]B)' def grab_info(self, user, password, data): @@ -32,25 +33,23 @@ class CatShareNet(Account): if re.search(self.PREMIUM_PATTERN, html): premium = True - try: - expiredate = re.search(self.VALID_UNTIL_PATTERN, html).group(1) - self.log_debug("Expire date: " + expiredate) + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + validuntil = time.mktime(time.strptime(m.group(1), "%Y-%m-%d %H:%M:%S")) - validuntil = time.mktime(time.strptime(expiredate, "%Y-%m-%d %H:%M:%S")) - - except Exception: - pass - - try: - trafficleft = self.parse_traffic(re.search(self.TRAFFIC_LEFT_PATTERN, html).group(1)) - - except Exception: - pass + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + trafficleft = self.parse_traffic(m.group(1), m.group(2)) return {'premium': premium, 'trafficleft': trafficleft, 'validuntil': validuntil} def signin(self, user, password, data): + html = self.load("http://catshare.net/") + + if '<a href="/logout">Wyloguj</a>' in html: + self.skip_login() + html = self.load("http://catshare.net/login", #@TODO: Revert to `https` in 0.4.10 post={'user_email' : user, 'user_password' : password, |