diff options
author | Nitzo <nitzo2001@yahoo.com> | 2016-06-20 22:09:27 +0200 |
---|---|---|
committer | Nitzo <nitzo2001@yahoo.com> | 2016-06-20 22:09:27 +0200 |
commit | 79dad368430c24a89fd2502dddb7f1b2bb012a71 (patch) | |
tree | 73dbf044e9188bfe09044966a9704442cb0b79dd /module | |
parent | [BitshareCom] Dead, fix #2510 (diff) | |
download | pyload-79dad368430c24a89fd2502dddb7f1b2bb012a71.tar.xz |
[NitroflareCom] fix #2477
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/accounts/NitroflareCom.py | 104 | ||||
-rw-r--r-- | module/plugins/hoster/NitroflareCom.py | 38 |
2 files changed, 56 insertions, 86 deletions
diff --git a/module/plugins/accounts/NitroflareCom.py b/module/plugins/accounts/NitroflareCom.py index e6cfc1b34..133f8dbe1 100644 --- a/module/plugins/accounts/NitroflareCom.py +++ b/module/plugins/accounts/NitroflareCom.py @@ -4,15 +4,14 @@ import re import time from module.plugins.internal.Account import Account -from module.PyFile import PyFile -from module.plugins.captcha.ReCaptcha import ReCaptcha +from module.plugins.internal.misc import json class NitroflareCom(Account): - __name__ = "NitroflareCom" - __type__ = "account" - __version__ = "0.16" - __status__ = "testing" + __name__ = "NitroflareCom" + __type__ = "account" + __version__ = "0.17" + __status__ = "testing" __description__ = """Nitroflare.com account plugin""" __license__ = "GPLv3" @@ -20,51 +19,21 @@ class NitroflareCom(Account): ("GammaC0de", "nitzo2001[AT]yahoo[DOT]com")] - VALID_UNTIL_PATTERN = r'>Time Left</label><strong>(.+?)</' - TRAFFIC_LEFT_PATTERN = r'>Your Daily Limit</label><strong>(?P<S1>[\d.,]+) (?P<U1>[\w^_]+ )?/ (?P<S2>[\d.,]+) (?P<U2>[\w^_]+)' - LOGIN_FAIL_PATTERN = r'<ul class="errors">\s*<li>' - - TOKEN_PATTERN = r'name="token" value="(.+?)"' - - def grab_info(self, user, password, data): - validuntil = -1 - trafficleft = None - premium = False - - html = self.load("https://nitroflare.com/member", - get={'s': "premium"}) - - m = re.search(self.VALID_UNTIL_PATTERN, html) - if m is not None: - expiredate = m.group(1).strip() - self.log_debug("Time Left: " + expiredate) + validuntil = -1 + trafficleft = None + premium = False - try: - validuntil = sum(int(v) * {'day': 24 * 3600, 'hour': 3600, 'minute': 60}[u.lower()] for v, u in - re.findall(r'(\d+)\s*(day|hour|minute)', expiredate, re.I)) + data = json.loads(self.load("https://nitroflare.com/api/v2/getKeyInfo", + get={'user' : user, + 'premiumKey': password})) - except Exception, e: - self.log_error(e, trace=True) + if data['type'] == 'success': + trafficleft = self.parse_traffic(data['result']['trafficLeft'], "byte") + premium = data['result']['status'] == "active" - else: - self.log_debug("Valid until: %s" % validuntil) - - if validuntil: - validuntil += time.time() - premium = True - else: - validuntil = -1 - - m = re.search(self.TRAFFIC_LEFT_PATTERN, html) - if m is not None: - try: - trafficleft = self.parse_traffic(m.group('S2'), m.group('U2')) - self.parse_traffic(m.group('S1'), m.group('U1') or "B") - - except Exception, e: - self.log_error(e, trace=True) - else: - self.log_debug("TRAFFIC_LEFT_PATTERN not found") + if premium: + validuntil = time.mktime(time.strptime(data['result']['expiryDate'], '%Y-%m-%d %H:%M:%S')) return {'validuntil' : validuntil, 'trafficleft': trafficleft, @@ -72,42 +41,9 @@ class NitroflareCom(Account): def signin(self, user, password, data): - login_url = "https://nitroflare.com/login" - - self.data = self.load(login_url) - if "document.location.href='logout'" in self.data: - self.skip_login() + data = json.loads(self.load("https://nitroflare.com/api/v2/getKeyInfo", + get={'user' : user, + 'premiumKey': password})) - post_data = {'login' : "", - 'email' : user, - 'password': password} - - # dummy pyfile - pyfile = PyFile(self.pyload.files, -1, login_url, login_url, 0, 0, "", self.classname, -1, -1) - pyfile.plugin = self - - self.captcha = ReCaptcha(pyfile) - - captcha_key = self.captcha.detect_key() - if captcha_key: - response, challenge = self.captcha.challenge() - post_data['g-recaptcha-response'] = response - - token = re.search(self.TOKEN_PATTERN, self.data).group(1) - post_data['token'] = token - - self.data = self.load(login_url, post=post_data) - - if re.search(self.LOGIN_FAIL_PATTERN, self.data): + if data['type'] != 'success' or data['result']['status'] == "banned": self.fail_login() - - """ - @NOTE: below are methods - necessary for captcha to work with account plugins - """ - def check_status(self): - pass - - def retry_captcha(self, attemps=10, wait=1, msg=_("Max captcha retries reached")): - self.captcha.invalid() - self.fail_login(msg="Invalid captcha") diff --git a/module/plugins/hoster/NitroflareCom.py b/module/plugins/hoster/NitroflareCom.py index e08c0e603..6ef8186c5 100644 --- a/module/plugins/hoster/NitroflareCom.py +++ b/module/plugins/hoster/NitroflareCom.py @@ -2,14 +2,16 @@ import re +from module.network.RequestFactory import getURL as get_url from module.plugins.captcha.ReCaptcha import ReCaptcha +from module.plugins.internal.misc import json from module.plugins.internal.SimpleHoster import SimpleHoster class NitroflareCom(SimpleHoster): __name__ = "NitroflareCom" __type__ = "hoster" - __version__ = "0.21" + __version__ = "0.22" __status__ = "testing" __pattern__ = r'https?://(?:www\.)?nitroflare\.com/view/(?P<ID>[\w^_]+)' @@ -30,6 +32,7 @@ class NitroflareCom(SimpleHoster): OFFLINE_PATTERN = r'>File doesn\'t exist' LINK_PREMIUM_PATTERN = LINK_FREE_PATTERN = r'(https?://[\w\-]+\.nitroflare\.com/.+?)"' + FILE_ID_PATTERN = r'https?://(?:www\.)?nitroflare\.com/view/(?P<ID>[\w^_]+)' DIRECT_LINK = False RECAPTCHA_KEY = "6Lenx_USAAAAAF5L1pmTWvWcH73dipAEzNnmNLgy" @@ -38,9 +41,28 @@ class NitroflareCom(SimpleHoster): # ERROR_PATTERN = r'downloading is not possible' + @classmethod + def api_info(cls, url): + info = {} + file_id = re.search(cls.__pattern__, url).group('ID') + + data = json.loads(get_url("https://nitroflare.com/api/v2/getFileInfo", + get={'files': file_id}, + decode=True)) + + if data['type'] == 'success': + fileinfo = data['result']['files'][file_id] + info['status'] = 2 if fileinfo['status'] == 'online' else 1 + info['name'] = fileinfo['name'] + info['size'] = fileinfo['size'] #: In bytes + + return info + + def handle_free(self, pyfile): #: Used here to load the cookies which will be required later - self.load("http://nitroflare.com/ajax/setCookie.php", post={'fileId': self.info['pattern']['ID']}) + self.load("http://nitroflare.com/ajax/setCookie.php", + post={'fileId': self.info['pattern']['ID']}) self.load(pyfile.url, post={'goToFreePage': ""}) @@ -72,3 +94,15 @@ class NitroflareCom(SimpleHoster): self.retry_captcha() return super(NitroflareCom, self).handle_free(pyfile) + + + def handle_premium(self, pyfile): + data = json.loads(self.load("https://nitroflare.com/api/v2/getDownloadLink", + get={'file' : self.info['pattern']['ID'], + 'user' : self.account.user, + 'premiumKey': self.account.get_login('password')})) + + if data['type'] == 'success': + pyfile.name = data['result']['name'] + pyfile.size = int(data['result']['size']) + self.link = data['result']['url'] |