summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts/CatShareNet.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/accounts/CatShareNet.py')
-rw-r--r--module/plugins/accounts/CatShareNet.py41
1 files changed, 23 insertions, 18 deletions
diff --git a/module/plugins/accounts/CatShareNet.py b/module/plugins/accounts/CatShareNet.py
index c33219685..bb42f443f 100644
--- a/module/plugins/accounts/CatShareNet.py
+++ b/module/plugins/accounts/CatShareNet.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
import re
-
-from time import mktime, strptime
+import time
from module.plugins.Account import Account
@@ -10,39 +9,44 @@ from module.plugins.Account import Account
class CatShareNet(Account):
__name__ = "CatShareNet"
__type__ = "account"
- __version__ = "0.01"
+ __version__ = "0.05"
__description__ = """CatShareNet account plugin"""
__license__ = "GPLv3"
__authors__ = [("prOq", None)]
- PREMIUM_PATTERN = r'class="nav-collapse collapse pull-right">[\s\w<>=-."/:]*\sz.</a></li>\s*<li><a href="/premium">.*\s*<span style="color: red">(.*?)</span>[\s\w<>/]*href="/logout"'
- VALID_UNTIL_PATTERN = r'<div class="span6 pull-right">[\s\w<>=-":;]*<span style="font-size:13px;">.*?<strong>(.*?)</strong></span>'
+ 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)'
def loadAccountInfo(self, user, req):
- premium = False
- validuntil = -1
+ premium = False
+ validuntil = -1
+ trafficleft = -1
html = req.load("http://catshare.net/", decode=True)
+ if re.search(self.PREMIUM_PATTERN, html):
+ premium = True
+
try:
- m = re.search(self.PREMIUM_PATTERN, html)
- if "Premium" in m.group(1):
- premium = True
- except:
+ expiredate = re.search(self.VALID_UNTIL_PATTERN, html).group(1)
+ self.logDebug("Expire date: " + expiredate)
+
+ validuntil = time.mktime(time.strptime(expiredate, "%Y-%m-%d %H:%M:%S"))
+
+ except Exception:
pass
try:
- m = re.search(self.VALID_UNTIL_PATTERN, html)
- expiredate = m.group(1)
- if "-" not in expiredate:
- validuntil = mktime(strptime(expiredate, "%d.%m.%Y"))
- except:
+ trafficleft = self.parseTraffic(re.search(self.TRAFFIC_LEFT_PATTERN, html).group(1))
+
+ except Exception:
pass
- return {'premium': premium, 'trafficleft': -1, 'validuntil': validuntil}
+ return {'premium': premium, 'trafficleft': trafficleft, 'validuntil': validuntil}
def login(self, user, data, req):
@@ -50,7 +54,8 @@ class CatShareNet(Account):
post={'user_email': user,
'user_password': data['password'],
'remindPassword': 0,
- 'user[submit]': "Login"})
+ 'user[submit]': "Login"},
+ decode=True)
if not '<a href="/logout">Wyloguj</a>' in html:
self.wrongPassword()