From ff581d9a4a1637b4e06bcbe77d67591f9279fe1b Mon Sep 17 00:00:00 2001 From: Stefano Date: Sun, 21 Jul 2013 15:03:21 +0200 Subject: Fixed PEP 8 violations in Crypters (cherry-picked from 4b61d36bf18931df0a9720047b3619ce245f8a1b) --- pyload/plugins/crypter/LinkSaveIn.py | 61 ++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 30 deletions(-) (limited to 'pyload/plugins/crypter/LinkSaveIn.py') diff --git a/pyload/plugins/crypter/LinkSaveIn.py b/pyload/plugins/crypter/LinkSaveIn.py index e021316bf..a73b7cc19 100644 --- a/pyload/plugins/crypter/LinkSaveIn.py +++ b/pyload/plugins/crypter/LinkSaveIn.py @@ -6,13 +6,15 @@ # * only best available link source is used (priority: cnl2>rsdf>ccf>dlc>web # -from Crypto.Cipher import AES -from module.plugins.Crypter import Crypter -from module.unescape import unescape import base64 import binascii import re +from Crypto.Cipher import AES +from module.plugins.Crypter import Crypter +from module.unescape import unescape + + class LinkSaveIn(Crypter): __name__ = "LinkSaveIn" __type__ = "crypter" @@ -26,31 +28,31 @@ class LinkSaveIn(Crypter): _JK_KEY_ = "jk" _CRYPTED_KEY_ = "crypted" HOSTER_DOMAIN = "linksave.in" - + def setup(self): self.html = None self.fileid = None self.captcha = False self.package = None self.preferred_sources = ['cnl2', 'rsdf', 'ccf', 'dlc', 'web'] - + def decrypt(self, pyfile): # Init self.package = pyfile.package() self.fileid = re.match(self.__pattern__, pyfile.url).group('id') self.req.cj.setCookie(self.HOSTER_DOMAIN, "Linksave_Language", "english") - + # Request package self.html = self.load(self.pyfile.url) if not self.isOnline(): self.offline() - + # Check for protection if self.isPasswordProtected(): self.unlockPasswordProtection() self.handleErrors() - + if self.isCaptchaProtected(): self.captcha = True self.unlockCaptchaProtection() @@ -78,49 +80,49 @@ class LinkSaveIn(Crypter): self.logDebug("File not found") return False return True - + def isPasswordProtected(self): if re.search(r'''Captcha:" in self.html: self.logDebug("Links are captcha protected") return True return False - + def unlockPasswordProtection(self): password = self.getPassword() self.logDebug("Submitting password [%s] for protected links" % password) post = {"id": self.fileid, "besucherpasswort": password, 'login': 'submit'} self.html = self.load(self.pyfile.url, post=post) - + def unlockCaptchaProtection(self): captcha_hash = re.search(r'name="hash" value="([^"]+)', self.html).group(1) captcha_url = re.search(r'src=".(/captcha/cap.php\?hsh=[^"]+)', self.html).group(1) captcha_code = self.decryptCaptcha("http://linksave.in" + captcha_url, forceUser=True) - self.html = self.load(self.pyfile.url, post={"id": self.fileid, "hash": captcha_hash, "code": captcha_code}) + self.html = self.load(self.pyfile.url, post={"id": self.fileid, "hash": captcha_hash, "code": captcha_code}) def getPackageInfo(self): name = self.pyfile.package().name folder = self.pyfile.package().folder self.logDebug("Defaulting to pyfile name [%s] and folder [%s] for package" % (name, folder)) return name, folder - - def handleErrors(self): + + def handleErrors(self): if "The visitorpassword you have entered is wrong" in self.html: self.logDebug("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") + self.fail("Incorrect password, please set right password on 'Edit package' form and retry") - if self.captcha: + if self.captcha: if "Wrong code. Please retry" in self.html: self.logDebug("Invalid captcha, retrying") self.invalidCaptcha() self.retry() else: self.correctCaptcha() - + def handleLinkSource(self, type_): if type_ == 'cnl2': return self.handleCNL2() @@ -136,15 +138,15 @@ class LinkSaveIn(Crypter): self.logDebug("Search for Web links") if not self.js: self.logDebug("no JS -> skip Web links") - else: - #@TODO: Gather paginated web links + else: + #@TODO: Gather paginated web links pattern = r'(.*)', response)[-1] @@ -155,9 +157,9 @@ class LinkSaveIn(Crypter): link = unescape(re.search(r'