diff options
Diffstat (limited to 'module/plugins')
| -rw-r--r-- | module/plugins/hoster/NitroflareCom.py | 93 | 
1 files changed, 46 insertions, 47 deletions
| diff --git a/module/plugins/hoster/NitroflareCom.py b/module/plugins/hoster/NitroflareCom.py index caae2f8b0..722fb6eaf 100644 --- a/module/plugins/hoster/NitroflareCom.py +++ b/module/plugins/hoster/NitroflareCom.py @@ -16,7 +16,7 @@ from module.plugins.internal.SimpleHoster import SimpleHoster  class NitroflareCom(SimpleHoster):      __name__    = "NitroflareCom"      __type__    = "hoster" -    __version__ = "0.05" +    __version__ = "0.06"      __pattern__ = r'https?://(?:www\.)?nitroflare\.com/view/(?P<ID>[\w^_]+)' @@ -30,71 +30,70 @@ class NitroflareCom(SimpleHoster):      INFO_PATTERN    = r'title="(?P<N>.+?)".+>(?P<S>[\d.,]+) (?P<U>[\w^_]+)'      OFFLINE_PATTERN = r'>File doesn\'t exist' -    LINK_FREE_PATTERN = r'(https?://[\w\\-]+\\.nitroflare\\.com/.+?)"' +    LINK_FREE_PATTERN = r'(https?://[\w\-]+\.nitroflare\.com/.+?)"' +    PREMIUM_ONLY_PATTERN = r'This file is available with Premium only' +    WAIT_PATTERN         = r'You have to wait .+?<' +    ERROR_PATTERN        = r'downloading is not possible' -    def handleFree(self, pyfile): -        file_info = self.load("https://nitroflare.com/api/getDownloadLink", -                              get={'file': self.info['pattern']['ID']}) - -        self.logDebug(file_info[3:]) -        file_info = json_loads(file_info[3:])  #: removing non ascii characters -        if file_info['type'] != "success": +    def checkErrors(self): +        if not self.html:              return -        result = file_info['result']  #: already a dict -        if result['linkType'] != "free": -            return +        if not self.premium and re.search(self.PREMIUM_ONLY_PATTERN, self.html): +            self.fail(_("Link require a premium account to be handled")) + +        elif hasattr(self, 'WAIT_PATTERN'): +            m = re.search(self.WAIT_PATTERN, self.html) +            if m: +                wait_time = sum([int(v) * {"hr": 3600, "hour": 3600, "min": 60, "sec": 1}[u.lower()] for v, u in +                                 re.findall(r'(\d+)\s*(hr|hour|min|sec)', m.group(0), re.I)]) +                self.wait(wait_time, wait_time > 300) +                return + +        elif hasattr(self, 'ERROR_PATTERN'): +            m = re.search(self.ERROR_PATTERN, self.html) +            if m: +                errmsg = self.info['error'] = m.group(1) +                self.error(errmsg) -        # delay      = int(result['delay']) -        captcha_key = result['recaptchaPublic'] -        filename    = result['name'] -        recaptcha   = ReCaptcha(self) +        self.info.pop('error', None) + +    def handleFree(self, pyfile):          # used here to load the cookies which will be required later -        self.load(pyfile.url)          self.load(pyfile.url, post={'goToFreePage': ""})          self.html = self.load("http://nitroflare.com/ajax/freeDownload.php",                                post={'method': "startTimer", 'fileId': self.info['pattern']['ID']})[4:] -        if "This file is available with premium key only" in self.html: -            self.fail("This file is available with premium key only") +        self.checkErrors() -        elif "downloading is not possible" in self.html: -            wait_time = re.search("You have to wait (\\d+) minutes to download your next file", self.html) -            if wait_time: -                self.wait(wait_time, True) -            else: -                self.fail("Downloading is not possible") +        try: +            js_file   = self.load("http://nitroflare.com/js/downloadFree.js?v=1.0.1") +            var_time  = re.search("var time = (\\d+);", js_file) +            wait_time = int(var_time.groups()[0]) -        else: -            self.logDebug(self.html) +        except Exception: +            wait_time = 60 -            try: -                js_file   = self.load("http://nitroflare.com/js/downloadFree.js?v=1.0.1") -                var_time  = re.search("var time = (\\d+);", js_file) -                wait_time = int(var_time.groups()[0]) +        self.wait(wait_time) -            except Exception: -                wait_time = 60 +        recaptcha = ReCaptcha(self) +        challenge, response = recaptcha.challenge("6Lenx_USAAAAAF5L1pmTWvWcH73dipAEzNnmNLgy") -            self.wait(wait_time) - -            challenge, response = recaptcha.challenge(captcha_key) - -            self.html = self.load("http://nitroflare.com/ajax/freeDownload.php", -                                  post={'method'                   : "fetchDownload", -                                        'recaptcha_challenge_field': challenge, -                                        'recaptcha_response_field' : response})[3:] +        self.html = self.load("http://nitroflare.com/ajax/freeDownload.php", +                              post={'method'                   : "fetchDownload", +                                    'recaptcha_challenge_field': challenge, +                                    'recaptcha_response_field' : response})[3:] -            self.logDebug(self.html) +        self.logDebug(self.html) -            if "The captcha wasn't entered correctly" in self.html -                return +        if "The captcha wasn't entered correctly" in self.html: +            return -            if "You have to fill the captcha" in self.html: -                return +        if "You have to fill the captcha" in self.html: +            return -            self.link = re.search(self.LINK_FREE_PATTERN, self.html) +        self.link = re.search(self.LINK_FREE_PATTERN, self.html) | 
