diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-30 03:55:01 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-30 03:55:01 +0200 |
commit | 10ed9dbcee2c996dd348db4ad57d824c9d454005 (patch) | |
tree | dea6aacb9e2cab930bc6d21c8456fd56e9d3fa1d /module | |
parent | Update plugins after splitting CaptchaService (diff) | |
download | pyload-10ed9dbcee2c996dd348db4ad57d824c9d454005.tar.xz |
[Dereferer][SimpleDereferer] Update
Diffstat (limited to 'module')
-rw-r--r-- | module/plugins/crypter/Dereferer.py | 33 | ||||
-rw-r--r-- | module/plugins/internal/SimpleDereferer.py | 30 |
2 files changed, 48 insertions, 15 deletions
diff --git a/module/plugins/crypter/Dereferer.py b/module/plugins/crypter/Dereferer.py index 8427c1540..8e56a7bfc 100644 --- a/module/plugins/crypter/Dereferer.py +++ b/module/plugins/crypter/Dereferer.py @@ -6,12 +6,39 @@ from module.plugins.internal.SimpleDereferer import SimpleDereferer class Dereferer(SimpleDereferer): __name__ = "Dereferer" __type__ = "crypter" - __version__ = "0.11" + __version__ = "0.12" - __pattern__ = r'https?://([^/]+)/.*?(?P<LINK>(ht|f)tps?(://|%3A%2F%2F).+)' + __pattern__ = r'https?://(?:www\.)?(?:\w+\.)*?(?P<DOMAIN>(?:[\d.]+|[\w\-]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/.*?(?P<LINK>(?:ht|f)tps?://.+)' __config__ = [("use_subfolder" , "bool", "Save package to subfolder" , True), ("subfolder_per_pack", "bool", "Create a subfolder for each package", True)] __description__ = """Crypter for dereferers""" __license__ = "GPLv3" - __authors__ = [("zoidberg", "zoidberg@mujmail.cz")] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + HOSTER_DOMAIN = None + HOSTER_NAME = None + + + def _log(self, type, args): + msg = " | ".join(str(a).strip() for a in args if a) + logger = getattr(self.log, type) + logger("%s: %s: %s" % (self.__name__, self.HOSTER_NAME, msg or _("%s MARK" % type.upper()))) + + + def init(self): + super(Dereferer, self).init() + + self.__pattern__ = self.core.pluginManager.crypterPlugins[self.__name__]['pattern'] #@TODO: Recheck in 0.4.10 + + self.HOSTER_DOMAIN = re.match(self.__pattern__, self.pyfile.url).group("DOMAIN").lower() + self.HOSTER_NAME = "".join(part.capitalize() for part in re.split(r'(\.|\d+)', self.HOSTER_DOMAIN) if part != '.') + + + def getLink(self): + try: + return re.match(self.__pattern__, pyfile.url).group('LINK').strip() + + except Exception, e: + self.logWarning(e) diff --git a/module/plugins/internal/SimpleDereferer.py b/module/plugins/internal/SimpleDereferer.py index 1f04ab1c6..2e7e08321 100644 --- a/module/plugins/internal/SimpleDereferer.py +++ b/module/plugins/internal/SimpleDereferer.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import re -import urllib from module.plugins.Crypter import Crypter from module.plugins.internal.SimpleHoster import create_getInfo, set_cookies @@ -11,7 +10,7 @@ from module.utils import html_unescape class SimpleDereferer(Crypter): __name__ = "SimpleDereferer" __type__ = "crypter" - __version__ = "0.13" + __version__ = "0.14" __pattern__ = r'^unmatchable$' __config__ = [] #@TODO: Remove in 0.4.10 @@ -37,6 +36,8 @@ class SimpleDereferer(Crypter): You can override the getLinks method if you need a more sophisticated way to extract the redirect url. """ + URL_REPLACEMENTS = [] + LINK_PATTERN = None TEXT_ENCODING = False @@ -50,18 +51,15 @@ class SimpleDereferer(Crypter): def decrypt(self, pyfile): + self.prepare() + self.handleDirect(pyfile) if not self.link: - try: - self.link = urllib.unquote(re.match(self.__pattern__, pyfile.url).group('LINK')) - - except AttributeError: - self.prepare() - self.preload() - self.checkStatus() + self.preload() + self.checkStatus() - self.link = self.getLink() + self.link = self.getLink() if self.link: self.urls = [self.link] @@ -80,6 +78,8 @@ class SimpleDereferer(Crypter): if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) + self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) + def preload(self): self.html = self.load(self.pyfile.url, cookies=bool(self.COOKIES), decode=not self.TEXT_ENCODING) @@ -97,5 +97,11 @@ class SimpleDereferer(Crypter): def getLink(self): - link = re.search(self.LINK_PATTERN, self.html).group(1) - return html_unescape(link.strip().decode('unicode-escape')) #@TODO: Move this check to plugin `load` method in 0.4.10 + try: + link = re.search(self.LINK_PATTERN, self.html).group(1) + + except Exception, e: + self.logWarning(e) + + else: + return html_unescape(link.strip().decode('unicode-escape')) #@TODO: Move this check to plugin `load` method in 0.4.10 |