diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-30 15:54:38 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-05-30 15:54:38 +0200 |
commit | fcdc1f730118050e390ad2d9fa337ce62809d9a6 (patch) | |
tree | be69dbc646d385cc34b8de8cd8e0fc082a6c6882 /module/plugins/internal/SimpleDereferer.py | |
parent | [XFileSharingPro][XFileSharingProFolder] Added default __pattern__ (diff) | |
download | pyload-fcdc1f730118050e390ad2d9fa337ce62809d9a6.tar.xz |
[SimpleCrypter] Merge with SimpleDereferer
Diffstat (limited to 'module/plugins/internal/SimpleDereferer.py')
-rw-r--r-- | module/plugins/internal/SimpleDereferer.py | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/module/plugins/internal/SimpleDereferer.py b/module/plugins/internal/SimpleDereferer.py deleted file mode 100644 index 2e7e08321..000000000 --- a/module/plugins/internal/SimpleDereferer.py +++ /dev/null @@ -1,107 +0,0 @@ -# -*- coding: utf-8 -*- - -import re - -from module.plugins.Crypter import Crypter -from module.plugins.internal.SimpleHoster import create_getInfo, set_cookies -from module.utils import html_unescape - - -class SimpleDereferer(Crypter): - __name__ = "SimpleDereferer" - __type__ = "crypter" - __version__ = "0.14" - - __pattern__ = r'^unmatchable$' - __config__ = [] #@TODO: Remove in 0.4.10 - - __description__ = """Simple dereferer plugin""" - __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - - - """ - Following patterns should be defined by each crypter: - - LINK_PATTERN: Regex to catch the redirect url in group(1) - example: LINK_PATTERN = r'<div class="link"><a href="(.+?)"' - - OFFLINE_PATTERN: (optional) Checks if the page is unreachable - example: OFFLINE_PATTERN = r'File (deleted|not found)' - - TEMP_OFFLINE_PATTERN: (optional) Checks if the page is temporarily unreachable - example: TEMP_OFFLINE_PATTERN = r'Server maintainance' - - - 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 - COOKIES = True - - - def handleDirect(self, pyfile): - header = self.load(pyfile.url, just_header=True, decode=True) - if 'location' in header and header['location']: - self.link = header['location'] - - - def decrypt(self, pyfile): - self.prepare() - - self.handleDirect(pyfile) - - if not self.link: - self.preload() - self.checkStatus() - - self.link = self.getLink() - - if self.link: - self.urls = [self.link] - - elif not self.urls and not self.packages: #@TODO: Remove in 0.4.10 - self.fail(_("No link grabbed")) - - - def prepare(self): - self.info = {} - self.html = "" - self.link = "" #@TODO: Move to hoster class in 0.4.10 - - self.req.setOption("timeout", 120) - - 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) - - if isinstance(self.TEXT_ENCODING, basestring): - self.html = unicode(self.html, self.TEXT_ENCODING) - - - def checkStatus(self): - if hasattr(self, "OFFLINE_PATTERN") and re.search(self.OFFLINE_PATTERN, self.html): - self.offline() - - elif hasattr(self, "TEMP_OFFLINE_PATTERN") and re.search(self.TEMP_OFFLINE_PATTERN, self.html): - self.tempOffline() - - - def getLink(self): - 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 |