diff options
author | Walter Purcaro <vuolter@gmail.com> | 2015-01-18 00:14:28 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2015-01-18 00:14:28 +0100 |
commit | 1e104975ef3cd0a755ef5ea91d4f5d1abd89704d (patch) | |
tree | 20ad4dc969f588fe65ba4d81c401a7ab14ab1782 | |
parent | Merge pull request #1051 from rukasuzu/patch-1 (diff) | |
parent | [CatShareNet] Added traffic left info (diff) | |
download | pyload-1e104975ef3cd0a755ef5ea91d4f5d1abd89704d.tar.xz |
Merge pull request #1052 from rukasuzu/patch-2
[CatShareNet] Added traffic left info
-rw-r--r-- | module/plugins/accounts/CatShareNet.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/module/plugins/accounts/CatShareNet.py b/module/plugins/accounts/CatShareNet.py index 90cdfe013..2552521e4 100644 --- a/module/plugins/accounts/CatShareNet.py +++ b/module/plugins/accounts/CatShareNet.py @@ -19,11 +19,13 @@ class CatShareNet(Account): 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)' def loadAccountInfo(self, user, req): premium = False validuntil = -1 + trafficleft = -1 html = req.load("http://catshare.net/", decode=True) @@ -39,10 +41,13 @@ class CatShareNet(Account): 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))) except Exception: pass - return {'premium': premium, 'trafficleft': -1, 'validuntil': validuntil} + return {'premium': premium, 'trafficleft': trafficleft, 'validuntil': validuntil} def login(self, user, data, req): |