summaryrefslogtreecommitdiffstats
path: root/module/plugins/internal/SimpleCrypter.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/internal/SimpleCrypter.py')
-rw-r--r--module/plugins/internal/SimpleCrypter.py42
1 files changed, 25 insertions, 17 deletions
diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py
index b843a28f0..81f977e57 100644
--- a/module/plugins/internal/SimpleCrypter.py
+++ b/module/plugins/internal/SimpleCrypter.py
@@ -11,7 +11,7 @@ from module.utils import fixup, html_unescape
class SimpleCrypter(Crypter, SimpleHoster):
__name__ = "SimpleCrypter"
__type__ = "crypter"
- __version__ = "0.46"
+ __version__ = "0.49"
__pattern__ = r'^unmatchable$'
__config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True), #: Overrides core.config['general']['folder_per_package']
@@ -55,15 +55,6 @@ class SimpleCrypter(Crypter, SimpleHoster):
LINK_PATTERN = None
- NAME_REPLACEMENTS = [("&#?\w+;", fixup)]
- URL_REPLACEMENTS = []
-
- TEXT_ENCODING = False #: Set to True or encoding name if encoding in http header is not correct
- COOKIES = True #: or False or list of tuples [(domain, name, value)]
-
- LOGIN_ACCOUNT = False
- LOGIN_PREMIUM = False
-
#@TODO: Remove in 0.4.10
def init(self):
@@ -83,6 +74,7 @@ class SimpleCrypter(Crypter, SimpleHoster):
self.info = {}
self.html = ""
+ self.link = "" #@TODO: Move to hoster class in 0.4.10
self.links = [] #@TODO: Move to hoster class in 0.4.10
if self.LOGIN_PREMIUM and not self.premium:
@@ -99,18 +91,34 @@ class SimpleCrypter(Crypter, SimpleHoster):
self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS)
+ def handleDirect(self, pyfile):
+ while True:
+ header = self.load(self.link or pyfile.url, just_header=True, decode=True)
+ if 'location' in header and header['location']:
+ self.link = header['location']
+ else:
+ break
+
+
def decrypt(self, pyfile):
self.prepare()
- self.preload()
- self.checkInfo()
+ self.logDebug("Looking for link redirect...")
+ self.handleDirect(pyfile)
+
+ if self.link:
+ self.urls = [self.link]
+
+ else:
+ self.preload()
+ self.checkInfo()
- self.links = self.getLinks()
+ self.links = self.getLinks()
- if hasattr(self, 'PAGES_PATTERN') and hasattr(self, 'loadPage'):
- self.handlePages(pyfile)
+ if hasattr(self, 'PAGES_PATTERN') and hasattr(self, 'loadPage'):
+ self.handlePages(pyfile)
- self.logDebug("Package has %d links" % len(self.links))
+ self.logDebug("Package has %d links" % len(self.links))
if self.links:
self.packages = [(self.info['name'], self.links, self.info['folder'])]
@@ -155,7 +163,7 @@ class SimpleCrypter(Crypter, SimpleHoster):
links = [urlparse.urljoin(baseurl, link) if not urlparse.urlparse(link).scheme else link \
for link in re.findall(self.LINK_PATTERN, self.html)]
- return [html_unescape(l.strip().decode('unicode-escape')) for l in links]
+ return [html_unescape(l.decode('unicode-escape').strip()) for l in links]
def handlePages(self, pyfile):