diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-10-21 01:51:12 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-10-21 01:51:12 +0200 |
commit | 52dabdbe4241b6c6af8bc139d480be5ed2af2294 (patch) | |
tree | b09a4313a3b5f6c507dc4e961eee2496f9e7b9cb /module/plugins | |
parent | [Notifier] Fix https://github.com/pyload/pyload/issues/2090 (diff) | |
download | pyload-52dabdbe4241b6c6af8bc139d480be5ed2af2294.tar.xz |
Boring code cosmetics (2)
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/hooks/ExternalScripts.py | 4 | ||||
-rw-r--r-- | module/plugins/internal/Account.py | 11 | ||||
-rw-r--r-- | module/plugins/internal/Base.py | 7 | ||||
-rw-r--r-- | module/plugins/internal/Captcha.py | 7 | ||||
-rw-r--r-- | module/plugins/internal/Extractor.py | 7 | ||||
-rw-r--r-- | module/plugins/internal/Hoster.py | 5 | ||||
-rw-r--r-- | module/plugins/internal/MultiHoster.py | 2 | ||||
-rw-r--r-- | module/plugins/internal/Notifier.py | 2 | ||||
-rw-r--r-- | module/plugins/internal/OCR.py | 7 | ||||
-rw-r--r-- | module/plugins/internal/SevenZip.py | 16 | ||||
-rw-r--r-- | module/plugins/internal/UnRar.py | 5 | ||||
-rw-r--r-- | module/plugins/internal/UnZip.py | 1 | ||||
-rw-r--r-- | module/plugins/internal/XFSAccount.py | 22 | ||||
-rw-r--r-- | module/plugins/internal/XFSCrypter.py | 8 | ||||
-rw-r--r-- | module/plugins/internal/XFSHoster.py | 27 |
15 files changed, 49 insertions, 82 deletions
diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index d2e52338f..53ff6a154 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -171,14 +171,14 @@ class ExternalScripts(Addon): def package_deleted(self, pid): - pypack = self.pyload.api.getPackageInfo(pid) + pdata = self.pyload.api.getPackageInfo(pid) if self.pyload.config.get("general", "folder_per_package"): dl_folder = fs_join(self.pyload.config.get("general", "download_folder"), pypack.folder) else: dl_folder = self.pyload.config.get("general", "download_folder") - args = [pypack.pid, pypack.name, dl_folder, pypack.password] + args = [pdata.pid, pdata.name, dl_folder, pdata.password] self._call("package_deleted", args) diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py index f55ae90ed..211ad7fb3 100644 --- a/module/plugins/internal/Account.py +++ b/module/plugins/internal/Account.py @@ -20,8 +20,8 @@ class Account(Plugin): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - LOGIN_TIMEOUT = 30 * 60 #: Relogin account every 30 minutes - TUNE_TIMEOUT = True #: Automatically tune relogin interval + LOGIN_TIMEOUT = 30 * 60 #: Relogin account every 30 minutes + TUNE_TIMEOUT = True #: Automatically tune relogin interval PERIODICAL_INTERVAL = None @@ -44,13 +44,6 @@ class Account(Plugin): self.init() - def init(self): - """ - Initialize additional data structures - """ - pass - - def set_interval(self, value): newinterval = max(0, self.PERIODICAL_INTERVAL, value) diff --git a/module/plugins/internal/Base.py b/module/plugins/internal/Base.py index bb2c14323..71b67dfff 100644 --- a/module/plugins/internal/Base.py +++ b/module/plugins/internal/Base.py @@ -124,13 +124,6 @@ class Base(Plugin): pass - def init(self): - """ - Initialize the plugin (in addition to `__init__`) - """ - pass - - def setup_base(self): pass diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py index e0518f67b..71eee0659 100644 --- a/module/plugins/internal/Captcha.py +++ b/module/plugins/internal/Captcha.py @@ -29,13 +29,6 @@ class Captcha(Plugin): self.init() - def init(self): - """ - Initialize additional data structures - """ - pass - - def _log(self, level, plugintype, pluginname, messages): messages = (self.__name__,) + messages return self.plugin._log(level, plugintype, self.plugin.__name__, messages) diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 81ee99dd8..6c26e3a7c 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -110,13 +110,6 @@ class Extractor(Plugin): self.init() - def init(self): - """ - Initialize additional data structures - """ - pass - - def _log(self, level, plugintype, pluginname, messages): messages = (self.__name__,) + messages return self.plugin._log(level, plugintype, self.plugin.__name__, messages) diff --git a/module/plugins/internal/Hoster.py b/module/plugins/internal/Hoster.py index 6b4b0030a..10cfe6262 100644 --- a/module/plugins/internal/Hoster.py +++ b/module/plugins/internal/Hoster.py @@ -14,7 +14,7 @@ from module.plugins.internal.utils import encode, exists, fixurl, fs_join, parse class Hoster(Base): __name__ = "Hoster" __type__ = "hoster" - __version__ = "0.43" + __version__ = "0.44" __status__ = "testing" __pattern__ = r'^unmatchable$' @@ -226,6 +226,7 @@ class Hoster(Base): except BadHeader, e: self.req.code = e.code + raise BadHeader(e) finally: self.pyfile.size = self.req.size @@ -238,7 +239,7 @@ class Hoster(Base): except OSError, e: self.log_debug(_("Error removing `%s`") % bad_file, e) - finally: + else: return "" #@TODO: Recheck in 0.4.10 diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 1f87359ac..82e2f81c5 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -24,7 +24,7 @@ class MultiHoster(SimpleHoster): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - PLUGIN_NAME = None + PLUGIN_NAME = None LEECH_HOSTER = False LOGIN_ACCOUNT = True diff --git a/module/plugins/internal/Notifier.py b/module/plugins/internal/Notifier.py index 5b1743300..055f5a929 100644 --- a/module/plugins/internal/Notifier.py +++ b/module/plugins/internal/Notifier.py @@ -24,7 +24,7 @@ class Notifier(Addon): __description__ = """Base notifier plugin""" __license__ = "GPLv3" - __authors__ = [("Walter Purcaro", "vuolter@gmail.com" )] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] def init(self): diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py index c783b816f..e3044f6c3 100644 --- a/module/plugins/internal/OCR.py +++ b/module/plugins/internal/OCR.py @@ -34,13 +34,6 @@ class OCR(Plugin): self.init() - def init(self): - """ - Initialize additional data structures - """ - pass - - def _log(self, level, plugintype, pluginname, messages): messages = (self.__name__,) + messages return self.plugin._log(level, plugintype, self.plugin.__name__, messages) diff --git a/module/plugins/internal/SevenZip.py b/module/plugins/internal/SevenZip.py index 9a7794b0c..bf33332ea 100644 --- a/module/plugins/internal/SevenZip.py +++ b/module/plugins/internal/SevenZip.py @@ -10,6 +10,7 @@ from module.plugins.internal.utils import fs_join, renice class SevenZip(UnRar): __name__ = "SevenZip" + __type__ = "extractor" __version__ = "0.18" __status__ = "testing" @@ -19,14 +20,13 @@ class SevenZip(UnRar): ("Michael Nowak" , None )] - CMD = "7z" - EXTENSIONS = [".7z", ".xz", ".zip", ".gz", ".gzip", ".tgz", ".bz2", ".bzip2", - ".tbz2", ".tbz", ".tar", ".wim", ".swm", ".lzma", ".rar", ".cab", - ".arj", ".z", ".taz", ".cpio", ".rpm", ".deb", ".lzh", ".lha", - ".chm", ".chw", ".hxs", ".iso", ".msi", ".doc", ".xls", ".ppt", - ".dmg", ".xar", ".hfs", ".exe", ".ntfs", ".fat", ".vhd", ".mbr", - ".squashfs", ".cramfs", ".scap"] - + CMD = "7z" + EXTENSIONS = [".7z", ".xz", ".zip", ".gz", ".gzip", ".tgz", ".bz2", ".bzip2", + ".tbz2", ".tbz", ".tar", ".wim", ".swm", ".lzma", ".rar", ".cab", + ".arj", ".z", ".taz", ".cpio", ".rpm", ".deb", ".lzh", ".lha", + ".chm", ".chw", ".hxs", ".iso", ".msi", ".doc", ".xls", ".ppt", + ".dmg", ".xar", ".hfs", ".exe", ".ntfs", ".fat", ".vhd", ".mbr", + ".squashfs", ".cramfs", ".scap"] #@NOTE: there are some more uncovered 7z formats re_filelist = re.compile(r'([\d\:]+)\s+([\d\:]+)\s+([\w\.]+)\s+(\d+)\s+(\d+)\s+(.+)') diff --git a/module/plugins/internal/UnRar.py b/module/plugins/internal/UnRar.py index 12855f712..963ca2a2e 100644 --- a/module/plugins/internal/UnRar.py +++ b/module/plugins/internal/UnRar.py @@ -11,6 +11,7 @@ from module.plugins.internal.utils import decode, fs_join, renice class UnRar(Extractor): __name__ = "UnRar" + __type__ = "extractor" __version__ = "1.29" __status__ = "testing" @@ -21,8 +22,8 @@ class UnRar(Extractor): ("Immenz" , "immenz@gmx.net" )] - CMD = "unrar" - EXTENSIONS = [".rar"] + CMD = "unrar" + EXTENSIONS = [".rar"] re_multipart = re.compile(r'\.(part|r)(\d+)(?:\.rar)?(\.rev|\.bad)?', re.I) diff --git a/module/plugins/internal/UnZip.py b/module/plugins/internal/UnZip.py index ee35c55d5..2c4e8e475 100644 --- a/module/plugins/internal/UnZip.py +++ b/module/plugins/internal/UnZip.py @@ -11,6 +11,7 @@ from module.plugins.internal.Extractor import Extractor, ArchiveError, CRCError, class UnZip(Extractor): __name__ = "UnZip" + __type__ = "extractor" __version__ = "1.20" __status__ = "testing" diff --git a/module/plugins/internal/XFSAccount.py b/module/plugins/internal/XFSAccount.py index e09f7dddc..1b424c964 100644 --- a/module/plugins/internal/XFSAccount.py +++ b/module/plugins/internal/XFSAccount.py @@ -26,25 +26,25 @@ class XFSAccount(MultiAccount): ("Walter Purcaro", "vuolter@gmail.com" )] - PLUGIN_DOMAIN = None - PLUGIN_URL = None - LOGIN_URL = None + PLUGIN_DOMAIN = None + PLUGIN_URL = None + LOGIN_URL = None - COOKIES = True + COOKIES = True - PREMIUM_PATTERN = r'\(Premium only\)' + PREMIUM_PATTERN = r'\(Premium only\)' - VALID_UNTIL_PATTERN = r'Premium.[Aa]ccount expire:.*?(\d{1,2} [\w^_]+ \d{4})' + VALID_UNTIL_PATTERN = r'Premium.[Aa]ccount expire:.*?(\d{1,2} [\w^_]+ \d{4})' - TRAFFIC_LEFT_PATTERN = r'Traffic available today:.*?<b>\s*(?P<S>[\d.,]+|[Uu]nlimited)\s*(?:(?P<U>[\w^_]+)\s*)?</b>' - TRAFFIC_LEFT_UNIT = "MB" #: Used only if no group <U> was found + TRAFFIC_LEFT_PATTERN = r'Traffic available today:.*?<b>\s*(?P<S>[\d.,]+|[Uu]nlimited)\s*(?:(?P<U>[\w^_]+)\s*)?</b>' + TRAFFIC_LEFT_UNIT = "MB" #: Used only if no group <U> was found LEECH_TRAFFIC_PATTERN = r'Leech Traffic left:<b>.*?(?P<S>[\d.,]+|[Uu]nlimited)\s*(?:(?P<U>[\w^_]+)\s*)?</b>' LEECH_TRAFFIC_UNIT = "MB" #: Used only if no group <U> was found - LOGIN_FAIL_PATTERN = r'Incorrect Login or Password|account was banned|Error<' - LOGIN_BAN_PATTERN = r'>(Your IP.+?)<a' - LOGIN_SKIP_PATTERN = r'op=logout' + LOGIN_FAIL_PATTERN = r'Incorrect Login or Password|account was banned|Error<' + LOGIN_BAN_PATTERN = r'>(Your IP.+?)<a' + LOGIN_SKIP_PATTERN = r'op=logout' def set_xfs_cookie(self): diff --git a/module/plugins/internal/XFSCrypter.py b/module/plugins/internal/XFSCrypter.py index d295d2e9a..d3ddadd2f 100644 --- a/module/plugins/internal/XFSCrypter.py +++ b/module/plugins/internal/XFSCrypter.py @@ -21,12 +21,12 @@ class XFSCrypter(SimpleCrypter): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - PLUGIN_DOMAIN = None + PLUGIN_DOMAIN = None - URL_REPLACEMENTS = [(r'&?per_page=\d+', ""), (r'[?/&]+$', ""), (r'(.+/[^?]+)$', r'\1?'), (r'$', r'&per_page=10000')] + URL_REPLACEMENTS = [(r'&?per_page=\d+', ""), (r'[?/&]+$', ""), (r'(.+/[^?]+)$', r'\1?'), (r'$', r'&per_page=10000')] - NAME_PATTERN = r'<[Tt]itle>.*?\: (?P<N>.+) folder</[Tt]itle>' - LINK_PATTERN = r'<(?:td|TD).*?>\s*(?:<.+>\s*)?<a href="(.+?)".*?>.+?(?:</a>)?\s*(?:<.+>\s*)?</(?:td|TD)>' + NAME_PATTERN = r'<[Tt]itle>.*?\: (?P<N>.+) folder</[Tt]itle>' + LINK_PATTERN = r'<(?:td|TD).*?>\s*(?:<.+>\s*)?<a href="(.+?)".*?>.+?(?:</a>)?\s*(?:<.+>\s*)?</(?:td|TD)>' OFFLINE_PATTERN = r'>\s*(No such user|\w+ (Not Found|file (was|has been) removed|no longer available))' TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' diff --git a/module/plugins/internal/XFSHoster.py b/module/plugins/internal/XFSHoster.py index ba851f25d..e3f2cab51 100644 --- a/module/plugins/internal/XFSHoster.py +++ b/module/plugins/internal/XFSHoster.py @@ -29,30 +29,30 @@ class XFSHoster(SimpleHoster): ("Walter Purcaro", "vuolter@gmail.com" )] - PLUGIN_DOMAIN = None + PLUGIN_DOMAIN = None - LEECH_HOSTER = True #@NOTE: hould be set to `False` by default for safe, but I am lazy... + LEECH_HOSTER = True #@NOTE: hould be set to `False` by default for safe, but I am lazy... - NAME_PATTERN = r'(Filename[ ]*:[ ]*</b>(</td><td nowrap>)?|name="fname"[ ]+value="|<[\w^_]+ class="(file)?name">)\s*(?P<N>.+?)(\s*<|")' - SIZE_PATTERN = r'(Size[ ]*:[ ]*</b>(</td><td>)?|File:.*>|</font>\s*\(|<[\w^_]+ class="size">)\s*(?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)' + NAME_PATTERN = r'(Filename[ ]*:[ ]*</b>(</td><td nowrap>)?|name="fname"[ ]+value="|<[\w^_]+ class="(file)?name">)\s*(?P<N>.+?)(\s*<|")' + SIZE_PATTERN = r'(Size[ ]*:[ ]*</b>(</td><td>)?|File:.*>|</font>\s*\(|<[\w^_]+ class="size">)\s*(?P<S>[\d.,]+)\s*(?P<U>[\w^_]+)' - OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed|no longer available)' - TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' + OFFLINE_PATTERN = r'>\s*\w+ (Not Found|file (was|has been) removed|no longer available)' + TEMP_OFFLINE_PATTERN = r'>\s*\w+ server (is in )?(maintenance|maintainance)' - WAIT_PATTERN = r'<span id="countdown_str".*>(\d+)</span>|id="countdown" value=".*?(\d+).*?"' - PREMIUM_ONLY_PATTERN = r'>This file is available for Premium Users only' - HAPPY_HOUR_PATTERN = r'>[Hh]appy hour' - ERROR_PATTERN = r'(?:class=["\']err["\'].*?>|<[Cc]enter><b>|>Error</td>|>\(ERROR:)(?:\s*<.+?>\s*)*(.+?)(?:["\']|<|\))' + WAIT_PATTERN = r'<span id="countdown_str".*>(\d+)</span>|id="countdown" value=".*?(\d+).*?"' + PREMIUM_ONLY_PATTERN = r'>This file is available for Premium Users only' + HAPPY_HOUR_PATTERN = r'>[Hh]appy hour' + ERROR_PATTERN = r'(?:class=["\']err["\'].*?>|<[Cc]enter><b>|>Error</td>|>\(ERROR:)(?:\s*<.+?>\s*)*(.+?)(?:["\']|<|\))' - LINK_LEECH_PATTERN = r'<h2>Download Link</h2>\s*<textarea[^>]*>([^<]+)' + LINK_LEECH_PATTERN = r'<h2>Download Link</h2>\s*<textarea[^>]*>([^<]+)' CAPTCHA_PATTERN = r'(https?://[^"\']+?/captchas?/[^"\']+)' CAPTCHA_BLOCK_PATTERN = r'>Enter code.*?<div.*?>(.+?)</div>' RECAPTCHA_PATTERN = None SOLVEMEDIA_PATTERN = None - FORM_PATTERN = None - FORM_INPUTS_MAP = None #: Dict passed as `input_names` to `parse_html_form` + FORM_PATTERN = None + FORM_INPUTS_MAP = None #: Dict passed as `input_names` to `parse_html_form` def setup(self): @@ -216,7 +216,6 @@ class XFSHoster(SimpleHoster): wait_time = int(m.group(1)) self.set_wait(wait_time) self.set_reconnect(False) - self.handle_captcha(inputs) self.wait() else: |