summaryrefslogtreecommitdiffstats
path: root/pyload/plugins/crypter/LinkSaveIn.py
diff options
context:
space:
mode:
authorGravatar Stefano <l.stickell@yahoo.it> 2013-07-21 15:03:21 +0200
committerGravatar Stefano <l.stickell@yahoo.it> 2013-07-21 15:43:18 +0200
commitff581d9a4a1637b4e06bcbe77d67591f9279fe1b (patch)
tree0be4883b505aecc6920bdfccfcc9672636d59691 /pyload/plugins/crypter/LinkSaveIn.py
parentImproved .gitattributes (diff)
downloadpyload-ff581d9a4a1637b4e06bcbe77d67591f9279fe1b.tar.xz
Fixed PEP 8 violations in Crypters
Diffstat (limited to 'pyload/plugins/crypter/LinkSaveIn.py')
-rw-r--r--pyload/plugins/crypter/LinkSaveIn.py61
1 files changed, 31 insertions, 30 deletions
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'''<input.*?type="password"''', self.html):
self.logDebug("Links are password protected")
return True
-
+
def isCaptchaProtected(self):
if "<b>Captcha:</b>" 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'<a href="http://linksave\.in/(\w{43})"'
ids = re.findall(pattern, self.html)
self.logDebug("Decrypting %d Web links" % len(ids))
for i, weblink_id in enumerate(ids):
try:
webLink = "http://linksave.in/%s" % weblink_id
- self.logDebug("Decrypting Web link %d, %s" % (i+1, webLink))
+ self.logDebug("Decrypting Web link %d, %s" % (i + 1, webLink))
fwLink = "http://linksave.in/fw-%s" % weblink_id
response = self.load(fwLink)
jscode = re.findall(r'<script type="text/javascript">(.*)</script>', response)[-1]
@@ -155,9 +157,9 @@ class LinkSaveIn(Crypter):
link = unescape(re.search(r'<iframe src="(.+?)"', response).group(1))
package_links.append(link)
except Exception, detail:
- self.logDebug("Error decrypting Web link %s, %s" % (webLink, detail))
+ self.logDebug("Error decrypting Web link %s, %s" % (webLink, detail))
return package_links
-
+
def handleContainer(self, type_):
package_links = []
type_ = type_.lower()
@@ -183,17 +185,17 @@ class LinkSaveIn(Crypter):
for (crypted, jk) in zip(vcrypted, vjk):
package_links.extend(self._getLinks(crypted, jk))
except:
- self.fail("Unable to decrypt CNL2 links")
+ self.fail("Unable to decrypt CNL2 links")
return package_links
-
+
def _getCipherParams(self):
-
+
# Get jk
- jk_re = r'<INPUT.*?NAME="%s".*?VALUE="(.*?)"' % LinkSaveIn._JK_KEY_
+ jk_re = r'<INPUT.*?NAME="%s".*?VALUE="(.*?)"' % LinkSaveIn._JK_KEY_
vjk = re.findall(jk_re, self.html)
-
+
# Get crypted
- crypted_re = r'<INPUT.*?NAME="%s".*?VALUE="(.*?)"' % LinkSaveIn._CRYPTED_KEY_
+ crypted_re = r'<INPUT.*?NAME="%s".*?VALUE="(.*?)"' % LinkSaveIn._CRYPTED_KEY_
vcrypted = re.findall(crypted_re, self.html)
# Log and return
@@ -224,4 +226,3 @@ class LinkSaveIn(Crypter):
# Log and return
self.logDebug("Package has %d links" % len(links))
return links
-