From 9c9cc6d4871b9847dada36c63ae1cbadfacef999 Mon Sep 17 00:00:00 2001 From: Stefano <l.stickell@yahoo.it> Date: Wed, 2 Jul 2014 15:23:46 +0200 Subject: [SimpleCrypter] ability to set cookies --- module/plugins/internal/SimpleCrypter.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index b1a18f5e0..268efee86 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -21,12 +21,12 @@ import re from module.plugins.Crypter import Crypter from module.utils import html_unescape -from module.plugins.internal.SimpleHoster import replace_patterns +from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" - __version__ = "0.07" + __version__ = "0.08" __pattern__ = None __type__ = "crypter" __description__ = """Simple decrypter plugin""" @@ -55,6 +55,12 @@ class SimpleCrypter(Crypter): FILE_URL_REPLACEMENTS = [] + SH_COOKIES = True # or False or list of tuples [(domain, name, value)] + + def setup(self): + if isinstance(self.SH_COOKIES, list): + set_cookies(self.req.cj, self.SH_COOKIES) + def decrypt(self, pyfile): pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) -- cgit v1.2.3 From 15362ebceaee1eb66920d4822d2faa947151e74a Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 5 Jul 2014 16:42:24 +0200 Subject: [SimpleCrypter] Better inline docs + support for offline & temp.offline check --- module/plugins/internal/SimpleCrypter.py | 40 +++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 268efee86..2c024d738 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -26,34 +26,44 @@ from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" - __version__ = "0.08" + __version__ = "0.09" __pattern__ = None __type__ = "crypter" __description__ = """Simple decrypter plugin""" __author_name__ = ("stickell", "zoidberg") __author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz") + """ - These patterns should be defined by each crypter: + Following patterns should be defined by each crypter: + + LINK_PATTERN: group(1) must be a download link or a regex to catch more links + example: LINK_PATTERN = r'<div class="link"><a href="(http://speedload.org/\w+)' + + TITLE_PATTERN: (optional) The group defined by 'title' should be the title + example: TITLE_PATTERN = r'<title>Files of: (?P<title>[^<]+) folder</title>' + + OFFLINE_PATTERN: (optional) Checks if the file is yet available online + example: OFFLINE_PATTERN = r'File (deleted|not found)' - LINK_PATTERN: group(1) must be a download link - example: <div class="link"><a href="(http://speedload.org/\w+) + TEMP_OFFLINE_PATTERN: (optional) Checks if the file is temporarily offline + example: TEMP_OFFLINE_PATTERN = r'Server maintainance' - TITLE_PATTERN: (optional) the group defined by 'title' should be the title - example: <title>Files of: (?P<title>[^<]+) folder</title> If it's impossible to extract the links using the LINK_PATTERN only you can override the getLinks method. If the links are disposed on multiple pages you need to define a pattern: - PAGES_PATTERN: the group defined by 'pages' must be the total number of pages + PAGES_PATTERN: The group defined by 'pages' must be the total number of pages + example: PAGES_PATTERN = r'' and a function: - loadPage(self, page_n): - must return the html of the page number 'page_n' + loadPage(self, page_n): + return the html of the page number 'page_n' """ - FILE_URL_REPLACEMENTS = [] + URL_REPLACEMENTS = [] + SH_COOKIES = True # or False or list of tuples [(domain, name, value)] @@ -62,10 +72,12 @@ class SimpleCrypter(Crypter): set_cookies(self.req.cj, self.SH_COOKIES) def decrypt(self, pyfile): - pyfile.url = replace_patterns(pyfile.url, self.FILE_URL_REPLACEMENTS) + pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) self.html = self.load(pyfile.url, decode=True) + self.checkOnline() + package_name, folder_name = self.getPackageNameAndFolder() self.package_links = self.getLinks() @@ -87,6 +99,12 @@ class SimpleCrypter(Crypter): """ return re.findall(self.LINK_PATTERN, self.html) + def checkOnline(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 getPackageNameAndFolder(self): if hasattr(self, 'TITLE_PATTERN'): m = re.search(self.TITLE_PATTERN, self.html) -- cgit v1.2.3 From 0ba3f71ba9bf5c500245ca40ac2eceb6a31da52b Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 5 Jul 2014 20:46:08 +0200 Subject: [SimpleCrypter] Added missed PAGES_PATTERN example --- module/plugins/internal/SimpleCrypter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 2c024d738..5cf3b55eb 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -54,7 +54,7 @@ class SimpleCrypter(Crypter): If the links are disposed on multiple pages you need to define a pattern: PAGES_PATTERN: The group defined by 'pages' must be the total number of pages - example: PAGES_PATTERN = r'' + example: PAGES_PATTERN = r'Pages: (?P<pages>\d+)' and a function: -- cgit v1.2.3 From 632139090a0440d2e61631a5ef4e3eafd728f9c7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 10 Jul 2014 02:03:02 +0200 Subject: [SimpleCrypter] Support parseError --- module/plugins/internal/SimpleCrypter.py | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 5cf3b55eb..2bcdad6a3 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -1,37 +1,20 @@ # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: zoidberg -""" - import re from module.plugins.Crypter import Crypter from module.utils import html_unescape -from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies +from module.plugins.internal.SimpleHoster import PluginParseError, replace_patterns, set_cookies class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" - __version__ = "0.09" + __version__ = "0.10" __pattern__ = None __type__ = "crypter" __description__ = """Simple decrypter plugin""" - __author_name__ = ("stickell", "zoidberg") - __author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz") + __author_name__ = ("stickell", "zoidberg", "Walter Purcaro") + __author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz", "vuolter@gmail.com") """ Following patterns should be defined by each crypter: @@ -128,3 +111,6 @@ class SimpleCrypter(Crypter): for p in xrange(2, pages + 1): self.html = self.loadPage(p) self.package_links += self.getLinks() + + def parseError(self, msg): + raise PluginParseError(msg) -- cgit v1.2.3 From 48c0c42fd6faffc56432d5f037cd575979f180cc Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 14 Jul 2014 02:23:37 +0200 Subject: Removed all @author flags + key attributes cleanup for internal & hooks plugins --- module/plugins/internal/SimpleCrypter.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 2bcdad6a3..dc93bef4d 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -10,8 +10,10 @@ from module.plugins.internal.SimpleHoster import PluginParseError, replace_patte class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __version__ = "0.10" - __pattern__ = None __type__ = "crypter" + + __pattern__ = None + __description__ = """Simple decrypter plugin""" __author_name__ = ("stickell", "zoidberg", "Walter Purcaro") __author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz", "vuolter@gmail.com") @@ -47,9 +49,9 @@ class SimpleCrypter(Crypter): URL_REPLACEMENTS = [] - SH_COOKIES = True # or False or list of tuples [(domain, name, value)] + def setup(self): if isinstance(self.SH_COOKIES, list): set_cookies(self.req.cj, self.SH_COOKIES) -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/internal/SimpleCrypter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index dc93bef4d..0b99feb42 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -3,14 +3,14 @@ import re from module.plugins.Crypter import Crypter -from module.utils import html_unescape from module.plugins.internal.SimpleHoster import PluginParseError, replace_patterns, set_cookies +from module.utils import html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" - __version__ = "0.10" __type__ = "crypter" + __version__ = "0.10" __pattern__ = None -- cgit v1.2.3 From 85b5a8efcc205d9739fc1a54481cb65bf18e4d81 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 24 Sep 2014 19:16:12 +0200 Subject: [SimpleCrypter] Better built-in info --- module/plugins/internal/SimpleCrypter.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 0b99feb42..3cd52d9f1 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -24,7 +24,7 @@ class SimpleCrypter(Crypter): LINK_PATTERN: group(1) must be a download link or a regex to catch more links example: LINK_PATTERN = r'<div class="link"><a href="(http://speedload.org/\w+)' - TITLE_PATTERN: (optional) The group defined by 'title' should be the title + TITLE_PATTERN: (optional) The group defined by 'title' should be the folder name or the webpage title example: TITLE_PATTERN = r'<title>Files of: (?P<title>[^<]+) folder</title>' OFFLINE_PATTERN: (optional) Checks if the file is yet available online @@ -34,17 +34,18 @@ class SimpleCrypter(Crypter): example: TEMP_OFFLINE_PATTERN = r'Server maintainance' - If it's impossible to extract the links using the LINK_PATTERN only you can override the getLinks method. + You can override the getLinks method if you need a more sophisticated way to extract the links. - If the links are disposed on multiple pages you need to define a pattern: - PAGES_PATTERN: The group defined by 'pages' must be the total number of pages + If the links are splitted on multiple pages you can define the PAGES_PATTERN regex: + + PAGES_PATTERN: (optional) The group defined by 'pages' should be the number of overall pages containing the links example: PAGES_PATTERN = r'Pages: (?P<pages>\d+)' - and a function: + and its loadPage method: - loadPage(self, page_n): - return the html of the page number 'page_n' + def loadPage(self, page_n): + return the html of the page number page_n """ URL_REPLACEMENTS = [] @@ -56,6 +57,7 @@ class SimpleCrypter(Crypter): if isinstance(self.SH_COOKIES, list): set_cookies(self.req.cj, self.SH_COOKIES) + def decrypt(self, pyfile): pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) @@ -77,6 +79,7 @@ class SimpleCrypter(Crypter): else: self.fail('Could not extract any links') + def getLinks(self): """ Returns the links extracted from self.html @@ -84,12 +87,14 @@ class SimpleCrypter(Crypter): """ return re.findall(self.LINK_PATTERN, self.html) + def checkOnline(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 getPackageNameAndFolder(self): if hasattr(self, 'TITLE_PATTERN'): m = re.search(self.TITLE_PATTERN, self.html) @@ -103,6 +108,7 @@ class SimpleCrypter(Crypter): self.logDebug("Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (name, folder)) return name, folder + def handleMultiPages(self): pages = re.search(self.PAGES_PATTERN, self.html) if pages: @@ -114,5 +120,6 @@ class SimpleCrypter(Crypter): self.html = self.loadPage(p) self.package_links += self.getLinks() + def parseError(self, msg): raise PluginParseError(msg) -- cgit v1.2.3 From 76c67b22c0b2dbd275fae77e8a3121acb2d4301b Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 26 Sep 2014 15:39:33 +0200 Subject: Fix cookie deletion + Account support for SimpleCrypter Fix: https://github.com/pyload/pyload/issues/749 --- module/plugins/internal/SimpleCrypter.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 3cd52d9f1..bacfce1dd 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -10,7 +10,7 @@ from module.utils import html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.10" + __version__ = "0.11" __pattern__ = None @@ -48,9 +48,14 @@ class SimpleCrypter(Crypter): return the html of the page number page_n """ + URL_REPLACEMENTS = [] - SH_COOKIES = True # or False or list of tuples [(domain, name, value)] + SH_BROKEN_ENCODING = False #: Set to True or encoding name if encoding in http header is not correct + SH_COOKIES = True #: or False or list of tuples [(domain, name, value)] + + LOGIN_ACCOUNT = False + LOGIN_PREMIUM = False def setup(self): @@ -59,9 +64,15 @@ class SimpleCrypter(Crypter): def decrypt(self, pyfile): + if self.LOGIN_ACCOUNT and not self.account: + self.fail('Required account not found!') + + if self.LOGIN_PREMIUM and not self.premium: + self.fail('Required premium account not found!') + pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) - self.html = self.load(pyfile.url, decode=True) + self.html = self.load(pyfile.url, decode=not self.SH_BROKEN_ENCODING, cookies=self.SH_COOKIES) self.checkOnline() -- cgit v1.2.3 From 4709a41c176dd2947709b7f35ccc84213d574624 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 26 Sep 2014 16:59:26 +0200 Subject: Rename SH flags --- module/plugins/internal/SimpleCrypter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index bacfce1dd..184ba66c9 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -51,16 +51,16 @@ class SimpleCrypter(Crypter): URL_REPLACEMENTS = [] - SH_BROKEN_ENCODING = False #: Set to True or encoding name if encoding in http header is not correct - SH_COOKIES = True #: or False or list of tuples [(domain, name, value)] + 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 def setup(self): - if isinstance(self.SH_COOKIES, list): - set_cookies(self.req.cj, self.SH_COOKIES) + if isinstance(self.COOKIES, list): + set_cookies(self.req.cj, self.COOKIES) def decrypt(self, pyfile): @@ -72,7 +72,7 @@ class SimpleCrypter(Crypter): pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) - self.html = self.load(pyfile.url, decode=not self.SH_BROKEN_ENCODING, cookies=self.SH_COOKIES) + self.html = self.load(pyfile.url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) self.checkOnline() -- cgit v1.2.3 From 0d220d634e512d89bda540f91c643b361c82ea8a Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 27 Sep 2014 01:38:32 +0200 Subject: Logging string cosmetics --- module/plugins/internal/SimpleCrypter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 184ba66c9..a4134dcc0 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -83,7 +83,7 @@ class SimpleCrypter(Crypter): if hasattr(self, 'PAGES_PATTERN') and hasattr(self, 'loadPage'): self.handleMultiPages() - self.logDebug('Package has %d links' % len(self.package_links)) + self.logDebug("Package has %d links" % len(self.package_links)) if self.package_links: self.packages = [(package_name, self.package_links, folder_name)] -- cgit v1.2.3 From 8add4efc7dc3eeaa873030930e5bd31d6bdf8126 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 28 Sep 2014 14:57:02 +0200 Subject: [XFileSharingPro] COOKIES preset to english + improved setup routine --- module/plugins/internal/SimpleCrypter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index a4134dcc0..3c783bcab 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -72,7 +72,7 @@ class SimpleCrypter(Crypter): pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) - self.html = self.load(pyfile.url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) + self.html = self.load(pyfile.url, decode=not self.TEXT_ENCODING) self.checkOnline() -- cgit v1.2.3 From 2e4101c6b373867d556a410901efb8c85c56593f Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 28 Sep 2014 16:27:29 +0200 Subject: Prepare method improves setup one --- module/plugins/internal/SimpleCrypter.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 3c783bcab..2873a7fa7 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -10,7 +10,7 @@ from module.utils import html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.11" + __version__ = "0.12" __pattern__ = None @@ -58,18 +58,20 @@ class SimpleCrypter(Crypter): LOGIN_PREMIUM = False - def setup(self): - if isinstance(self.COOKIES, list): - set_cookies(self.req.cj, self.COOKIES) - - - def decrypt(self, pyfile): + def prepare(self): if self.LOGIN_ACCOUNT and not self.account: self.fail('Required account not found!') if self.LOGIN_PREMIUM and not self.premium: self.fail('Required premium account not found!') + if isinstance(self.COOKIES, list): + set_cookies(self.req.cj, self.COOKIES) + + + def decrypt(self, pyfile): + self.prepare() + pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) self.html = self.load(pyfile.url, decode=not self.TEXT_ENCODING) -- cgit v1.2.3 From cf57dbf9a57bd4078051688f8984a4c1fe6e4996 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 6 Oct 2014 14:45:15 +0200 Subject: [SimpleCrypter] Improve patterns --- module/plugins/internal/SimpleCrypter.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 2873a7fa7..d69995402 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -4,13 +4,13 @@ import re from module.plugins.Crypter import Crypter from module.plugins.internal.SimpleHoster import PluginParseError, replace_patterns, set_cookies -from module.utils import html_unescape +from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.12" + __version__ = "0.13" __pattern__ = None @@ -24,8 +24,8 @@ class SimpleCrypter(Crypter): LINK_PATTERN: group(1) must be a download link or a regex to catch more links example: LINK_PATTERN = r'<div class="link"><a href="(http://speedload.org/\w+)' - TITLE_PATTERN: (optional) The group defined by 'title' should be the folder name or the webpage title - example: TITLE_PATTERN = r'<title>Files of: (?P<title>[^<]+) folder</title>' + TITLE_PATTERN: (optional) group(1) should be the folder name or the webpage title + example: TITLE_PATTERN = r'<title>Files of: ([^<]+) folder</title>' OFFLINE_PATTERN: (optional) Checks if the file is yet available online example: OFFLINE_PATTERN = r'File (deleted|not found)' @@ -39,8 +39,8 @@ class SimpleCrypter(Crypter): If the links are splitted on multiple pages you can define the PAGES_PATTERN regex: - PAGES_PATTERN: (optional) The group defined by 'pages' should be the number of overall pages containing the links - example: PAGES_PATTERN = r'Pages: (?P<pages>\d+)' + PAGES_PATTERN: (optional) group(1) should be the number of overall pages containing the links + example: PAGES_PATTERN = r'Pages: (\d+)' and its loadPage method: @@ -49,6 +49,7 @@ class SimpleCrypter(Crypter): """ + TITLE_REPLACEMENTS = [("&#?\w+;", fixup)] URL_REPLACEMENTS = [] TEXT_ENCODING = False #: Set to True or encoding name if encoding in http header is not correct @@ -112,7 +113,8 @@ class SimpleCrypter(Crypter): if hasattr(self, 'TITLE_PATTERN'): m = re.search(self.TITLE_PATTERN, self.html) if m: - name = folder = html_unescape(m.group('title').strip()) + name = replace_patterns(m.group(1).strip(), self.TITLE_REPLACEMENTS) + folder = html_unescape(name) self.logDebug("Found name [%s] and folder [%s] in package info" % (name, folder)) return name, folder @@ -125,7 +127,7 @@ class SimpleCrypter(Crypter): def handleMultiPages(self): pages = re.search(self.PAGES_PATTERN, self.html) if pages: - pages = int(pages.group('pages')) + pages = int(pages.group(1)) else: pages = 1 -- cgit v1.2.3 From dd24571c5015e3fea1877671b464104557463f6f Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 7 Oct 2014 13:52:47 +0200 Subject: [SimpleCrypter][SimpleHoster] Better exception handling --- module/plugins/internal/SimpleCrypter.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index d69995402..43e8b46cb 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -18,11 +18,12 @@ class SimpleCrypter(Crypter): __author_name__ = ("stickell", "zoidberg", "Walter Purcaro") __author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz", "vuolter@gmail.com") + """ Following patterns should be defined by each crypter: LINK_PATTERN: group(1) must be a download link or a regex to catch more links - example: LINK_PATTERN = r'<div class="link"><a href="(http://speedload.org/\w+)' + example: LINK_PATTERN = r'<div class="link"><a href="(.+?)"' TITLE_PATTERN: (optional) group(1) should be the folder name or the webpage title example: TITLE_PATTERN = r'<title>Files of: ([^<]+) folder</title>' @@ -48,7 +49,6 @@ class SimpleCrypter(Crypter): return the html of the page number page_n """ - TITLE_REPLACEMENTS = [("&#?\w+;", fixup)] URL_REPLACEMENTS = [] @@ -111,24 +111,28 @@ class SimpleCrypter(Crypter): def getPackageNameAndFolder(self): if hasattr(self, 'TITLE_PATTERN'): - m = re.search(self.TITLE_PATTERN, self.html) - if m: + try: + m = re.search(self.TITLE_PATTERN, self.html) name = replace_patterns(m.group(1).strip(), self.TITLE_REPLACEMENTS) folder = html_unescape(name) + except: + pass + else: self.logDebug("Found name [%s] and folder [%s] in package info" % (name, folder)) return name, folder name = self.pyfile.package().name folder = self.pyfile.package().folder self.logDebug("Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (name, folder)) + return name, folder def handleMultiPages(self): - pages = re.search(self.PAGES_PATTERN, self.html) - if pages: - pages = int(pages.group(1)) - else: + try: + m = re.search(self.PAGES_PATTERN, self.html) + pages = int(m.group(1)) + except: pages = 1 for p in xrange(2, pages + 1): -- cgit v1.2.3 From b0868ae6446078bacf1635dde5e4ab316b4a94cb Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 7 Oct 2014 18:57:59 +0200 Subject: New __authors__ key replaces __author_name__ and __author_mail__ + Whitespaces and EOF fixup --- module/plugins/internal/SimpleCrypter.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 43e8b46cb..2da551ea9 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -15,8 +15,9 @@ class SimpleCrypter(Crypter): __pattern__ = None __description__ = """Simple decrypter plugin""" - __author_name__ = ("stickell", "zoidberg", "Walter Purcaro") - __author_mail__ = ("l.stickell@yahoo.it", "zoidberg@mujmail.cz", "vuolter@gmail.com") + __authors__ = [("stickell", "l.stickell@yahoo.it"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] """ -- cgit v1.2.3 From ae7a7e66981456e5bbe2b54006d79b6f907be7a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 8 Oct 2014 20:18:13 +0200 Subject: Add __license__ key attribute to plugins --- module/plugins/internal/SimpleCrypter.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 2da551ea9..8139d661d 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -15,6 +15,7 @@ class SimpleCrypter(Crypter): __pattern__ = None __description__ = """Simple decrypter plugin""" + __license__ = "GPLv3" __authors__ = [("stickell", "l.stickell@yahoo.it"), ("zoidberg", "zoidberg@mujmail.cz"), ("Walter Purcaro", "vuolter@gmail.com")] -- cgit v1.2.3 From fac6b2007a93101f8441810118f3c8d10a3db13a Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 17 Oct 2014 20:53:31 +0200 Subject: [SimpleCrypter] Fix missing LINK_PATTERN --- module/plugins/internal/SimpleCrypter.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 8139d661d..73329ed65 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -51,6 +51,8 @@ class SimpleCrypter(Crypter): return the html of the page number page_n """ + LINK_PATTERN = None + TITLE_REPLACEMENTS = [("&#?\w+;", fixup)] URL_REPLACEMENTS = [] -- cgit v1.2.3 From e2f481deb624709764768454f7cf8222b8b45af7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 18 Oct 2014 15:23:30 +0200 Subject: [SimpleCrypter] Fix account association --- module/plugins/internal/SimpleCrypter.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 73329ed65..fe644cbda 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -10,7 +10,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.13" + __version__ = "0.14" __pattern__ = None @@ -63,6 +63,15 @@ class SimpleCrypter(Crypter): LOGIN_PREMIUM = False + def init(self): + self.account = self.core.accountManager.getAccountPlugin((self.__name__ + ".py").replace("Folder.py", "")) + + if self.account and self.account.canUse(): + self.user, data = self.account.selectAccount() + self.req = self.account.getAccountRequest(self.user) + self.premium = self.account.isPremium(self.user) + + def prepare(self): if self.LOGIN_ACCOUNT and not self.account: self.fail('Required account not found!') -- cgit v1.2.3 From b9cd4eb41e9b8753bca4b5a8334d7242eab98371 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 18 Oct 2014 17:44:49 +0200 Subject: [SimpleCrypter] Fix account routine --- module/plugins/internal/SimpleCrypter.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index fe644cbda..3c1dc3244 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -10,7 +10,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.14" + __version__ = "0.15" __pattern__ = None @@ -64,12 +64,15 @@ class SimpleCrypter(Crypter): def init(self): - self.account = self.core.accountManager.getAccountPlugin((self.__name__ + ".py").replace("Folder.py", "")) + account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "") + account = self.core.accountManager.getAccountPlugin(account_name) - if self.account and self.account.canUse(): - self.user, data = self.account.selectAccount() - self.req = self.account.getAccountRequest(self.user) - self.premium = self.account.isPremium(self.user) + if account and account.canUse(): + self.user, data = account.selectAccount() + self.req = account.getAccountRequest(self.user) + self.premium = account.isPremium(self.user) + + self.account = account def prepare(self): -- cgit v1.2.3 From bb1f6b3cbfc34914a1a336f8f5a2e15b57e2b5f5 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 19 Oct 2014 14:35:53 +0200 Subject: parseError -> error now calls Fail instead Exception --- module/plugins/internal/SimpleCrypter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 3c1dc3244..b45e503d5 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -3,14 +3,15 @@ import re from module.plugins.Crypter import Crypter -from module.plugins.internal.SimpleHoster import PluginParseError, replace_patterns, set_cookies +from module.plugins.Plugin import Fail +from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.15" + __version__ = "0.16" __pattern__ = None @@ -156,5 +157,5 @@ class SimpleCrypter(Crypter): self.package_links += self.getLinks() - def parseError(self, msg): - raise PluginParseError(msg) + def error(self, reason): + raise Fail("Parse error (%s) - crypter plugin may be out of date" % reason) -- cgit v1.2.3 From 4bfdf03e804fcafabab0ff08b2b6ef1daec2cf91 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 19 Oct 2014 15:11:18 +0200 Subject: Improve error method --- module/plugins/internal/SimpleCrypter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index b45e503d5..f1def8118 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -157,5 +157,8 @@ class SimpleCrypter(Crypter): self.package_links += self.getLinks() - def error(self, reason): - raise Fail("Parse error (%s) - crypter plugin may be out of date" % reason) + def error(self, reason=None, type="parse"): + if reason: + raise Fail("%s error: %s | Plugin may be out of date" % (type.capitalize(), reason)) + else: + raise Fail("%s error | Plugin out of date" % type.capitalize()) -- cgit v1.2.3 From 4e0e93fe8a9c9a98f3f299afacf07fbc855ef88b Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 20 Oct 2014 12:59:27 +0200 Subject: Preload self.html --- module/plugins/internal/SimpleCrypter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index f1def8118..b09ee6ac2 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -2,6 +2,7 @@ import re +from module.network.RequestFactory import getURL from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies @@ -11,7 +12,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.16" + __version__ = "0.17" __pattern__ = None @@ -86,14 +87,13 @@ class SimpleCrypter(Crypter): if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) + url = self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) + self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) + def decrypt(self, pyfile): self.prepare() - pyfile.url = replace_patterns(pyfile.url, self.URL_REPLACEMENTS) - - self.html = self.load(pyfile.url, decode=not self.TEXT_ENCODING) - self.checkOnline() package_name, folder_name = self.getPackageNameAndFolder() -- cgit v1.2.3 From 99f1eff391ca832740d1d519e8d6724a00fba952 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 22 Oct 2014 02:04:46 +0200 Subject: [SimpleCrypter] Fix missing TEXT_ENCODING routine --- module/plugins/internal/SimpleCrypter.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index b09ee6ac2..e2e08bb1b 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -12,7 +12,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.17" + __version__ = "0.18" __pattern__ = None @@ -88,7 +88,7 @@ class SimpleCrypter(Crypter): set_cookies(self.req.cj, self.COOKIES) url = self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) - self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=self.COOKIES) + self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) def decrypt(self, pyfile): @@ -127,6 +127,9 @@ class SimpleCrypter(Crypter): def getPackageNameAndFolder(self): + if isinstance(self.TEXT_ENCODING, basestring): + self.html = unicode(html, self.TEXT_ENCODING) + if hasattr(self, 'TITLE_PATTERN'): try: m = re.search(self.TITLE_PATTERN, self.html) -- cgit v1.2.3 From 6badd4f1f210d2e9385c4d73c5b41ee5a6f04e65 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 22 Oct 2014 09:59:16 +0200 Subject: Improve error method + fix TEXT_ENCODING in SimpleCrypter --- module/plugins/internal/SimpleCrypter.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index e2e08bb1b..2ea8d302b 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -2,6 +2,8 @@ import re +from traceback import print_exc + from module.network.RequestFactory import getURL from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail @@ -12,7 +14,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.18" + __version__ = "0.19" __pattern__ = None @@ -65,6 +67,7 @@ class SimpleCrypter(Crypter): LOGIN_PREMIUM = False + #@TODO: remove in 0.4.10 def init(self): account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "") account = self.core.accountManager.getAccountPlugin(account_name) @@ -128,7 +131,7 @@ class SimpleCrypter(Crypter): def getPackageNameAndFolder(self): if isinstance(self.TEXT_ENCODING, basestring): - self.html = unicode(html, self.TEXT_ENCODING) + self.html = unicode(self.html, self.TEXT_ENCODING) if hasattr(self, 'TITLE_PATTERN'): try: @@ -160,8 +163,8 @@ class SimpleCrypter(Crypter): self.package_links += self.getLinks() + #@TODO: remove in 0.4.10 def error(self, reason=None, type="parse"): - if reason: - raise Fail("%s error: %s | Plugin may be out of date" % (type.capitalize(), reason)) - else: - raise Fail("%s error | Plugin out of date" % type.capitalize()) + raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ':' + str(reason) if reason else "")) + if self.core.debug: + print_exc() -- cgit v1.2.3 From 1b096b2eb2634e8dea80b06ab9ecde206b198b35 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 22 Oct 2014 19:47:00 +0200 Subject: Spare code cosmetics --- module/plugins/internal/SimpleCrypter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 2ea8d302b..613ffce1f 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -165,6 +165,6 @@ class SimpleCrypter(Crypter): #@TODO: remove in 0.4.10 def error(self, reason=None, type="parse"): - raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ':' + str(reason) if reason else "")) + raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ': ' + str(reason) if reason else "")) if self.core.debug: print_exc() -- cgit v1.2.3 From 0eb6e7ec4a1144dcca824d8add049787d3da1762 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Wed, 22 Oct 2014 19:44:59 +0200 Subject: Two space before function declaration --- module/plugins/internal/SimpleCrypter.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 613ffce1f..6c00a2267 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -51,6 +51,7 @@ class SimpleCrypter(Crypter): and its loadPage method: + def loadPage(self, page_n): return the html of the page number page_n """ -- cgit v1.2.3 From 8e89cb7781ec3b135feeb750f6321bbc85e89d67 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 23 Oct 2014 22:54:40 +0200 Subject: Fix error method --- module/plugins/internal/SimpleCrypter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 6c00a2267..402a641ea 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -165,7 +165,7 @@ class SimpleCrypter(Crypter): #@TODO: remove in 0.4.10 - def error(self, reason=None, type="parse"): - raise Fail("%s error%s | Plugin out of date" % (type.capitalize(), ': ' + str(reason) if reason else "")) + def error(self, reason="", type="parse"): if self.core.debug: print_exc() + raise Fail("%s error%s | Plugin may be out of date" % (type.strip().capitalize(), ': ' + reason.strip() if reason else "")) -- cgit v1.2.3 From e3f5280529921100f48bb8a79853bf480c7611e4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 25 Oct 2014 02:53:05 +0200 Subject: Replace single quotes with doubles in self.error and self.fail msg --- module/plugins/internal/SimpleCrypter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 402a641ea..3cbb0f70a 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -83,10 +83,10 @@ class SimpleCrypter(Crypter): def prepare(self): if self.LOGIN_ACCOUNT and not self.account: - self.fail('Required account not found!') + self.fail("Required account not found!") if self.LOGIN_PREMIUM and not self.premium: - self.fail('Required premium account not found!') + self.fail("Required premium account not found!") if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) @@ -112,7 +112,7 @@ class SimpleCrypter(Crypter): if self.package_links: self.packages = [(package_name, self.package_links, folder_name)] else: - self.fail('Could not extract any links') + self.fail("Could not extract any links") def getLinks(self): -- cgit v1.2.3 From 9f2ebe486a3e155fb6a60e07cccb77ab6a772eb2 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 26 Oct 2014 02:31:54 +0200 Subject: Extend translation support in plugins + a lot of code cosmetics and typo fixes --- module/plugins/internal/SimpleCrypter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 3cbb0f70a..61286449d 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -83,10 +83,10 @@ class SimpleCrypter(Crypter): def prepare(self): if self.LOGIN_ACCOUNT and not self.account: - self.fail("Required account not found!") + self.fail(_("Required account not found!")) if self.LOGIN_PREMIUM and not self.premium: - self.fail("Required premium account not found!") + self.fail(_("Required premium account not found!")) if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) @@ -112,7 +112,7 @@ class SimpleCrypter(Crypter): if self.package_links: self.packages = [(package_name, self.package_links, folder_name)] else: - self.fail("Could not extract any links") + self.fail(_("Could not extract any links")) def getLinks(self): -- cgit v1.2.3 From 8f0303277fce7471539508f7a8fad033e5e87076 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 26 Oct 2014 19:36:46 +0100 Subject: [SimpleHoster][SimpleCrypter] Clean error method --- module/plugins/internal/SimpleCrypter.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 61286449d..9e1b11f7b 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -7,7 +7,7 @@ from traceback import print_exc from module.network.RequestFactory import getURL from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail -from module.plugins.internal.SimpleHoster import replace_patterns, set_cookies +from module.plugins.internal.SimpleHoster import _error, replace_patterns, set_cookies from module.utils import fixup, html_unescape @@ -164,8 +164,5 @@ class SimpleCrypter(Crypter): self.package_links += self.getLinks() - #@TODO: remove in 0.4.10 def error(self, reason="", type="parse"): - if self.core.debug: - print_exc() - raise Fail("%s error%s | Plugin may be out of date" % (type.strip().capitalize(), ': ' + reason.strip() if reason else "")) + return _error(reason, type) -- cgit v1.2.3 From f6aed08062c3b6a4dad09d238a32ef5ab58479a4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 26 Oct 2014 20:49:31 +0100 Subject: [SimpleHoster][SimpleCrypter] Bump up __version__ --- module/plugins/internal/SimpleCrypter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 9e1b11f7b..31102b6fa 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -14,7 +14,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.19" + __version__ = "0.20" __pattern__ = None -- cgit v1.2.3 From 146fe1e309c33ab149bfaf58ad86c0dd4fb9b156 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 27 Oct 2014 01:18:45 +0100 Subject: Spare code cosmetics --- module/plugins/internal/SimpleCrypter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 31102b6fa..f6783cffb 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -91,8 +91,8 @@ class SimpleCrypter(Crypter): if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) - url = self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) - self.html = getURL(url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) + self.html = getURL(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) def decrypt(self, pyfile): -- cgit v1.2.3 From aa0751bcfd995e308bcd586a6965c75e68b1274b Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 27 Oct 2014 23:05:13 +0100 Subject: Code cosmetics --- module/plugins/internal/SimpleCrypter.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index f6783cffb..bfa2e6408 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -12,17 +12,18 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): - __name__ = "SimpleCrypter" - __type__ = "crypter" + __name__ = "SimpleCrypter" + __type__ = "crypter" __version__ = "0.20" __pattern__ = None + __config__ = [] __description__ = """Simple decrypter plugin""" - __license__ = "GPLv3" - __authors__ = [("stickell", "l.stickell@yahoo.it"), - ("zoidberg", "zoidberg@mujmail.cz"), - ("Walter Purcaro", "vuolter@gmail.com")] + __license__ = "GPLv3" + __authors__ = [("stickell", "l.stickell@yahoo.it"), + ("zoidberg", "zoidberg@mujmail.cz"), + ("Walter Purcaro", "vuolter@gmail.com")] """ @@ -111,8 +112,6 @@ class SimpleCrypter(Crypter): if self.package_links: self.packages = [(package_name, self.package_links, folder_name)] - else: - self.fail(_("Could not extract any links")) def getLinks(self): -- cgit v1.2.3 From 885f8ed782e64d9e73367905e642a84d0a8999f1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 28 Oct 2014 04:01:38 +0100 Subject: Update __config__ --- module/plugins/internal/SimpleCrypter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index bfa2e6408..50d647dee 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -17,7 +17,8 @@ class SimpleCrypter(Crypter): __version__ = "0.20" __pattern__ = None - __config__ = [] + __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] + ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] __description__ = """Simple decrypter plugin""" __license__ = "GPLv3" -- cgit v1.2.3 From 6a5b13502648cf51007c15948b778e5a9d54ad20 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 28 Oct 2014 04:52:39 +0100 Subject: [SimpleCrypter][SimpleHoster] Fix typo in _error method call --- module/plugins/internal/SimpleCrypter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 50d647dee..2fa0c2df3 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -14,7 +14,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.20" + __version__ = "0.21" __pattern__ = None __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -165,4 +165,4 @@ class SimpleCrypter(Crypter): def error(self, reason="", type="parse"): - return _error(reason, type) + return _error(self, reason, type) -- cgit v1.2.3 From 1a6d4ab20645e8dda3f0c61d10ecbcc16312eec7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 28 Oct 2014 16:02:14 +0100 Subject: [SimpleCrypter] Wait method --- module/plugins/internal/SimpleCrypter.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 2fa0c2df3..1f41a7e5a 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -7,14 +7,14 @@ from traceback import print_exc from module.network.RequestFactory import getURL from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail -from module.plugins.internal.SimpleHoster import _error, replace_patterns, set_cookies +from module.plugins.internal.SimpleHoster import _error, _wait, replace_patterns, set_cookies from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.21" + __version__ = "0.22" __pattern__ = None __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -164,5 +164,10 @@ class SimpleCrypter(Crypter): self.package_links += self.getLinks() + #@TODO: Remove in 0.4.10 + def wait(self, seconds=0, reconnect=None): + return _wait(self, seconds, reconnect) + + def error(self, reason="", type="parse"): return _error(self, reason, type) -- cgit v1.2.3 From fe64575ff079037d0db827e9067d5a5f6dffb1dd Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 30 Oct 2014 17:24:09 +0100 Subject: [SimpleCrypter] Fix cookies support --- module/plugins/internal/SimpleCrypter.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 1f41a7e5a..e586580d7 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -4,7 +4,6 @@ import re from traceback import print_exc -from module.network.RequestFactory import getURL from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail from module.plugins.internal.SimpleHoster import _error, _wait, replace_patterns, set_cookies @@ -14,7 +13,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.22" + __version__ = "0.23" __pattern__ = None __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -94,7 +93,7 @@ class SimpleCrypter(Crypter): set_cookies(self.req.cj, self.COOKIES) self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) - self.html = getURL(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) def decrypt(self, pyfile): -- cgit v1.2.3 From 7d21001f0495102a2948912d5416dbd3362dc446 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 1 Nov 2014 18:50:11 +0100 Subject: [SimpleCrypter] Move TEXT_ENCODING check to prepare routine --- module/plugins/internal/SimpleCrypter.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index e586580d7..86e8077e7 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -13,7 +13,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.23" + __version__ = "0.24" __pattern__ = None __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -93,8 +93,12 @@ class SimpleCrypter(Crypter): set_cookies(self.req.cj, self.COOKIES) self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) + self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + if isinstance(self.TEXT_ENCODING, basestring): + self.html = unicode(self.html, self.TEXT_ENCODING) + def decrypt(self, pyfile): self.prepare() @@ -130,9 +134,6 @@ class SimpleCrypter(Crypter): def getPackageNameAndFolder(self): - if isinstance(self.TEXT_ENCODING, basestring): - self.html = unicode(self.html, self.TEXT_ENCODING) - if hasattr(self, 'TITLE_PATTERN'): try: m = re.search(self.TITLE_PATTERN, self.html) -- cgit v1.2.3 From 4ec11afb741149ea86e6ba647862b461d54c747c Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 2 Nov 2014 22:37:19 +0100 Subject: Update internal Simple plugins --- module/plugins/internal/SimpleCrypter.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 86e8077e7..1690b50c2 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -32,8 +32,8 @@ class SimpleCrypter(Crypter): LINK_PATTERN: group(1) must be a download link or a regex to catch more links example: LINK_PATTERN = r'<div class="link"><a href="(.+?)"' - TITLE_PATTERN: (optional) group(1) should be the folder name or the webpage title - example: TITLE_PATTERN = r'<title>Files of: ([^<]+) folder</title>' + NAME_PATTERN: (optional) group(1) should be the folder name or the webpage title + example: NAME_PATTERN = r'<title>Files of: ([^<]+) folder</title>' OFFLINE_PATTERN: (optional) Checks if the file is yet available online example: OFFLINE_PATTERN = r'File (deleted|not found)' @@ -59,7 +59,7 @@ class SimpleCrypter(Crypter): LINK_PATTERN = None - TITLE_REPLACEMENTS = [("&#?\w+;", fixup)] + NAME_REPLACEMENTS = [("&#?\w+;", fixup)] URL_REPLACEMENTS = [] TEXT_ENCODING = False #: Set to True or encoding name if encoding in http header is not correct @@ -94,7 +94,8 @@ class SimpleCrypter(Crypter): self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) - self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + if not self.html: + self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) if isinstance(self.TEXT_ENCODING, basestring): self.html = unicode(self.html, self.TEXT_ENCODING) @@ -103,6 +104,9 @@ class SimpleCrypter(Crypter): def decrypt(self, pyfile): self.prepare() + if self.html is None: + self.fail(_("No html retrieved")) + self.checkOnline() package_name, folder_name = self.getPackageNameAndFolder() @@ -134,10 +138,10 @@ class SimpleCrypter(Crypter): def getPackageNameAndFolder(self): - if hasattr(self, 'TITLE_PATTERN'): + if hasattr(self, 'NAME_PATTERN'): try: - m = re.search(self.TITLE_PATTERN, self.html) - name = replace_patterns(m.group(1).strip(), self.TITLE_REPLACEMENTS) + m = re.search(self.NAME_PATTERN, self.html) + name = replace_patterns(m.group(1).strip(), self.NAME_REPLACEMENTS) folder = html_unescape(name) except: pass -- cgit v1.2.3 From cb598e72d1b8bee0302c21e09781b6b2389593c1 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 3 Nov 2014 12:12:55 +0100 Subject: [SimpleCrypter] Use getFileInfo --- module/plugins/internal/SimpleCrypter.py | 67 ++++++++++++++------------------ 1 file changed, 29 insertions(+), 38 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 1690b50c2..9856ae2e5 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -6,14 +6,14 @@ from traceback import print_exc from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail -from module.plugins.internal.SimpleHoster import _error, _wait, replace_patterns, set_cookies +from module.plugins.internal.SimpleHoster import _error, _wait, parseFileInfo, replace_patterns, set_cookies from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.24" + __version__ = "0.25" __pattern__ = None __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -32,8 +32,8 @@ class SimpleCrypter(Crypter): LINK_PATTERN: group(1) must be a download link or a regex to catch more links example: LINK_PATTERN = r'<div class="link"><a href="(.+?)"' - NAME_PATTERN: (optional) group(1) should be the folder name or the webpage title - example: NAME_PATTERN = r'<title>Files of: ([^<]+) folder</title>' + NAME_PATTERN: (optional) folder name or webpage title + example: NAME_PATTERN = r'<title>Files of: (?P<N>[^<]+) folder</title>' OFFLINE_PATTERN: (optional) Checks if the file is yet available online example: OFFLINE_PATTERN = r'File (deleted|not found)' @@ -84,10 +84,10 @@ class SimpleCrypter(Crypter): def prepare(self): if self.LOGIN_ACCOUNT and not self.account: - self.fail(_("Required account not found!")) + self.fail(_("Required account not found")) if self.LOGIN_PREMIUM and not self.premium: - self.fail(_("Required premium account not found!")) + self.fail(_("Required premium account not found")) if isinstance(self.COOKIES, list): set_cookies(self.req.cj, self.COOKIES) @@ -107,53 +107,44 @@ class SimpleCrypter(Crypter): if self.html is None: self.fail(_("No html retrieved")) - self.checkOnline() + info = self.getFileInfo() - package_name, folder_name = self.getPackageNameAndFolder() - - self.package_links = self.getLinks() + self.links = self.getLinks() if hasattr(self, 'PAGES_PATTERN') and hasattr(self, 'loadPage'): self.handleMultiPages() - self.logDebug("Package has %d links" % len(self.package_links)) + self.logDebug("Package has %d links" % len(self.links)) - if self.package_links: - self.packages = [(package_name, self.package_links, folder_name)] + if self.links: + self.packages = [(info['name'], self.links, info['folder'])] - def getLinks(self): - """ - Returns the links extracted from self.html - You should override this only if it's impossible to extract links using only the LINK_PATTERN. - """ - return re.findall(self.LINK_PATTERN, self.html) + def getFileInfo(self): + name, size, status, url = parseFileInfo(self) + if name and name != url: + self.pyfile.name = name + else: + self.pyfile.name = self.file_info['name'] = html_unescape(urlparse(url).path.split("/")[-1]) - def checkOnline(self): - if hasattr(self, "OFFLINE_PATTERN") and re.search(self.OFFLINE_PATTERN, self.html): + if status == 1: self.offline() - elif hasattr(self, "TEMP_OFFLINE_PATTERN") and re.search(self.TEMP_OFFLINE_PATTERN, self.html): + elif status == 6: self.tempOffline() + self.file_info['folder'] = self.pyfile.name - def getPackageNameAndFolder(self): - if hasattr(self, 'NAME_PATTERN'): - try: - m = re.search(self.NAME_PATTERN, self.html) - name = replace_patterns(m.group(1).strip(), self.NAME_REPLACEMENTS) - folder = html_unescape(name) - except: - pass - else: - self.logDebug("Found name [%s] and folder [%s] in package info" % (name, folder)) - return name, folder + self.logDebug("FILE NAME: %s" % self.pyfile.name) + return self.file_info - name = self.pyfile.package().name - folder = self.pyfile.package().folder - self.logDebug("Package info not found, defaulting to pyfile name [%s] and folder [%s]" % (name, folder)) - return name, folder + def getLinks(self): + """ + Returns the links extracted from self.html + You should override this only if it's impossible to extract links using only the LINK_PATTERN. + """ + return re.findall(self.LINK_PATTERN, self.html) def handleMultiPages(self): @@ -165,7 +156,7 @@ class SimpleCrypter(Crypter): for p in xrange(2, pages + 1): self.html = self.loadPage(p) - self.package_links += self.getLinks() + self.links += self.getLinks() #@TODO: Remove in 0.4.10 -- cgit v1.2.3 From 03f3b86f500c495932fd118b54569d92f700847c Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Mon, 3 Nov 2014 16:57:55 +0100 Subject: Code cosmetics about file_info and other stuff --- module/plugins/internal/SimpleCrypter.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 9856ae2e5..0985bac60 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -13,9 +13,9 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.25" + __version__ = "0.26" - __pattern__ = None + __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] ("subfolder_per_package", "bool", "Create a subfolder for each package", True)] @@ -71,6 +71,8 @@ class SimpleCrypter(Crypter): #@TODO: remove in 0.4.10 def init(self): + self.info = {} + account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "") account = self.core.accountManager.getAccountPlugin(account_name) @@ -126,17 +128,17 @@ class SimpleCrypter(Crypter): if name and name != url: self.pyfile.name = name else: - self.pyfile.name = self.file_info['name'] = html_unescape(urlparse(url).path.split("/")[-1]) + self.pyfile.name = self.info['name'] = html_unescape(urlparse(url).path.split("/")[-1]) - if status == 1: + if status is 1: self.offline() - elif status == 6: + elif status is 6: self.tempOffline() - self.file_info['folder'] = self.pyfile.name + self.info['folder'] = self.pyfile.name self.logDebug("FILE NAME: %s" % self.pyfile.name) - return self.file_info + return self.info def getLinks(self): -- cgit v1.2.3 From e9376045f48255d3cbfdbaf5b5c6fbfd9112f17d Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 4 Nov 2014 03:23:06 +0100 Subject: [SimpleCrypter][SimpleHoster] Fix info data retrieving --- module/plugins/internal/SimpleCrypter.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 0985bac60..a694cc2c9 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -13,7 +13,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.26" + __version__ = "0.27" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -60,10 +60,10 @@ class SimpleCrypter(Crypter): LINK_PATTERN = None NAME_REPLACEMENTS = [("&#?\w+;", fixup)] - URL_REPLACEMENTS = [] + 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)] + COOKIES = True #: or False or list of tuples [(domain, name, value)] LOGIN_ACCOUNT = False LOGIN_PREMIUM = False @@ -96,7 +96,7 @@ class SimpleCrypter(Crypter): self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) - if not self.html: + if self.html is None: self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) if isinstance(self.TEXT_ENCODING, basestring): @@ -109,7 +109,8 @@ class SimpleCrypter(Crypter): if self.html is None: self.fail(_("No html retrieved")) - info = self.getFileInfo() + if not self.info: + self.getFileInfo() self.links = self.getLinks() @@ -119,7 +120,7 @@ class SimpleCrypter(Crypter): self.logDebug("Package has %d links" % len(self.links)) if self.links: - self.packages = [(info['name'], self.links, info['folder'])] + self.packages = [(self.info['name'], self.links, self.info['folder'])] def getFileInfo(self): @@ -132,6 +133,7 @@ class SimpleCrypter(Crypter): if status is 1: self.offline() + elif status is 6: self.tempOffline() -- cgit v1.2.3 From 0d1fe176a7963a71f9eb6735afc4132c26550b75 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 4 Nov 2014 19:59:21 +0100 Subject: Fix missing urlparse import --- module/plugins/internal/SimpleCrypter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index a694cc2c9..69cbb7051 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -2,7 +2,7 @@ import re -from traceback import print_exc +from urlparse import urlparse from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail @@ -13,7 +13,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.27" + __version__ = "0.28" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] -- cgit v1.2.3 From 395ac7930ef4e1598186a7a0636d3f245b7e5134 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 11 Nov 2014 00:36:45 +0100 Subject: Fix url to name conversion in api and simple plugins --- module/plugins/internal/SimpleCrypter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 69cbb7051..0e43496c4 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -129,7 +129,7 @@ class SimpleCrypter(Crypter): if name and name != url: self.pyfile.name = name else: - self.pyfile.name = self.info['name'] = html_unescape(urlparse(url).path.split("/")[-1]) + self.pyfile.name = self.info['name'] = urlparse(html_unescape(name)).path.split("/")[-1] if status is 1: self.offline() -- cgit v1.2.3 From 0521acfc4e62096d8f78e6f5d1966835c7acbcef Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 14 Nov 2014 01:53:24 +0100 Subject: [SimpleCrypter][SimpleHoster] Temp workaround --- module/plugins/internal/SimpleCrypter.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 0e43496c4..01d1895a6 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -13,7 +13,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.28" + __version__ = "0.29" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -96,8 +96,7 @@ class SimpleCrypter(Crypter): self.pyfile.url = replace_patterns(self.pyfile.url, self.URL_REPLACEMENTS) - if self.html is None: - self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) if isinstance(self.TEXT_ENCODING, basestring): self.html = unicode(self.html, self.TEXT_ENCODING) -- cgit v1.2.3 From 353f0b64180364cd2d04a3fac0eba5358203eab4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 21 Nov 2014 07:09:49 +0100 Subject: [SimpleCrypter] Updated --- module/plugins/internal/SimpleCrypter.py | 50 +++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 01d1895a6..d1938ec66 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -13,7 +13,7 @@ from module.utils import fixup, html_unescape class SimpleCrypter(Crypter): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.29" + __version__ = "0.30" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -71,7 +71,8 @@ class SimpleCrypter(Crypter): #@TODO: remove in 0.4.10 def init(self): - self.info = {} + self.info = {} #@TODO: Remove in 0.4.10 + self.links = [] account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "") account = self.core.accountManager.getAccountPlugin(account_name) @@ -91,12 +92,16 @@ class SimpleCrypter(Crypter): if self.LOGIN_PREMIUM and not self.premium: self.fail(_("Required premium account not found")) + 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) - self.html = self.load(self.pyfile.url, decode=not self.TEXT_ENCODING, cookies=bool(self.COOKIES)) + + 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) @@ -105,11 +110,12 @@ class SimpleCrypter(Crypter): def decrypt(self, pyfile): self.prepare() + self.preload() + if self.html is None: self.fail(_("No html retrieved")) - if not self.info: - self.getFileInfo() + self.checkInfo() self.links = self.getLinks() @@ -122,13 +128,8 @@ class SimpleCrypter(Crypter): self.packages = [(self.info['name'], self.links, self.info['folder'])] - def getFileInfo(self): - name, size, status, url = parseFileInfo(self) - - if name and name != url: - self.pyfile.name = name - else: - self.pyfile.name = self.info['name'] = urlparse(html_unescape(name)).path.split("/")[-1] + def checkStatus(self): + status = self.info['status'] if status is 1: self.offline() @@ -136,10 +137,31 @@ class SimpleCrypter(Crypter): elif status is 6: self.tempOffline() + + def checkName(self): + name = self.info['name'] + url = self.info['url'] + + if name and name != url: + self.pyfile.name = name + else: + self.pyfile.name = self.info['name'] = urlparse(html_unescape(name)).path.split('/')[-1] + self.info['folder'] = self.pyfile.name - self.logDebug("FILE NAME: %s" % self.pyfile.name) - return self.info + self.logDebug("File name: %s" % self.pyfile.name) + + + def checkInfo(self): + self.logDebug(_("File info (previous): %s") % self.info) + + info = parseFileInfo(self.pyfile.url, self.html or "") + self.info.update(info) + + self.logDebug(_("File info (current): %s") % self.info) + + self.checkName() + self.checkStatus() def getLinks(self): -- cgit v1.2.3 From acddd89ad9e0ce9107ac9a99443cfbecc58a1ff9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 21 Nov 2014 07:46:34 +0100 Subject: [SimpleCrypter][SimpleHoster] Fix info attr init --- module/plugins/internal/SimpleCrypter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index d1938ec66..75c687c16 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -71,9 +71,6 @@ class SimpleCrypter(Crypter): #@TODO: remove in 0.4.10 def init(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.links = [] - account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "") account = self.core.accountManager.getAccountPlugin(account_name) @@ -92,6 +89,9 @@ class SimpleCrypter(Crypter): if self.LOGIN_PREMIUM and not self.premium: self.fail(_("Required premium account not found")) + self.info = {} + self.links = [] + self.req.setOption("timeout", 120) if isinstance(self.COOKIES, list): -- cgit v1.2.3 From 48d785908bafd2615189c6792cbfec36db7e97df Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 21 Nov 2014 18:20:17 +0100 Subject: [SimpleCrypter] Extend SimpleHoster --- module/plugins/internal/SimpleCrypter.py | 47 +++++++------------------------- 1 file changed, 10 insertions(+), 37 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 75c687c16..8c7f0bef3 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -6,14 +6,14 @@ from urlparse import urlparse from module.plugins.Crypter import Crypter from module.plugins.Plugin import Fail -from module.plugins.internal.SimpleHoster import _error, _wait, parseFileInfo, replace_patterns, set_cookies -from module.utils import fixup, html_unescape +from module.plugins.internal.SimpleHoster import SimpleHoster, _error, _wait, replace_patterns, set_cookies +from module.utils import fixup -class SimpleCrypter(Crypter): +class SimpleCrypter(Crypter, SimpleHoster): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.30" + __version__ = "0.31" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -69,7 +69,7 @@ class SimpleCrypter(Crypter): LOGIN_PREMIUM = False - #@TODO: remove in 0.4.10 + #@TODO: Remove in 0.4.10 def init(self): account_name = (self.__name__ + ".py").replace("Folder.py", "").replace(".py", "") account = self.core.accountManager.getAccountPlugin(account_name) @@ -100,13 +100,6 @@ class SimpleCrypter(Crypter): 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 decrypt(self, pyfile): self.prepare() @@ -138,30 +131,19 @@ class SimpleCrypter(Crypter): self.tempOffline() - def checkName(self): + def checkNameSize(self): name = self.info['name'] url = self.info['url'] if name and name != url: self.pyfile.name = name else: - self.pyfile.name = self.info['name'] = urlparse(html_unescape(name)).path.split('/')[-1] - - self.info['folder'] = self.pyfile.name - - self.logDebug("File name: %s" % self.pyfile.name) - + self.pyfile.name = self.info['name'] = urlparse(name).path.split('/')[-1] - def checkInfo(self): - self.logDebug(_("File info (previous): %s") % self.info) + folder = self.info['folder'] = self.pyfile.name - info = parseFileInfo(self.pyfile.url, self.html or "") - self.info.update(info) - - self.logDebug(_("File info (current): %s") % self.info) - - self.checkName() - self.checkStatus() + self.logDebug("File name: %s" % self.pyfile.name, + "File folder: %s" % folder) def getLinks(self): @@ -182,12 +164,3 @@ class SimpleCrypter(Crypter): for p in xrange(2, pages + 1): self.html = self.loadPage(p) self.links += self.getLinks() - - - #@TODO: Remove in 0.4.10 - def wait(self, seconds=0, reconnect=None): - return _wait(self, seconds, reconnect) - - - def error(self, reason="", type="parse"): - return _error(self, reason, type) -- cgit v1.2.3 From d85b5694472c4bf3983729a077a76dd58da25ac4 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 22 Nov 2014 01:46:38 +0100 Subject: [SimpleHoster] Multi-hoster and error handling support + fixes (thx MaPePeR) --- module/plugins/internal/SimpleCrypter.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 8c7f0bef3..5d00daa3c 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -5,8 +5,7 @@ import re from urlparse import urlparse from module.plugins.Crypter import Crypter -from module.plugins.Plugin import Fail -from module.plugins.internal.SimpleHoster import SimpleHoster, _error, _wait, replace_patterns, set_cookies +from module.plugins.internal.SimpleHoster import SimpleHoster, replace_patterns, set_cookies from module.utils import fixup -- cgit v1.2.3 From 9804b57e02d663328af048a96e60a330ac27b60d Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 23 Nov 2014 01:30:45 +0100 Subject: Fixes about create_getInfo --- module/plugins/internal/SimpleCrypter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 5d00daa3c..53ffaf4a6 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -5,14 +5,14 @@ import re from urlparse import urlparse from module.plugins.Crypter import Crypter -from module.plugins.internal.SimpleHoster import SimpleHoster, replace_patterns, set_cookies +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo, replace_patterns, set_cookies from module.utils import fixup class SimpleCrypter(Crypter, SimpleHoster): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.31" + __version__ = "0.32" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] -- cgit v1.2.3 From badfd177fb3639869441f4738461c7f576e1d078 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Tue, 23 Dec 2014 17:22:47 +0100 Subject: [SimpleHoster] Update --- module/plugins/internal/SimpleCrypter.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 53ffaf4a6..e0dd10585 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -12,7 +12,7 @@ from module.utils import fixup class SimpleCrypter(Crypter, SimpleHoster): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.32" + __version__ = "0.33" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -120,16 +120,6 @@ class SimpleCrypter(Crypter, SimpleHoster): self.packages = [(self.info['name'], self.links, self.info['folder'])] - def checkStatus(self): - status = self.info['status'] - - if status is 1: - self.offline() - - elif status is 6: - self.tempOffline() - - def checkNameSize(self): name = self.info['name'] url = self.info['url'] -- cgit v1.2.3 From 136f63dc39603814b215606f888fb2e639021277 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 26 Dec 2014 04:27:41 +0100 Subject: Spare code fixes --- module/plugins/internal/SimpleCrypter.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index e0dd10585..6596828b3 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -12,7 +12,7 @@ from module.utils import fixup class SimpleCrypter(Crypter, SimpleHoster): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.33" + __version__ = "0.34" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -82,14 +82,14 @@ class SimpleCrypter(Crypter, SimpleHoster): def prepare(self): - if self.LOGIN_ACCOUNT and not self.account: - self.fail(_("Required account not found")) + self.info = {} + self.links = [] #@TODO: Move to hoster class in 0.4.10 if self.LOGIN_PREMIUM and not self.premium: self.fail(_("Required premium account not found")) - self.info = {} - self.links = [] + if self.LOGIN_ACCOUNT and not self.account: + self.fail(_("Required account not found")) self.req.setOption("timeout", 120) -- cgit v1.2.3 From b6a2bd53628bd2824bac1dafc7b4eafdf3c815dd Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 27 Dec 2014 13:48:03 +0100 Subject: Update plugins after SimpleHoster changes --- module/plugins/internal/SimpleCrypter.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 6596828b3..428826456 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -12,7 +12,7 @@ from module.utils import fixup class SimpleCrypter(Crypter, SimpleHoster): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.34" + __version__ = "0.35" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -28,16 +28,16 @@ class SimpleCrypter(Crypter, SimpleHoster): """ Following patterns should be defined by each crypter: - LINK_PATTERN: group(1) must be a download link or a regex to catch more links + LINK_PATTERN: Download link or regex to catch links in group(1) example: LINK_PATTERN = r'<div class="link"><a href="(.+?)"' - NAME_PATTERN: (optional) folder name or webpage title + NAME_PATTERN: (optional) folder name or page title example: NAME_PATTERN = r'<title>Files of: (?P<N>[^<]+) folder</title>' - OFFLINE_PATTERN: (optional) Checks if the file is yet available online + OFFLINE_PATTERN: (optional) Checks if the page is unreachable example: OFFLINE_PATTERN = r'File (deleted|not found)' - TEMP_OFFLINE_PATTERN: (optional) Checks if the file is temporarily offline + TEMP_OFFLINE_PATTERN: (optional) Checks if the page is temporarily unreachable example: TEMP_OFFLINE_PATTERN = r'Server maintainance' @@ -120,7 +120,10 @@ class SimpleCrypter(Crypter, SimpleHoster): self.packages = [(self.info['name'], self.links, self.info['folder'])] - def checkNameSize(self): + def checkNameSize(self, getinfo=True): + if getinfo: + self.updateInfo(self.getInfo(self.pyfile.url, self.html)) + name = self.info['name'] url = self.info['url'] -- cgit v1.2.3 From 4882503efe1fce2f123723766f672456e5ccc221 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 27 Dec 2014 21:23:33 +0100 Subject: [SimpleCrypter][SimpleDereferer] Fail if no link grabbed --- module/plugins/internal/SimpleCrypter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 428826456..51ba07eb7 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -12,7 +12,7 @@ from module.utils import fixup class SimpleCrypter(Crypter, SimpleHoster): __name__ = "SimpleCrypter" __type__ = "crypter" - __version__ = "0.35" + __version__ = "0.36" __pattern__ = r'^unmatchable$' __config__ = [("use_subfolder", "bool", "Save package to subfolder", True), #: Overrides core.config['general']['folder_per_package'] @@ -119,6 +119,9 @@ class SimpleCrypter(Crypter, SimpleHoster): if self.links: self.packages = [(self.info['name'], self.links, self.info['folder'])] + elif not self.urls and not self.packages: #@TODO: Remove in 0.4.10 + self.fail("No link grabbed") + def checkNameSize(self, getinfo=True): if getinfo: -- cgit v1.2.3 From 0c61cbb03493b15970a5ccb9a5e20b02b3884a4e Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 28 Dec 2014 01:05:59 +0100 Subject: [SimpleHoster] Improve --- module/plugins/internal/SimpleCrypter.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'module/plugins/internal/SimpleCrypter.py') diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 51ba07eb7..566252245 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -103,10 +103,6 @@ class SimpleCrypter(Crypter, SimpleHoster): self.prepare() self.preload() - - if self.html is None: - self.fail(_("No html retrieved")) - self.checkInfo() self.links = self.getLinks() -- cgit v1.2.3