summaryrefslogtreecommitdiffstats
path: root/module/plugins/crypter/NCryptIn.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/crypter/NCryptIn.py')
-rw-r--r--module/plugins/crypter/NCryptIn.py142
1 files changed, 71 insertions, 71 deletions
diff --git a/module/plugins/crypter/NCryptIn.py b/module/plugins/crypter/NCryptIn.py
index ec43d7fa9..8abf06602 100644
--- a/module/plugins/crypter/NCryptIn.py
+++ b/module/plugins/crypter/NCryptIn.py
@@ -12,7 +12,7 @@ from module.plugins.internal.ReCaptcha import ReCaptcha
class NCryptIn(Crypter):
__name__ = "NCryptIn"
__type__ = "crypter"
- __version__ = "1.36"
+ __version__ = "1.37"
__pattern__ = r'http://(?:www\.)?ncrypt\.in/(?P<TYPE>folder|link|frame)-([^/\?]+)'
__config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True),
@@ -32,7 +32,7 @@ class NCryptIn(Crypter):
def setup(self):
self.package = None
- self.cleanedHtml = None
+ self.cleaned_html = None
self.links_source_order = ["cnl2", "rsdf", "ccf", "dlc", "web"]
self.protection_type = None
@@ -45,30 +45,30 @@ class NCryptIn(Crypter):
folder_name = self.package.folder
#: Deal with single links
- if self.isSingleLink():
- package_links.extend(self.handleSingleLink())
+ if self.is_single_link():
+ package_links.extend(self.handle_single_link())
#: Deal with folders
else:
#: Request folder home
- self.html = self.requestFolderHome()
- self.cleanedHtml = self.removeHtmlCrap(self.html)
- if not self.isOnline():
+ self.html = self.request_folder_home()
+ self.cleaned_html = self.remove_html_crap(self.html)
+ if not self.is_online():
self.offline()
#: Check for folder protection
- if self.isProtected():
- self.html = self.unlockProtection()
- self.cleanedHtml = self.removeHtmlCrap(self.html)
- self.handleErrors()
+ if self.is_protected():
+ self.html = self.unlock_protection()
+ self.cleaned_html = self.remove_html_crap(self.html)
+ self.handle_errors()
#: Prepare package name and folder
- (package_name, folder_name) = self.getPackageInfo()
+ (package_name, folder_name) = self.get_package_info()
#: Extract package links
for link_source_type in self.links_source_order:
- package_links.extend(self.handleLinkSource(link_source_type))
+ package_links.extend(self.handle_link_source(link_source_type))
if package_links: #: use only first source which provides links
break
package_links = set(package_links)
@@ -78,16 +78,16 @@ class NCryptIn(Crypter):
self.packages = [(package_name, package_links, folder_name)]
- def isSingleLink(self):
+ def is_single_link(self):
link_type = re.match(self.__pattern__, self.pyfile.url).group('TYPE')
return link_type in ("link", "frame")
- def requestFolderHome(self):
+ def request_folder_home(self):
return self.load(self.pyfile.url)
- def removeHtmlCrap(self, content):
+ def remove_html_crap(self, content):
patterns = (r'(type="hidden".*?(name=".*?")?.*?value=".*?")',
r'display:none;">(.*?)</(div|span)>',
r'<div\s+class="jdownloader"(.*?)</div>',
@@ -99,61 +99,61 @@ class NCryptIn(Crypter):
return content
- def isOnline(self):
- if "Your folder does not exist" in self.cleanedHtml:
- self.logDebug("File not m")
+ def is_online(self):
+ if "Your folder does not exist" in self.cleaned_html:
+ self.log_debug("File not m")
return False
return True
- def isProtected(self):
- form = re.search(r'<form.*?name.*?protected.*?>(.*?)</form>', self.cleanedHtml, re.S)
+ def is_protected(self):
+ form = re.search(r'<form.*?name.*?protected.*?>(.*?)</form>', self.cleaned_html, re.S)
if form:
content = form.group(1)
for keyword in ("password", "captcha"):
if keyword in content:
self.protection_type = keyword
- self.logDebug("Links are %s protected" % self.protection_type)
+ self.log_debug("Links are %s protected" % self.protection_type)
return True
return False
- def getPackageInfo(self):
+ def get_package_info(self):
m = re.search(self.NAME_PATTERN, self.html)
if m:
name = folder = m.group('N').strip()
- self.logDebug("Found name [%s] and folder [%s] in package info" % (name, folder))
+ self.log_debug("Found name [%s] and folder [%s] in package info" % (name, folder))
else:
name = self.package.name
folder = self.package.folder
- self.logDebug("Package info not m, defaulting to pyfile name [%s] and folder [%s]" % (name, folder))
+ self.log_debug("Package info not m, defaulting to pyfile name [%s] and folder [%s]" % (name, folder))
return name, folder
- def unlockProtection(self):
+ def unlock_protection(self):
postData = {}
- form = re.search(r'<form name="protected"(.*?)</form>', self.cleanedHtml, re.S).group(1)
+ form = re.search(r'<form name="protected"(.*?)</form>', self.cleaned_html, re.S).group(1)
#: Submit package password
if "password" in form:
- password = self.getPassword()
- self.logDebug("Submitting password [%s] for protected links" % password)
+ password = self.get_password()
+ self.log_debug("Submitting password [%s] for protected links" % password)
postData['password'] = password
#: Resolve anicaptcha
if "anicaptcha" in form:
- self.logDebug("Captcha protected")
+ self.log_debug("Captcha protected")
captchaUri = re.search(r'src="(/temp/anicaptcha/.+?)"', form).group(1)
- captcha = self.decryptCaptcha("http://ncrypt.in" + captchaUri)
- self.logDebug("Captcha resolved [%s]" % captcha)
+ captcha = self.decrypt_captcha("http://ncrypt.in" + captchaUri)
+ self.log_debug("Captcha resolved [%s]" % captcha)
postData['captcha'] = captcha
#: Resolve recaptcha
if "recaptcha" in form:
- self.logDebug("ReCaptcha protected")
+ self.log_debug("ReCaptcha protected")
captcha_key = re.search(r'\?k=(.*?)"', form).group(1)
- self.logDebug("Resolving ReCaptcha with key [%s]" % captcha_key)
+ self.log_debug("Resolving ReCaptcha with key [%s]" % captcha_key)
recaptcha = ReCaptcha(self)
response, challenge = recaptcha.challenge(captcha_key)
postData['recaptcha_challenge_field'] = challenge
@@ -161,10 +161,10 @@ class NCryptIn(Crypter):
#: Resolve circlecaptcha
if "circlecaptcha" in form:
- self.logDebug("CircleCaptcha protected")
+ self.log_debug("CircleCaptcha protected")
captcha_img_url = "http://ncrypt.in/classes/captcha/circlecaptcha.php"
- coords = self.decryptCaptcha(captcha_img_url, forceUser=True, imgtype="png", result_type='positional')
- self.logDebug("Captcha resolved, coords [%s]" % str(coords))
+ coords = self.decrypt_captcha(captcha_img_url, forceUser=True, imgtype="png", result_type='positional')
+ self.log_debug("Captcha resolved, coords [%s]" % str(coords))
postData['circle.x'] = coords[0]
postData['circle.y'] = coords[1]
@@ -173,74 +173,74 @@ class NCryptIn(Crypter):
return self.load(self.pyfile.url, post=postData)
- def handleErrors(self):
+ def handle_errors(self):
if self.protection_type == "password":
- if "This password is invalid!" in self.cleanedHtml:
- self.logDebug("Incorrect password, please set right password on 'Edit package' form and retry")
+ if "This password is invalid!" in self.cleaned_html:
+ self.log_debug("Incorrect password, please set right password on 'Edit package' form and retry")
self.fail(_("Incorrect password, please set right password on 'Edit package' form and retry"))
if self.protection_type == "captcha":
- if "The securitycheck was wrong!" in self.cleanedHtml:
- self.invalidCaptcha()
+ if "The securitycheck was wrong!" in self.cleaned_html:
+ self.invalid_captcha()
self.retry()
else:
- self.correctCaptcha()
+ self.correct_captcha()
- def handleLinkSource(self, link_source_type):
+ def handle_link_source(self, link_source_type):
#: Check for JS engine
require_js_engine = link_source_type in ("cnl2", "rsdf", "ccf", "dlc")
if require_js_engine and not self.js:
- self.logDebug("No JS engine available, skip %s links" % link_source_type)
+ self.log_debug("No JS engine available, skip %s links" % link_source_type)
return []
#: Select suitable handler
if link_source_type == 'single':
- return self.handleSingleLink()
+ return self.handle_single_link()
if link_source_type == 'cnl2':
- return self.handleCNL2()
+ return self.handle_CNL2()
elif link_source_type in ("rsdf", "ccf", "dlc"):
- return self.handleContainer(link_source_type)
+ return self.handle_container(link_source_type)
elif link_source_type == "web":
- return self.handleWebLinks()
+ return self.handle_web_links()
else:
self.error(_('Unknown source type "%s"') % link_source_type)
- def handleSingleLink(self):
- self.logDebug("Handling Single link")
+ def handle_single_link(self):
+ self.log_debug("Handling Single link")
package_links = []
#: Decrypt single link
- decrypted_link = self.decryptLink(self.pyfile.url)
+ decrypted_link = self.decrypt_link(self.pyfile.url)
if decrypted_link:
package_links.append(decrypted_link)
return package_links
- def handleCNL2(self):
- self.logDebug("Handling CNL2 links")
+ def handle_CNL2(self):
+ self.log_debug("Handling CNL2 links")
package_links = []
- if 'cnl2_output' in self.cleanedHtml:
+ if 'cnl2_output' in self.cleaned_html:
try:
- (vcrypted, vjk) = self._getCipherParams()
+ (vcrypted, vjk) = self._get_cipher_params()
for (crypted, jk) in zip(vcrypted, vjk):
- package_links.extend(self._getLinks(crypted, jk))
+ package_links.extend(self._get_links(crypted, jk))
except Exception:
self.fail(_("Unable to decrypt CNL2 links"))
return package_links
- def handleContainers(self):
- self.logDebug("Handling Container links")
+ def handle_containers(self):
+ self.log_debug("Handling Container links")
package_links = []
pattern = r'/container/(rsdf|dlc|ccf)/(\w+)'
containersLinks = re.findall(pattern, self.html)
- self.logDebug("Decrypting %d Container links" % len(containersLinks))
+ self.log_debug("Decrypting %d Container links" % len(containersLinks))
for containerLink in containersLinks:
link = "http://ncrypt.in/container/%s/%s.%s" % (containerLink[0], containerLink[1], containerLink[0])
package_links.append(link)
@@ -248,15 +248,15 @@ class NCryptIn(Crypter):
return package_links
- def handleWebLinks(self):
- self.logDebug("Handling Web links")
+ def handle_web_links(self):
+ self.log_debug("Handling Web links")
pattern = r'(http://ncrypt\.in/link-.*?=)'
links = re.findall(pattern, self.html)
package_links = []
- self.logDebug("Decrypting %d Web links" % len(links))
+ self.log_debug("Decrypting %d Web links" % len(links))
for i, link in enumerate(links):
- self.logDebug("Decrypting Web link %d, %s" % (i + 1, link))
+ self.log_debug("Decrypting Web link %d, %s" % (i + 1, link))
decrypted_link = self.decrypt(link)
if decrypted_link:
package_links.append(decrypted_link)
@@ -264,16 +264,16 @@ class NCryptIn(Crypter):
return package_links
- def decryptLink(self, link):
+ def decrypt_link(self, link):
try:
url = link.replace("link-", "frame-")
link = self.load(url, just_header=True)['location']
return link
except Exception, detail:
- self.logDebug("Error decrypting link %s, %s" % (link, detail))
+ self.log_debug("Error decrypting link %s, %s" % (link, detail))
- def _getCipherParams(self):
+ def _get_cipher_params(self):
pattern = r'<input.*?name="%s".*?value="(.*?)"'
#: Get jk
@@ -285,14 +285,14 @@ class NCryptIn(Crypter):
vcrypted = re.findall(crypted_re, self.html)
#: Log and return
- self.logDebug("Detected %d crypted blocks" % len(vcrypted))
+ self.log_debug("Detected %d crypted blocks" % len(vcrypted))
return vcrypted, vjk
- def _getLinks(self, crypted, jk):
+ def _get_links(self, crypted, jk):
#: Get key
jreturn = self.js.eval("%s f()" % jk)
- self.logDebug("JsEngine returns value [%s]" % jreturn)
+ self.log_debug("JsEngine returns value [%s]" % jreturn)
key = binascii.unhexlify(jreturn)
#: Decrypt
@@ -306,5 +306,5 @@ class NCryptIn(Crypter):
links = filter(bool, text.split('\n'))
#: Log and return
- self.logDebug("Block has %d links" % len(links))
+ self.log_debug("Block has %d links" % len(links))
return links