summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-18 11:59:32 +0100
committerGravatar Walter Purcaro <vuolter@gmail.com> 2015-01-18 11:59:32 +0100
commit70cc18ec1552c580b8e53737a32f7324720d67dc (patch)
tree5cfc29ed77f5b5875e83bbd82ca53c8337f47441 /module/plugins/accounts
parentMerge pull request #1044 from zapp-brannigan/patch-3 (diff)
downloadpyload-70cc18ec1552c580b8e53737a32f7324720d67dc.tar.xz
[CatShareNet] Update
Diffstat (limited to 'module/plugins/accounts')
-rw-r--r--module/plugins/accounts/CatShareNet.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/module/plugins/accounts/CatShareNet.py b/module/plugins/accounts/CatShareNet.py
index 2552521e4..00bfadd09 100644
--- a/module/plugins/accounts/CatShareNet.py
+++ b/module/plugins/accounts/CatShareNet.py
@@ -10,40 +10,44 @@ from module.plugins.Account import Account
class CatShareNet(Account):
__name__ = "CatShareNet"
__type__ = "account"
- __version__ = "0.02"
+ __version__ = "0.03"
__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>'
- TRAFFIC_PATTERN = r'<a href="/premium">([0-9.]+ [kMG]B)'
+ 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>'
+ 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)
try:
- m = re.search(self.PREMIUM_PATTERN, html)
- if "Premium" in m.group(1):
+ if "Premium" in re.search(self.PREMIUM_PATTERN, html).group(1):
premium = True
+
+ except Exception:
+ pass
+
+ try:
+ expiredate = re.search(self.VALID_UNTIL_PATTERN, html).group(1)
+ self.logDebug("Expire date: " + expiredate)
+
+ validuntil = mktime(strptime(expiredate, "%d.%m.%Y"))
+
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"))
- m = re.search(TRAFFIC_PATTERN, html)
- if m:
- trafficleft = int(self.parseTraffic(m.group(1)))
+ trafficleft = self.parseTraffic(re.search(TRAFFIC_LEFT_PATTERN, html).group(1))
+
except Exception:
pass