summaryrefslogtreecommitdiffstats
path: root/module/plugins/accounts/NitroflareCom.py
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-04 02:01:27 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-04 02:01:27 +0200
commitcbd11a6117ce206aa44910a20e522709fd89c99b (patch)
treea817ae0c3dd67318692a54f92d25d9648100b78f /module/plugins/accounts/NitroflareCom.py
parentNew plugin: ZahikiNet (diff)
downloadpyload-cbd11a6117ce206aa44910a20e522709fd89c99b.tar.xz
[NitroflareCom] Account fixup
Diffstat (limited to 'module/plugins/accounts/NitroflareCom.py')
-rw-r--r--module/plugins/accounts/NitroflareCom.py38
1 files changed, 29 insertions, 9 deletions
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</label.*>(.+?)</'
- LOGIN_FAIL_PATTERN = r'<ul class="errors">\s*<li>'
+ VALID_UNTIL_PATTERN = r'>Time Left</label><strong>(.+?)</'
+ TRAFFIC_LEFT_PATTERN = r'>Daily Limit</label><strong>([\d.,]+)'
+ LOGIN_FAIL_PATTERN = r'<ul class="errors">\s*<li>'
+
+ 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):