diff options
Diffstat (limited to 'module')
37 files changed, 333 insertions, 425 deletions
diff --git a/module/plugins/hooks/AndroidPhoneNotify.py b/module/plugins/hooks/AndroidPhoneNotify.py index 1cea0c994..e6ddac546 100644 --- a/module/plugins/hooks/AndroidPhoneNotify.py +++ b/module/plugins/hooks/AndroidPhoneNotify.py @@ -2,10 +2,10 @@ import time -from module.plugins.internal.Hook import Hook, Expose +from module.plugins.internal.Addon import Addon, Expose -class AndroidPhoneNotify(Hook): +class AndroidPhoneNotify(Addon): __name__ = "AndroidPhoneNotify" __type__ = "hook" __version__ = "0.10" @@ -26,12 +26,7 @@ class AndroidPhoneNotify(Hook): ("Walter Purcaro", "vuolter@gmail.com" )] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - + def init(self): self.event_list = ["plugin_updated"] self.event_map = {'allDownloadsProcessed': "all_downloads_processed"} diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index cb9d5aaa6..8b19af84c 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -9,11 +9,11 @@ try: except ImportError: pass -from module.plugins.internal.Hook import Hook, Expose, threaded +from module.plugins.internal.Addon import Addon, Expose, threaded from module.utils import fs_encode, save_join as fs_join -class AntiVirus(Hook): +class AntiVirus(Addon): __name__ = "AntiVirus" __type__ = "hook" __version__ = "0.11" @@ -32,13 +32,6 @@ class AntiVirus(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - @Expose @threaded def scan(self, pyfile, thread): diff --git a/module/plugins/hooks/BypassCaptcha.py b/module/plugins/hooks/BypassCaptcha.py index 42c30ba25..2607ac5ad 100644 --- a/module/plugins/hooks/BypassCaptcha.py +++ b/module/plugins/hooks/BypassCaptcha.py @@ -40,8 +40,6 @@ class BypassCaptcha(Hook): ("zoidberg" , "zoidberg@mujmail.cz" )] - interval = 0 #@TODO: Remove in 0.4.10 - PYLOAD_KEY = "4f771155b640970d5607f919a615bdefc67e7d32" SUBMIT_URL = "http://bypasscaptcha.com/upload.php" @@ -49,10 +47,6 @@ class BypassCaptcha(Hook): GETCREDITS_URL = "http://bypasscaptcha.com/ex_left.php" - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def get_credits(self): res = self.load(self.GETCREDITS_URL, post={"key": self.get_config('passkey')}) diff --git a/module/plugins/hooks/Captcha9Kw.py b/module/plugins/hooks/Captcha9Kw.py index 0ef67e54d..ec989ae51 100644 --- a/module/plugins/hooks/Captcha9Kw.py +++ b/module/plugins/hooks/Captcha9Kw.py @@ -33,15 +33,9 @@ class Captcha9Kw(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - interval = 0 #@TODO: Remove in 0.4.10 - API_URL = "https://www.9kw.eu/index.cgi" - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def get_credits(self): res = self.load(self.API_URL, get={'apikey': self.get_config('passkey'), diff --git a/module/plugins/hooks/CaptchaBrotherhood.py b/module/plugins/hooks/CaptchaBrotherhood.py index d35bc720d..1265fc0ae 100644 --- a/module/plugins/hooks/CaptchaBrotherhood.py +++ b/module/plugins/hooks/CaptchaBrotherhood.py @@ -50,15 +50,9 @@ class CaptchaBrotherhood(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - interval = 0 #@TODO: Remove in 0.4.10 - API_URL = "http://www.captchabrotherhood.com/" - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def get_credits(self): res = self.load(self.API_URL + "askCredits.aspx", get={"username": self.get_config('username'), "password": self.get_config('password')}) diff --git a/module/plugins/hooks/Checksum.py b/module/plugins/hooks/Checksum.py index 4d2dbf576..681816a0f 100644 --- a/module/plugins/hooks/Checksum.py +++ b/module/plugins/hooks/Checksum.py @@ -7,7 +7,7 @@ import os import re import zlib -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon from module.utils import save_join as fs_join, fs_encode @@ -35,7 +35,7 @@ def compute_checksum(local_file, algorithm): return None -class Checksum(Hook): +class Checksum(Addon): __name__ = "Checksum" __type__ = "hook" __version__ = "0.18" @@ -53,7 +53,6 @@ class Checksum(Hook): ("stickell" , "l.stickell@yahoo.it")] - interval = 0 #@TODO: Remove in 0.4.10 methods = {'sfv' : 'crc32', 'crc' : 'crc32', 'hash': 'md5'} @@ -68,8 +67,7 @@ class Checksum(Hook): self.log_info(_("Checksum validation is disabled in plugin configuration")) - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + def init(self): self.algorithms = sorted( getattr(hashlib, "algorithms", ("md5", "sha1", "sha224", "sha256", "sha384", "sha512")), reverse=True) diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index c361d51b2..61e28f469 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -10,7 +10,7 @@ except ImportError: from threading import Lock -from module.plugins.internal.Hook import Hook, threaded +from module.plugins.internal.Addon import Addon, threaded def forward(source, destination): @@ -26,7 +26,7 @@ def forward(source, destination): #@TODO: IPv6 support -class ClickAndLoad(Hook): +class ClickAndLoad(Addon): __name__ = "ClickAndLoad" __type__ = "hook" __version__ = "0.45" @@ -41,13 +41,6 @@ class ClickAndLoad(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def activate(self): if not self.core.config.get("webinterface", "activated"): return diff --git a/module/plugins/hooks/DeathByCaptcha.py b/module/plugins/hooks/DeathByCaptcha.py index 43bad2d0b..6727107ca 100644 --- a/module/plugins/hooks/DeathByCaptcha.py +++ b/module/plugins/hooks/DeathByCaptcha.py @@ -63,15 +63,9 @@ class DeathByCaptcha(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - interval = 0 #@TODO: Remove in 0.4.10 - API_URL = "http://api.dbcapi.me/api/" - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def api_response(self, api="captcha", post=False, multipart=False): req = get_request() req.c.setopt(pycurl.HTTPHEADER, ["Accept: application/json", "User-Agent: pyLoad %s" % self.core.version]) diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 5c613f5c6..2143fe19a 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from module.database import style -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon -class DeleteFinished(Hook): +class DeleteFinished(Addon): __name__ = "DeleteFinished" __type__ = "hook" __version__ = "1.14" @@ -21,8 +21,7 @@ class DeleteFinished(Hook): ## overwritten methods ## - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + def init(self): # self.event_map = {'pluginConfigChanged': "plugin_config_changed"} self.interval = self.MIN_CHECK_INTERVAL diff --git a/module/plugins/hooks/DownloadScheduler.py b/module/plugins/hooks/DownloadScheduler.py index e1114d615..bd67dec67 100644 --- a/module/plugins/hooks/DownloadScheduler.py +++ b/module/plugins/hooks/DownloadScheduler.py @@ -3,10 +3,10 @@ import re import time -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon -class DownloadScheduler(Hook): +class DownloadScheduler(Addon): __name__ = "DownloadScheduler" __type__ = "hook" __version__ = "0.24" @@ -20,14 +20,6 @@ class DownloadScheduler(Hook): ("stickell", "l.stickell@yahoo.it")] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - self.cb = None #: Callback to scheduler job; will be by removed hookmanager when hook unloaded - - def activate(self): self.update_schedule() diff --git a/module/plugins/hooks/ExpertDecoders.py b/module/plugins/hooks/ExpertDecoders.py index 17890f691..baf880644 100644 --- a/module/plugins/hooks/ExpertDecoders.py +++ b/module/plugins/hooks/ExpertDecoders.py @@ -26,15 +26,9 @@ class ExpertDecoders(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - interval = 0 #@TODO: Remove in 0.4.10 - API_URL = "http://www.fasttypers.org/imagepost.ashx" - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def get_credits(self): res = self.load(self.API_URL, post={"key": self.get_config('passkey'), "action": "balance"}) diff --git a/module/plugins/hooks/ExternalScripts.py b/module/plugins/hooks/ExternalScripts.py index 6bf3cf347..2a96d9e59 100644 --- a/module/plugins/hooks/ExternalScripts.py +++ b/module/plugins/hooks/ExternalScripts.py @@ -3,11 +3,11 @@ import os import subprocess -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon from module.utils import fs_encode, save_join as fs_join -class ExternalScripts(Hook): +class ExternalScripts(Addon): __name__ = "ExternalScripts" __type__ = "hook" __version__ = "0.43" @@ -23,11 +23,8 @@ class ExternalScripts(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {'oldip': None} + def init(self): + self.info['oldip'] = None self.scripts = {} self.event_list = ["archive_extract_failed", "archive_extracted" , diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index ad9f67a1a..cead3595c 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -55,7 +55,7 @@ if os.name != "nt": from grp import getgrnam from pwd import getpwnam -from module.plugins.internal.Hook import Hook, Expose, threaded +from module.plugins.internal.Addon import Addon, Expose, threaded from module.plugins.internal.Plugin import replace_patterns from module.plugins.internal.Extractor import ArchiveError, CRCError, PasswordError from module.utils import fs_encode, save_join as fs_join, uniqify @@ -109,7 +109,7 @@ class ArchiveQueue(object): return self.set(queue) -class ExtractArchive(Hook): +class ExtractArchive(Addon): __name__ = "ExtractArchive" __type__ = "hook" __version__ = "1.46" @@ -141,8 +141,7 @@ class ExtractArchive(Hook): NAME_REPLACEMENTS = [(r'\.part\d+\.rar$', ".part.rar")] - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + def init(self): self.event_map = {'allDownloadsProcessed': "all_downloads_processed", 'packageDeleted' : "package_deleted" } diff --git a/module/plugins/hooks/HotFolder.py b/module/plugins/hooks/HotFolder.py index 8e1d1c54f..b98f325fa 100644 --- a/module/plugins/hooks/HotFolder.py +++ b/module/plugins/hooks/HotFolder.py @@ -7,11 +7,11 @@ import time from shutil import move -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon from module.utils import fs_encode, save_join as fs_join -class HotFolder(Hook): +class HotFolder(Addon): __name__ = "HotFolder" __type__ = "hook" __version__ = "0.16" @@ -26,8 +26,7 @@ class HotFolder(Hook): __authors__ = [("RaNaN", "RaNaN@pyload.de")] - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + def init(self): self.interval = 30 diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py index 5d8376b4e..e31435e96 100644 --- a/module/plugins/hooks/IRCInterface.py +++ b/module/plugins/hooks/IRCInterface.py @@ -11,11 +11,11 @@ from select import select from threading import Thread from module.Api import PackageDoesNotExists, FileDoesNotExists -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon from module.utils import formatSize -class IRCInterface(Thread, Hook): +class IRCInterface(Thread, Addon): __name__ = "IRCInterface" __type__ = "hook" __version__ = "0.15" @@ -36,12 +36,9 @@ class IRCInterface(Thread, Hook): __authors__ = [("Jeix", "Jeix@hasnomail.com")] - interval = 0 #@TODO: Remove in 0.4.10 - - def __init__(self, core, manager): Thread.__init__(self) - Hook.__init__(self, core, manager) + Addon.__init__(self, core, manager) self.set_daemon(True) diff --git a/module/plugins/hooks/ImageTyperz.py b/module/plugins/hooks/ImageTyperz.py index b46728a0d..2e4cae903 100644 --- a/module/plugins/hooks/ImageTyperz.py +++ b/module/plugins/hooks/ImageTyperz.py @@ -44,17 +44,11 @@ class ImageTyperz(Hook): ("zoidberg", "zoidberg@mujmail.cz")] - interval = 0 #@TODO: Remove in 0.4.10 - SUBMIT_URL = "http://captchatypers.com/Forms/UploadFileAndGetTextNEW.ashx" RESPOND_URL = "http://captchatypers.com/Forms/SetBadImage.ashx" GETCREDITS_URL = "http://captchatypers.com/Forms/RequestBalance.ashx" - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def get_credits(self): res = self.load(self.GETCREDITS_URL, post={'action': "REQUESTBALANCE", diff --git a/module/plugins/hooks/JustPremium.py b/module/plugins/hooks/JustPremium.py index 706de4d81..b30625e9a 100644 --- a/module/plugins/hooks/JustPremium.py +++ b/module/plugins/hooks/JustPremium.py @@ -2,10 +2,10 @@ import re -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon -class JustPremium(Hook): +class JustPremium(Addon): __name__ = "JustPremium" __type__ = "hook" __version__ = "0.24" @@ -20,11 +20,7 @@ class JustPremium(Hook): ("immenz" , "immenz@gmx.net" )] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + def init(self): self.event_map = {'linksAdded': "links_added"} diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py index 9aa70aa71..b5245cc14 100644 --- a/module/plugins/hooks/MergeFiles.py +++ b/module/plugins/hooks/MergeFiles.py @@ -6,11 +6,11 @@ import os import re import traceback -from module.plugins.internal.Hook import Hook, threaded +from module.plugins.internal.Addon import Addon, threaded from module.utils import save_join as fs_join -class MergeFiles(Hook): +class MergeFiles(Addon): __name__ = "MergeFiles" __type__ = "hook" __version__ = "0.16" @@ -22,15 +22,9 @@ class MergeFiles(Hook): __authors__ = [("and9000", "me@has-no-mail.com")] - interval = 0 #@TODO: Remove in 0.4.10 - BUFFER_SIZE = 4096 - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - @threaded def package_finished(self, pack): files = {} diff --git a/module/plugins/hooks/MultiHome.py b/module/plugins/hooks/MultiHome.py index 7e4b5e583..bfb420aea 100644 --- a/module/plugins/hooks/MultiHome.py +++ b/module/plugins/hooks/MultiHome.py @@ -2,10 +2,10 @@ import time -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon -class MultiHome(Hook): +class MultiHome(Addon): __name__ = "MultiHome" __type__ = "hook" __version__ = "0.14" @@ -17,11 +17,7 @@ class MultiHome(Hook): __authors__ = [("mkaay", "mkaay@mkaay.de")] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + def init(self): self.register = {} self.interfaces = [] diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py index 52752861f..8740ccd7d 100644 --- a/module/plugins/hooks/RestartFailed.py +++ b/module/plugins/hooks/RestartFailed.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon -class RestartFailed(Hook): +class RestartFailed(Addon): __name__ = "RestartFailed" __type__ = "hook" __version__ = "1.60" @@ -34,8 +34,7 @@ class RestartFailed(Hook): self.core.api.restartFailed() - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + def init(self): # self.event_map = {'pluginConfigChanged': "plugin_config_changed"} self.interval = self.MIN_CHECK_INTERVAL diff --git a/module/plugins/hooks/SkipRev.py b/module/plugins/hooks/SkipRev.py index 5ec6290ac..2123a6543 100644 --- a/module/plugins/hooks/SkipRev.py +++ b/module/plugins/hooks/SkipRev.py @@ -7,13 +7,13 @@ import urlparse from types import MethodType from module.PyFile import PyFile -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon -class SkipRev(Hook): +class SkipRev(Addon): __name__ = "SkipRev" __type__ = "hook" - __version__ = "0.32" + __version__ = "0.33" __config__ = [("mode" , "Auto;Manual", "Choose recovery archives to skip" , "Auto"), ("revtokeep", "int" , "Number of recovery archives to keep for package", 0 )] @@ -23,26 +23,15 @@ class SkipRev(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - @staticmethod - def _setup(self): - self.pyfile.plugin._setup() + def _init(self): + self.pyfile.plugin._init() if self.pyfile.hasStatus("skipped"): self.skip(self.pyfile.statusname or self.pyfile.pluginname) def _name(self, pyfile): - if hasattr(pyfile.pluginmodule, "getInfo"): #@NOTE: getInfo is deprecated in 0.4.10 - return pyfile.pluginmodule.get_info([pyfile.url]).next()[0] - else: - self.log_warning(_("Unable to grab file name")) - return urlparse.urlparse(urllib.unquote(pyfile.url)).path.split('/')[-1] + return pyfile.pluginclass.get_info(pyfile.url)['name'] def _pyfile(self, link): @@ -78,10 +67,10 @@ class SkipRev(Hook): pyfile.setCustomStatus("SkipRev", "skipped") - if not hasattr(pyfile.plugin, "_setup"): + if not hasattr(pyfile.plugin, "_init"): #: Work-around: inject status checker inside the preprocessing routine of the plugin - pyfile.plugin._setup = pyfile.plugin.setup - pyfile.plugin.setup = MethodType(self._setup, pyfile.plugin) + pyfile.plugin._init = pyfile.plugin.init + pyfile.plugin.init = MethodType(self._init, pyfile.plugin) def download_failed(self, pyfile): diff --git a/module/plugins/hooks/UnSkipOnFail.py b/module/plugins/hooks/UnSkipOnFail.py index 5507cd20f..c8e58294c 100644 --- a/module/plugins/hooks/UnSkipOnFail.py +++ b/module/plugins/hooks/UnSkipOnFail.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from module.PyFile import PyFile -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon -class UnSkipOnFail(Hook): +class UnSkipOnFail(Addon): __name__ = "UnSkipOnFail" __type__ = "hook" __version__ = "0.09" @@ -16,13 +16,6 @@ class UnSkipOnFail(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def download_failed(self, pyfile): #: Check if pyfile is still "failed", maybe might has been restarted in meantime if pyfile.status != 8: diff --git a/module/plugins/hooks/UpdateManager.py b/module/plugins/hooks/UpdateManager.py index 6f6ad9838..4ec981ac0 100644 --- a/module/plugins/hooks/UpdateManager.py +++ b/module/plugins/hooks/UpdateManager.py @@ -9,7 +9,7 @@ import time from operator import itemgetter -from module.plugins.internal.Hook import Expose, Hook, threaded +from module.plugins.internal.Addon import Expose, Addon, threaded from module.utils import save_join as fs_join @@ -25,7 +25,7 @@ def exists(path): return False -class UpdateManager(Hook): +class UpdateManager(Addon): __name__ = "UpdateManager" __type__ = "hook" __version__ = "0.54" @@ -59,7 +59,7 @@ class UpdateManager(Hook): self.init_periodical() - def setup(self): + def init(self): self.info = {'pyload': False, 'version': None, 'plugins': False, 'last_check': time.time()} self.mtimes = {} #: Store modification time for each plugin diff --git a/module/plugins/hooks/UserAgentSwitcher.py b/module/plugins/hooks/UserAgentSwitcher.py index fdfe4b673..637f6c3ad 100644 --- a/module/plugins/hooks/UserAgentSwitcher.py +++ b/module/plugins/hooks/UserAgentSwitcher.py @@ -2,10 +2,10 @@ import pycurl -from module.plugins.internal.Hook import Hook +from module.plugins.internal.Addon import Addon -class UserAgentSwitcher(Hook): +class UserAgentSwitcher(Addon): __name__ = "UserAgentSwitcher" __type__ = "hook" __version__ = "0.10" @@ -20,13 +20,6 @@ class UserAgentSwitcher(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - - def download_preparing(self, pyfile): connecttimeout = self.get_config('connecttimeout') maxredirs = self.get_config('maxredirs') diff --git a/module/plugins/hooks/WindowsPhoneNotify.py b/module/plugins/hooks/WindowsPhoneNotify.py index 511b4b568..b4b4d2658 100644 --- a/module/plugins/hooks/WindowsPhoneNotify.py +++ b/module/plugins/hooks/WindowsPhoneNotify.py @@ -3,10 +3,10 @@ import httplib import time -from module.plugins.internal.Hook import Hook, Expose +from module.plugins.internal.Addon import Addon, Expose -class WindowsPhoneNotify(Hook): +class WindowsPhoneNotify(Addon): __name__ = "WindowsPhoneNotify" __type__ = "hook" __version__ = "0.12" @@ -28,12 +28,7 @@ class WindowsPhoneNotify(Hook): ("Walter Purcaro", "vuolter@gmail.com" )] - interval = 0 #@TODO: Remove in 0.4.10 - - - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 - + def init(self): self.event_list = ["plugin_updated"] self.event_map = {'allDownloadsProcessed': "all_downloads_processed"} diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 45acc9976..5829378d8 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -22,7 +22,6 @@ class XFileSharingPro(Hook): __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] - interval = 0 #@TODO: Remove in 0.4.10 regexp = {'hoster' : (r'https?://(?:www\.)?(?:\w+\.)*?(?P<DOMAIN>(?:[\d.]+|[\w\-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:embed-)?\w{12}(?:\W|$)', r'https?://(?:[^/]+\.)?(?P<DOMAIN>%s)/(?:embed-)?\w+'), 'crypter': (r'https?://(?:www\.)?(?:\w+\.)*?(?P<DOMAIN>(?:[\d.]+|[\w\-^_]{3,}(?:\.[a-zA-Z]{2,}){1,2})(?:\:\d+)?)/(?:user|folder)s?/\w+', @@ -48,8 +47,7 @@ class XFileSharingPro(Hook): # self.load_pattern() - def setup(self): - self.info = {} #@TODO: Remove in 0.4.10 + def init(self): # self.event_map = {'pluginConfigChanged': "plugin_config_changed"} diff --git a/module/plugins/internal/Account.py b/module/plugins/internal/Account.py index 534f5607d..7bf8964ad 100644 --- a/module/plugins/internal/Account.py +++ b/module/plugins/internal/Account.py @@ -41,6 +41,9 @@ class Account(Plugin): def init(self): + """ + Initialize additional data structures + """ pass diff --git a/module/plugins/internal/Addon.py b/module/plugins/internal/Addon.py new file mode 100644 index 000000000..f3da5272f --- /dev/null +++ b/module/plugins/internal/Addon.py @@ -0,0 +1,242 @@ +# -*- coding: utf-8 -*- + +import traceback + +from module.plugins.internal.Plugin import Plugin + + +class Expose(object): + """ + Used for decoration to declare rpc services + """ + def __new__(cls, f, *args, **kwargs): + hookManager.addRPC(f.__module__, f.func_name, f.func_doc) + return f + + +def threaded(fn): + + def run(*args, **kwargs): + hookManager.startThread(fn, *args, **kwargs) + + return run + + +class Addon(Plugin): + __name__ = "Addon" + __type__ = "hook" #@TODO: Change to `addon` in 0.4.10 + __version__ = "0.01" + + __config__ = [] #: [("name", "type", "desc", "default")] + __threaded__ = [] #@TODO: Remove in 0.4.10 + + __description__ = """Base addon plugin""" + __license__ = "GPLv3" + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + + def __init__(self, core, manager): + super(Addon, self).__init__(core) + + #: `HookManager` + self.manager = manager + + #: Automatically register event listeners for functions, attribute will be deleted dont use it yourself + self.event_map = {} + + #: Deprecated alternative to event_map + #: List of events the plugin can handle, name the functions exactly like eventname. + self.event_list = [] #@NOTE: dont make duplicate entries in event_map + + #: Callback of periodical job task, used by HookManager + self.cb = None + self.interval = 60 + + self.init() + self.init_events() + + + def init_events(self): + if self.event_map: + for event, funcs in self.event_map.iteritems(): + if type(funcs) in (list, tuple): + for f in funcs: + self.manager.addEvent(event, getattr(self, f)) + else: + self.manager.addEvent(event, getattr(self, funcs)) + + #: Delete for various reasons + self.event_map = None + + if self.event_list: + self.log_debug("Deprecated method `event_list`, use `event_map` instead") + + for f in self.event_list: + self.manager.addEvent(f, getattr(self, f)) + + self.event_list = None + + + def init_periodical(self, delay=0, threaded=False): + self.cb = self.core.scheduler.addJob(max(0, delay), self._periodical, [threaded], threaded=threaded) + + + #: Deprecated method, use `init_periodical` instead + def initPeriodical(self, *args, **kwargs): + return self.init_periodical(*args, **kwargs) + + + def _periodical(self, threaded): + if self.interval < 0: + self.cb = None + return + + try: + self.periodical() + + except Exception, e: + self.log_error(_("Error executing addon: %s") % e) + if self.core.debug: + traceback.print_exc() + + self.cb = self.core.scheduler.addJob(self.interval, self._periodical, [threaded], threaded=threaded) + + + def periodical(self): + pass + + + def __repr__(self): + return "<Addon %s>" % self.__name__ + + + def is_activated(self): + """ + Checks if addon is activated + """ + return self.get_config("activated") + + + #: Deprecated method, use `is_activated` instead + def isActivated(self, *args, **kwargs): + return self.is_activated(*args, **kwargs) + + + def deactivate(self): + """ + Called when addon was deactivated + """ + pass + + + #: Deprecated method, use `deactivate` instead + def unload(self, *args, **kwargs): + return self.deactivate(*args, **kwargs) + + + def activate(self): + """ + Called when addon was activated + """ + pass + + + #: Deprecated method, use `activate` instead + def coreReady(self, *args, **kwargs): + return self.activate(*args, **kwargs) + + + def exit(self): + """ + Called by core.shutdown just before pyLoad exit + """ + pass + + + #: Deprecated method, use `exit` instead + def coreExiting(self, *args, **kwargs): + return self.exit(*args, **kwargs) + + + def download_preparing(self, pyfile): + pass + + + #: Deprecated method, use `download_preparing` instead + def downloadPreparing(self, *args, **kwargs): + return self.download_preparing(*args, **kwargs) + + + def download_finished(self, pyfile): + pass + + + #: Deprecated method, use `download_finished` instead + def downloadFinished(self, *args, **kwargs): + return self.download_finished(*args, **kwargs) + + + def download_failed(self, pyfile): + pass + + + #: Deprecated method, use `download_failed` instead + def downloadFailed(self, *args, **kwargs): + return self.download_failed(*args, **kwargs) + + + def package_finished(self, pypack): + pass + + + #: Deprecated method, use `package_finished` instead + def packageFinished(self, *args, **kwargs): + return self.package_finished(*args, **kwargs) + + + def before_reconnect(self, ip): + pass + + + #: Deprecated method, use `before_reconnect` instead + def beforeReconnecting(self, *args, **kwargs): + return self.before_reconnect(*args, **kwargs) + + + def after_reconnect(self, ip, oldip): + pass + + + #: Deprecated method, use `after_reconnect` instead + def afterReconnecting(self, ip): + return self.after_reconnect(ip, None) + + + def captcha_task(self, task): + """ + New captcha task for the plugin, it MUST set the handler and timeout or will be ignored + """ + pass + + + #: Deprecated method, use `captcha_task` instead + def newCaptchaTask(self, *args, **kwargs): + return self.captcha_task(*args, **kwargs) + + + def captcha_correct(self, task): + pass + + + #: Deprecated method, use `captcha_correct` instead + def captchaCorrect(self, *args, **kwargs): + return self.captcha_correct(*args, **kwargs) + + + def captcha_invalid(self, task): + pass + + + #: Deprecated method, use `captcha_invalid` instead + def captchaInvalid(self, *args, **kwargs): + return self.captcha_invalid(*args, **kwargs) diff --git a/module/plugins/internal/Captcha.py b/module/plugins/internal/Captcha.py index 68d5d3bb8..1309b0d6b 100644 --- a/module/plugins/internal/Captcha.py +++ b/module/plugins/internal/Captcha.py @@ -19,6 +19,15 @@ class Captcha(Plugin): self.plugin = plugin self.key = None #: Last key detected + self.init() + + + def init(self): + """ + Initialize additional data structures + """ + pass + #@TODO: Recheck in 0.4.10 def retrieve_key(self, html): diff --git a/module/plugins/internal/Extractor.py b/module/plugins/internal/Extractor.py index 60d8b3b3b..929ef5378 100644 --- a/module/plugins/internal/Extractor.py +++ b/module/plugins/internal/Extractor.py @@ -99,6 +99,8 @@ class Extractor(Plugin): pyfile = self.manager.core.files.getFile(fid) if fid else None self.notify_progress = lambda x: pyfile.setProgress(x) if pyfile else lambda x: None + self.init() + def init(self): """ diff --git a/module/plugins/internal/Hook.py b/module/plugins/internal/Hook.py index 162c9ecbf..a17037a11 100644 --- a/module/plugins/internal/Hook.py +++ b/module/plugins/internal/Hook.py @@ -1,34 +1,14 @@ # -*- coding: utf-8 -*- -import traceback +from module.plugins.internal.Addon import Addon -from module.plugins.internal.Plugin import Plugin - -class Expose(object): - """ - Used for decoration to declare rpc services - """ - def __new__(cls, f, *args, **kwargs): - hookManager.addRPC(f.__module__, f.func_name, f.func_doc) - return f - - -def threaded(fn): - - def run(*args, **kwargs): - hookManager.startThread(fn, *args, **kwargs) - - return run - - -class Hook(Plugin): +class Hook(Addon): __name__ = "Hook" __type__ = "hook" - __version__ = "0.09" + __version__ = "0.10" __config__ = [] #: [("name", "type", "desc", "default")] - __threaded__ = [] #@TODO: Remove in 0.4.10 __description__ = """Base hook plugin""" __license__ = "GPLv3" @@ -38,215 +18,5 @@ class Hook(Plugin): def __init__(self, core, manager): - super(Hook, self).__init__(core) - - #: `HookManager` - self.manager = manager - - #: Automatically register event listeners for functions, attribute will be deleted dont use it yourself - self.event_map = {} - - #: Deprecated alternative to event_map - #: List of events the plugin can handle, name the functions exactly like eventname. - self.event_list = [] #@NOTE: dont make duplicate entries in event_map - - #: Callback of periodical job task, used by HookManager - self.cb = None - self.interval = 60 - - self.setup() - self.init_events() + super(Hook, self).__init__(core, manager) self.init_periodical(10) - - - def init_events(self): - if self.event_map: - for event, funcs in self.event_map.iteritems(): - if type(funcs) in (list, tuple): - for f in funcs: - self.manager.addEvent(event, getattr(self, f)) - else: - self.manager.addEvent(event, getattr(self, funcs)) - - #: Delete for various reasons - self.event_map = None - - if self.event_list: - self.log_debug("Deprecated method `event_list`, use `event_map` instead") - - for f in self.event_list: - self.manager.addEvent(f, getattr(self, f)) - - self.event_list = None - - - def init_periodical(self, delay=0, threaded=False): - self.cb = self.core.scheduler.addJob(max(0, delay), self._periodical, [threaded], threaded=threaded) - - - #: Deprecated method, use `init_periodical` instead - def initPeriodical(self, *args, **kwargs): - return self.init_periodical(*args, **kwargs) - - - def _periodical(self, threaded): - if self.interval < 0: - self.cb = None - return - - try: - self.periodical() - - except Exception, e: - self.log_error(_("Error executing hook: %s") % e) - if self.core.debug: - traceback.print_exc() - - self.cb = self.core.scheduler.addJob(self.interval, self._periodical, [threaded], threaded=threaded) - - - def periodical(self): - pass - - - def __repr__(self): - return "<Hook %s>" % self.__name__ - - - def setup(self): - """ - More init stuff if needed - """ - pass - - - def is_activated(self): - """ - Checks if hook is activated - """ - return self.get_config("activated") - - - #: Deprecated method, use `is_activated` instead - def isActivated(self, *args, **kwargs): - return self.is_activated(*args, **kwargs) - - - def deactivate(self): - """ - Called when hook was deactivated - """ - pass - - - #: Deprecated method, use `deactivate` instead - def unload(self, *args, **kwargs): - return self.deactivate(*args, **kwargs) - - - def activate(self): - """ - Called when hook was activated - """ - pass - - - #: Deprecated method, use `activate` instead - def coreReady(self, *args, **kwargs): - return self.activate(*args, **kwargs) - - - def exit(self): - """ - Called by core.shutdown just before pyLoad exit - """ - pass - - - #: Deprecated method, use `exit` instead - def coreExiting(self, *args, **kwargs): - return self.exit(*args, **kwargs) - - - def download_preparing(self, pyfile): - pass - - - #: Deprecated method, use `download_preparing` instead - def downloadPreparing(self, *args, **kwargs): - return self.download_preparing(*args, **kwargs) - - - def download_finished(self, pyfile): - pass - - - #: Deprecated method, use `download_finished` instead - def downloadFinished(self, *args, **kwargs): - return self.download_finished(*args, **kwargs) - - - def download_failed(self, pyfile): - pass - - - #: Deprecated method, use `download_failed` instead - def downloadFailed(self, *args, **kwargs): - return self.download_failed(*args, **kwargs) - - - def package_finished(self, pypack): - pass - - - #: Deprecated method, use `package_finished` instead - def packageFinished(self, *args, **kwargs): - return self.package_finished(*args, **kwargs) - - - def before_reconnect(self, ip): - pass - - - #: Deprecated method, use `before_reconnect` instead - def beforeReconnecting(self, *args, **kwargs): - return self.before_reconnect(*args, **kwargs) - - - def after_reconnect(self, ip, oldip): - pass - - - #: Deprecated method, use `after_reconnect` instead - def afterReconnecting(self, ip): - return self.after_reconnect(ip, None) - - - def captcha_task(self, task): - """ - New captcha task for the plugin, it MUST set the handler and timeout or will be ignored - """ - pass - - - #: Deprecated method, use `captcha_task` instead - def newCaptchaTask(self, *args, **kwargs): - return self.captcha_task(*args, **kwargs) - - - def captcha_correct(self, task): - pass - - - #: Deprecated method, use `captcha_correct` instead - def captchaCorrect(self, *args, **kwargs): - return self.captcha_correct(*args, **kwargs) - - - def captcha_invalid(self, task): - pass - - - #: Deprecated method, use `captcha_invalid` instead - def captchaInvalid(self, *args, **kwargs): - return self.captcha_invalid(*args, **kwargs) diff --git a/module/plugins/internal/MultiHook.py b/module/plugins/internal/MultiHook.py index 4a43e89c7..127d83ab5 100644 --- a/module/plugins/internal/MultiHook.py +++ b/module/plugins/internal/MultiHook.py @@ -11,7 +11,7 @@ from module.utils import decode, remove_chars class MultiHook(Hook): __name__ = "MultiHook" __type__ = "hook" - __version__ = "0.50" + __version__ = "0.51" __config__ = [("pluginmode" , "all;listed;unlisted", "Use for plugins" , "all"), ("pluginlist" , "str" , "Plugin list (comma separated)", "" ), @@ -54,7 +54,7 @@ class MultiHook(Hook): (r'^0' , "zero" )] - def setup(self): + def init(self): self.plugins = [] self.supported = [] self.new_supported = [] diff --git a/module/plugins/internal/MultiHoster.py b/module/plugins/internal/MultiHoster.py index 363d46739..7bba2f6d3 100644 --- a/module/plugins/internal/MultiHoster.py +++ b/module/plugins/internal/MultiHoster.py @@ -30,9 +30,8 @@ class MultiHoster(SimpleHoster): def prepare(self): - self.info = {} - self.html = "" - self.link = "" #@TODO: Move to Hoster in 0.4.10 + self.html = "" + self.link = "" #@TODO: Move to Hoster in 0.4.10 self.direct_dl = False #@TODO: Move to Hoster in 0.4.10 if not self.get_config('use_premium', True): diff --git a/module/plugins/internal/OCR.py b/module/plugins/internal/OCR.py index 9ddca0315..387db1d13 100644 --- a/module/plugins/internal/OCR.py +++ b/module/plugins/internal/OCR.py @@ -29,6 +29,14 @@ class OCR(Plugin): def __init__(self): self.logger = logging.getLogger("log") + self.init() + + + def init(self): + """ + Initialize additional data structures + """ + pass def load_image(self, image): diff --git a/module/plugins/internal/Plugin.py b/module/plugins/internal/Plugin.py index 93dd2ecbe..d0f75a8a3 100644 --- a/module/plugins/internal/Plugin.py +++ b/module/plugins/internal/Plugin.py @@ -122,9 +122,7 @@ class Plugin(object): def __init__(self, core): self.core = core - - #: Provide information in dict here - self.info = {} + self.info = {} #: Provide information in dict here def _log(self, level, args): diff --git a/module/plugins/internal/SimpleCrypter.py b/module/plugins/internal/SimpleCrypter.py index 82f5ef332..cd447db6b 100644 --- a/module/plugins/internal/SimpleCrypter.py +++ b/module/plugins/internal/SimpleCrypter.py @@ -66,7 +66,6 @@ class SimpleCrypter(Crypter, SimpleHoster): def prepare(self): self.pyfile.error = "" #@TODO: Remove in 0.4.10 - self.info = {} self.html = "" #@TODO: Recheck in 0.4.10 self.link = "" #@TODO: Recheck in 0.4.10 self.links = [] diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py index 5bf2f0417..911a7d411 100644 --- a/module/plugins/internal/SimpleHoster.py +++ b/module/plugins/internal/SimpleHoster.py @@ -204,10 +204,9 @@ class SimpleHoster(Hoster): def prepare(self): self.pyfile.error = "" #@TODO: Remove in 0.4.10 - self.info = {} self.html = "" #@TODO: Recheck in 0.4.10 self.link = "" #@TODO: Recheck in 0.4.10 - self.direct_dl = False + self.direct_dl = False self.multihost = False if not self.get_config('use_premium', True): |