summaryrefslogtreecommitdiffstats
path: root/module/plugins/hoster/NitroflareCom.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hoster/NitroflareCom.py')
-rw-r--r--module/plugins/hoster/NitroflareCom.py99
1 files changed, 41 insertions, 58 deletions
diff --git a/module/plugins/hoster/NitroflareCom.py b/module/plugins/hoster/NitroflareCom.py
index 2367493e5..a0734d9b1 100644
--- a/module/plugins/hoster/NitroflareCom.py
+++ b/module/plugins/hoster/NitroflareCom.py
@@ -1,79 +1,62 @@
# -*- coding: utf-8 -*-
-#
-# Note:
-# Right now premium support is not added
-# Thus, any file that require premium support
-# cannot be downloaded. Only the file that is free to
-# download can be downloaded.
import re
-from module.common.json_layer import json_loads
-from module.plugins.internal.CaptchaService import ReCaptcha
+from module.plugins.internal.ReCaptcha import ReCaptcha
from module.plugins.internal.SimpleHoster import SimpleHoster
class NitroflareCom(SimpleHoster):
__name__ = "NitroflareCom"
__type__ = "hoster"
- __version__ = "0.03"
+ __version__ = "0.14"
__pattern__ = r'https?://(?:www\.)?nitroflare\.com/view/(?P<ID>[\w^_]+)'
+ __config__ = [("use_premium", "bool", "Use premium account if available", True)]
__description__ = """Nitroflare.com hoster plugin"""
__license__ = "GPLv3"
- __authors__ = [("sahil", ""),
- ("Walter Purcaro", "vuolter@gmail.com")]
+ __authors__ = [("sahil" , "sahilshekhawat01@gmail.com"),
+ ("Walter Purcaro", "vuolter@gmail.com" ),
+ ("Stickell" , "l.stickell@yahoo.it" )]
+ INFO_PATTERN = r'title="(?P<N>.+?)".+>(?P<S>[\d.,]+) (?P<U>[\w^_]+)'
+ OFFLINE_PATTERN = r'>File doesn\'t exist'
- # URL_REPLACEMENTS = [("http://", "https://")]
+ LINK_PREMIUM_PATTERN = LINK_FREE_PATTERN = r'(https?://[\w\-]+\.nitroflare\.com/.+?)"'
- LINK_FREE_PATTERN = r'(https?://[\w\\-]+\\.nitroflare\\.com/[^<>\"]*?)"'
+ RECAPTCHA_KEY = "6Lenx_USAAAAAF5L1pmTWvWcH73dipAEzNnmNLgy"
+ PREMIUM_ONLY_PATTERN = r'This file is available with Premium only'
+ WAIT_PATTERN = r'You have to wait (\d+ minutes)'
+ # 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.logWarning(file_info[3:])
- file_info = json_loads(file_info[3:]) # removing non ascii characters
- if file_info['type'] == "success":
- result = file_info['result'] # already a dict
- if result['linkType'] == "free":
- delay = result['delay'] # Don't need the delay for free downloads
- captch_key = result['recaptchaPublic']
- filename = result['name']
- recaptcha = ReCaptcha(self)
- # try upto 3 times to solve reCaptcha
- for i in xrange(3):
- challenge, response = recaptcha.challenge(key=captch_key)
- res = self.load("https://nitroflare.com/ajax/freeDownload.php",
- post={"method": "fetchDownload",
- "recaptcha_challenge_field": challenge,
- "recaptcha_response_field": response})
- if self.handleCaptchaErrors(res):
- break
- if "The captcha wasn't entered correctly" or "You have to fill the captcha" in res:
- continue
- else:
- break
-
- if "The captcha wasn't entered correctly" or "You have to fill the captcha" in res:
- self.logError("Captcha Failed")
- self.offline()
- # Captcha failed
- else:
- self.logInfo("result of the captcha is")
- self.logInfo(res)
- # self.offline()
- download_link = re.search(self.DOWNLOAD_PATTERN, res)
- if download_link is None:
- print "downloasd link failed"
- # Download link failed
- else:
- self.download(download_link)
- else:
- print "link is invalid"
- self.offline()
- # Link is invalid
- # self.download()
+ # used here to load the cookies which will be required later
+ self.load(pyfile.url, post={'goToFreePage': ""})
+
+ self.load("http://nitroflare.com/ajax/setCookie.php", post={'fileId': self.info['pattern']['ID']})
+ self.html = self.load("http://nitroflare.com/ajax/freeDownload.php",
+ post={'method': "startTimer", 'fileId': self.info['pattern']['ID']})
+
+ self.checkErrors()
+
+ 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])
+
+ except Exception:
+ wait_time = 60
+
+ self.wait(wait_time)
+
+ recaptcha = ReCaptcha(self)
+ response, challenge = recaptcha.challenge(self.RECAPTCHA_KEY)
+
+ self.html = self.load("http://nitroflare.com/ajax/freeDownload.php",
+ post={'method' : "fetchDownload",
+ 'recaptcha_challenge_field': challenge,
+ 'recaptcha_response_field' : response})
+
+ return super(NitroflareCom, self).handleFree(pyfile)