From cbd11a6117ce206aa44910a20e522709fd89c99b Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 4 Jun 2015 02:01:27 +0200 Subject: [NitroflareCom] Account fixup --- module/plugins/accounts/NitroflareCom.py | 38 ++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'module/plugins/accounts/NitroflareCom.py') diff --git a/module/plugins/accounts/NitroflareCom.py b/module/plugins/accounts/NitroflareCom.py index 4f7ae90c5..d9b434504 100644 --- a/module/plugins/accounts/NitroflareCom.py +++ b/module/plugins/accounts/NitroflareCom.py @@ -9,20 +9,23 @@ from module.plugins.Account import Account class NitroflareCom(Account): __name__ = "NitroflareCom" __type__ = "account" - __version__ = "0.02" + __version__ = "0.03" __description__ = """Nitroflare.com account plugin""" __license__ = "GPLv3" __authors__ = [("Walter Purcaro", "vuolter@gmail.com" )] - VALID_UNTIL_PATTERN = r'>Time Left(.+?)\s*
  • ' + VALID_UNTIL_PATTERN = r'>Time Left(.+?)Daily Limit([\d.,]+)' + LOGIN_FAIL_PATTERN = r'
      \s*
    • ' + + TOKEN_PATTERN = r'name="token" value="(.+?)"' def loadAccountInfo(self, user, req): validuntil = -1 - trafficleft = None #@TODO: Implement traffic left check + trafficleft = None premium = False html = req.load("https://nitroflare.com/member", @@ -32,6 +35,7 @@ class NitroflareCom(Account): m = re.search(self.VALID_UNTIL_PATTERN, html) if m: expiredate = m.group(1).strip() + self.logDebug("Time Left: " + expiredate) try: validuntil = sum(int(v) * {'day': 24 * 3600, 'hour': 3600, 'minute': 60}[u.lower()] for v, u in @@ -40,23 +44,39 @@ class NitroflareCom(Account): self.logError(e) else: + self.logDebug("Valid until: %s" % validuntil) + if validuntil: validuntil += time.time() premium = True else: validuntil = -1 - return {'validuntil' : validuntil, - 'trafficleft' : trafficleft, - 'premium' : premium} + m = re.search(self.TRAFFIC_LEFT_PATTERN, html) + if m: + try: + trafficleft = self.parseTraffic(str(max(0, 50 - int(m.group(1)))) + " GB") + + except Exception, e: + self.logError(e) + else: + self.logDebug("TRAFFIC_LEFT_PATTERN not found") + + return {'validuntil' : validuntil, + 'trafficleft': trafficleft, + 'premium' : premium} def login(self, user, data, req): html = req.load("https://nitroflare.com/login", decode=True) + + token = re.search(self.TOKEN_PATTERN, html).group(1) + html = req.load("https://nitroflare.com/login", - post={'email' : user, + post={'login' : "", + 'email' : user, 'password': data['password'], - 'token' : re.search(r'name="token" value="(.+?)"', html).group(1)}, + 'token' : token}, decode=True) if re.search(self.LOGIN_FAIL_PATTERN, html): -- cgit v1.2.3