diff options
Diffstat (limited to 'module/plugins/accounts/RapiduNet.py')
-rw-r--r-- | module/plugins/accounts/RapiduNet.py | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/module/plugins/accounts/RapiduNet.py b/module/plugins/accounts/RapiduNet.py index fe465bc48..70f47b673 100644 --- a/module/plugins/accounts/RapiduNet.py +++ b/module/plugins/accounts/RapiduNet.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- import re +import time + from module.plugins.Account import Account from module.common.json_layer import json_loads @@ -8,40 +10,56 @@ from module.common.json_layer import json_loads class RapiduNet(Account): __name__ = "RapiduNet" __type__ = "account" - __version__ = "0.02" + __version__ = "0.05" __description__ = """Rapidu.net account plugin""" __license__ = "GPLv3" - __authors__ = [("prOq", None)] + __authors__ = [("prOq", None), + ("Walter Purcaro", "vuolter@gmail.com")] + + + PREMIUM_PATTERN = r'>Account: <b>Premium' + VALID_UNTIL_PATTERN = r'>Account: <b>\w+ \((\d+)' - PREMIUM_PATTERN = r'<a href="premium/" style="padding-left: 0px;">Account: <b>Premium</b></a>' + TRAFFIC_LEFT_PATTERN = r'class="tipsyS"><b>(.+?)<' def loadAccountInfo(self, user, req): - info = {'validuntil': None, 'trafficleft': None, 'premium': False} + validuntil = None + trafficleft = -1 + premium = False - req.load("https://rapidu.net/ajax.php", get={'a': "getChangeLang"}, post={"_go": "", "lang": "en"}) html = req.load("https://rapidu.net/", decode=True) if re.search(self.PREMIUM_PATTERN, html): - info['premium'] = True + premium = True - return info + m = re.search(self.VALID_UNTIL_PATTERN, html) + if m: + validuntil = time.time() + (86400 * int(m.group(1))) + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + trafficleft = self.parseTraffic(m.group(1)) - def login(self, user, data, req): - try: - json = json_loads(req.load("https://rapidu.net/ajax.php?a=getUserLogin", - post={'_go': "", - 'login': user, - 'pass': data['password'], - 'member': "1"})) - - self.logDebug(json) + return {'validuntil': validuntil, 'trafficleft': trafficleft, 'premium': premium} - if not json['message'] == "success": - self.wrongPassword() - except Exception, e: - self.logError(e) + def login(self, user, data, req): + req.load("https://rapidu.net/ajax.php", + get={'a': "getChangeLang"}, + post={'_go' : "", + 'lang': "en"}) + + json = json_loads(req.load("https://rapidu.net/ajax.php", + get={'a': "getUserLogin"}, + post={'_go' : "", + 'login' : user, + 'pass' : data['password'], + 'remember': "1"})) + + self.logDebug(json) + + if not json['message'] == "success": + self.wrongPassword() |