From f6e5359110f4bd5facc04a98f94acbc41b6e5228 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 3 Oct 2014 21:20:20 +0200 Subject: Update pyload to the new plugins structure --- docs/docs.conf | 2 +- pyload/Core.py | 8 +- pyload/api/__init__.py | 18 +- pyload/database/FileDatabase.py | 10 +- pyload/manager/AccountManager.py | 2 +- pyload/manager/AddonManager.py | 306 ++++++++++++++++++++++++ pyload/manager/CaptchaManager.py | 4 +- pyload/manager/HookManager.py | 305 ----------------------- pyload/manager/PluginManager.py | 27 ++- pyload/manager/ThreadManager.py | 8 +- pyload/manager/thread/PluginThread.py | 16 +- pyload/plugins/Plugin.py | 10 +- pyload/plugins/account/TusfilesNet.py | 2 +- pyload/plugins/addon/AlldebridCom.py | 4 +- pyload/plugins/addon/BypassCaptcha.py | 6 +- pyload/plugins/addon/Captcha9kw.py | 6 +- pyload/plugins/addon/CaptchaBrotherhood.py | 6 +- pyload/plugins/addon/Checksum.py | 6 +- pyload/plugins/addon/ClickAndLoad.py | 6 +- pyload/plugins/addon/DeathByCaptcha.py | 6 +- pyload/plugins/addon/DebridItaliaCom.py | 4 +- pyload/plugins/addon/DeleteFinished.py | 6 +- pyload/plugins/addon/DownloadScheduler.py | 8 +- pyload/plugins/addon/EasybytezCom.py | 4 +- pyload/plugins/addon/Ev0InFetcher.py | 6 +- pyload/plugins/addon/ExpertDecoders.py | 6 +- pyload/plugins/addon/ExternalScripts.py | 6 +- pyload/plugins/addon/ExtractArchive.py | 6 +- pyload/plugins/addon/FastixRu.py | 4 +- pyload/plugins/addon/FreeWayMe.py | 4 +- pyload/plugins/addon/HotFolder.py | 6 +- pyload/plugins/addon/IRCInterface.py | 8 +- pyload/plugins/addon/ImageTyperz.py | 6 +- pyload/plugins/addon/LinkdecrypterCom.py | 8 +- pyload/plugins/addon/LinksnappyCom.py | 4 +- pyload/plugins/addon/MegaDebridEu.py | 4 +- pyload/plugins/addon/MergeFiles.py | 6 +- pyload/plugins/addon/MultiHome.py | 6 +- pyload/plugins/addon/MultishareCz.py | 4 +- pyload/plugins/addon/MyfastfileCom.py | 4 +- pyload/plugins/addon/OverLoadMe.py | 4 +- pyload/plugins/addon/PremiumTo.py | 4 +- pyload/plugins/addon/PremiumizeMe.py | 4 +- pyload/plugins/addon/RPNetBiz.py | 4 +- pyload/plugins/addon/RealdebridCom.py | 4 +- pyload/plugins/addon/RehostTo.py | 4 +- pyload/plugins/addon/RestartFailed.py | 6 +- pyload/plugins/addon/SimplyPremiumCom.py | 4 +- pyload/plugins/addon/SimplydebridCom.py | 4 +- pyload/plugins/addon/UnSkipOnFail.py | 6 +- pyload/plugins/addon/UnrestrictLi.py | 4 +- pyload/plugins/addon/WindowsPhoneToastNotify.py | 6 +- pyload/plugins/addon/XFileSharingPro.py | 8 +- pyload/plugins/addon/XMPPInterface.py | 4 +- pyload/plugins/addon/ZeveraCom.py | 4 +- pyload/plugins/base/Addon.py | 149 ++++++++++++ pyload/plugins/base/Hook.py | 149 ------------ pyload/plugins/crypter/MultiuploadCom.py | 2 +- pyload/plugins/crypter/UploadableChFolder.py | 2 +- pyload/plugins/hoster/LoadTo.py | 2 +- pyload/plugins/hoster/LomafileCom.py | 2 +- pyload/plugins/hoster/TurbobitNet.py | 2 +- pyload/plugins/internal/AbstractExtractor.py | 2 +- pyload/plugins/internal/DeadCrypter.py | 2 +- pyload/plugins/internal/DeadHoster.py | 2 +- pyload/plugins/internal/MultiHoster.py | 6 +- pyload/plugins/internal/UpdateManager.py | 10 +- 67 files changed, 636 insertions(+), 632 deletions(-) create mode 100644 pyload/manager/AddonManager.py delete mode 100644 pyload/manager/HookManager.py create mode 100644 pyload/plugins/base/Addon.py delete mode 100644 pyload/plugins/base/Hook.py diff --git a/docs/docs.conf b/docs/docs.conf index fd2987784..749e09212 100644 --- a/docs/docs.conf +++ b/docs/docs.conf @@ -8,7 +8,7 @@ output: html target: docs docformat: restructuredtext -exclude: pyload\.lib|pyload\.remote\.thriftbackend\.thriftgen|\.pyc|\.pyo|pyload\.plugins\.(accounts|container|crypter|hooks|hoster|internal|ocr) +exclude: pyload\.lib|pyload\.remote\.thriftbackend\.thriftgen|\.pyc|\.pyo|pyload\.plugins\.(account|addon|base|container|crypter|hook|hoster|internal|ocr) name: pyLoad Documentation url: http://docs.pyload.org diff --git a/pyload/Core.py b/pyload/Core.py index 902b6fdb3..6b67f8984 100644 --- a/pyload/Core.py +++ b/pyload/Core.py @@ -377,7 +377,7 @@ class Core(object): # later imported because they would trigger api import, and remote value not set correctly from pyload import api - from pyload.manager.HookManager import HookManager + from pyload.manager.AddonManager import AddonManager from pyload.manager.ThreadManager import ThreadManager if api.activated != self.remote: @@ -393,7 +393,7 @@ class Core(object): self.accountManager = AccountManager(self) self.threadManager = ThreadManager(self) self.captchaManager = CaptchaManager(self) - self.hookManager = HookManager(self) + self.addonManager = AddonManager(self) self.remoteManager = RemoteManager(self) self.js = JsEngine(self) @@ -435,7 +435,7 @@ class Core(object): self.running = True self.log.info(_("Activating Plugins...")) - self.hookManager.coreReady() + self.addonManager.coreReady() self.log.info(_("pyLoad is up and running")) @@ -576,7 +576,7 @@ class Core(object): for pyfile in pyfiles: pyfile.abortDownload() - self.hookManager.coreExiting() + self.addonManager.coreExiting() except: if self.debug: diff --git a/pyload/api/__init__.py b/pyload/api/__init__.py index 9c4740e82..a6927b238 100644 --- a/pyload/api/__init__.py +++ b/pyload/api/__init__.py @@ -145,7 +145,7 @@ class Api(Iface): :param value: new config value :param section: 'plugin' or 'core """ - self.core.hookManager.dispatchEvent("configChanged", category, option, value, section) + self.core.addonManager.dispatchEvent("configChanged", category, option, value, section) if section == "core": self.core.config[category][option] = value @@ -960,12 +960,12 @@ class Api(Iface): @permission(PERMS.STATUS) def getServices(self): - """ A dict of available services, these can be defined by hook plugins. + """ A dict of available services, these can be defined by addon plugins. :return: dict with this style: {"plugin": {"method": "description"}} """ data = {} - for plugin, funcs in self.core.hookManager.methods.iteritems(): + for plugin, funcs in self.core.addonManager.methods.iteritems(): data[plugin] = funcs return data @@ -978,12 +978,12 @@ class Api(Iface): :param func: :return: bool """ - cont = self.core.hookManager.methods + cont = self.core.addonManager.methods return plugin in cont and func in cont[plugin] @permission(PERMS.STATUS) def call(self, info): - """Calls a service (a method in hook plugin). + """Calls a service (a method in addon plugin). :param info: `ServiceCall` :return: result @@ -999,18 +999,18 @@ class Api(Iface): raise ServiceDoesNotExists(plugin, func) try: - ret = self.core.hookManager.callRPC(plugin, func, args, parse) + ret = self.core.addonManager.callRPC(plugin, func, args, parse) return str(ret) except Exception, e: raise ServiceException(e.message) @permission(PERMS.STATUS) def getAllInfo(self): - """Returns all information stored by hook plugins. Values are always strings + """Returns all information stored by addon plugins. Values are always strings :return: {"plugin": {"name": value}} """ - return self.core.hookManager.getAllInfo() + return self.core.addonManager.getAllInfo() @permission(PERMS.STATUS) def getInfoByPlugin(self, plugin): @@ -1019,7 +1019,7 @@ class Api(Iface): :param plugin: pluginname :return: dict of attr names mapped to value {"name": value} """ - return self.core.hookManager.getInfo(plugin) + return self.core.addonManager.getInfo(plugin) def changePassword(self, user, oldpw, newpw): """ changes password for specific user """ diff --git a/pyload/database/FileDatabase.py b/pyload/database/FileDatabase.py index 54e5450e8..3594da685 100644 --- a/pyload/database/FileDatabase.py +++ b/pyload/database/FileDatabase.py @@ -120,7 +120,7 @@ class FileHandler: def addLinks(self, urls, package): """adds links""" - self.core.hookManager.dispatchEvent("linksAdded", urls, package) + self.core.addonManager.dispatchEvent("linksAdded", urls, package) data = self.core.pluginManager.parseUrls(urls) @@ -166,7 +166,7 @@ class FileHandler: self.db.deletePackage(p) self.core.pullManager.addEvent(e) - self.core.hookManager.dispatchEvent("packageDeleted", id) + self.core.addonManager.dispatchEvent("packageDeleted", id) if id in self.packageCache: del self.packageCache[id] @@ -368,7 +368,7 @@ class FileHandler: """checks if all files are finished and dispatch event""" if not self.getQueueCount(True): - self.core.hookManager.dispatchEvent("allDownloadsFinished") + self.core.addonManager.dispatchEvent("allDownloadsFinished") self.core.log.debug("All downloads finished") return True @@ -381,7 +381,7 @@ class FileHandler: self.resetCount() if not self.db.processcount(1, fid): - self.core.hookManager.dispatchEvent("allDownloadsProcessed") + self.core.addonManager.dispatchEvent("allDownloadsProcessed") self.core.log.debug("All downloads processed") return True @@ -528,7 +528,7 @@ class FileHandler: if not ids or (pyfile.id in ids and len(ids) == 1): if not pyfile.package().setFinished: self.core.log.info(_("Package finished: %s") % pyfile.package().name) - self.core.hookManager.packageFinished(pyfile.package()) + self.core.addonManager.packageFinished(pyfile.package()) pyfile.package().setFinished = True diff --git a/pyload/manager/AccountManager.py b/pyload/manager/AccountManager.py index d1958f4b6..ec092d740 100644 --- a/pyload/manager/AccountManager.py +++ b/pyload/manager/AccountManager.py @@ -36,7 +36,7 @@ class AccountManager: if plugin in self.accounts: if plugin not in self.plugins: try: - self.plugins[plugin] = self.core.pluginManager.loadClass("accounts", plugin)(self, self.accounts[plugin]) + self.plugins[plugin] = self.core.pluginManager.loadClass("account", plugin)(self, self.accounts[plugin]) except TypeError: # The account class no longer exists (blacklisted plugin). Skipping the account to avoid crash return None diff --git a/pyload/manager/AddonManager.py b/pyload/manager/AddonManager.py new file mode 100644 index 000000000..a81e0a74f --- /dev/null +++ b/pyload/manager/AddonManager.py @@ -0,0 +1,306 @@ +# -*- 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 . + + @author: RaNaN, mkaay + @interface-version: 0.1 +""" +import __builtin__ + +import traceback +from thread import start_new_thread +from threading import RLock + +from types import MethodType + +from pyload.manager.thread.PluginThread import AddonThread +from pyload.manager.PluginManager import literal_eval +from utils import lock + +class AddonManager: + """Manages addons, delegates and handles Events. + + Every plugin can define events, \ + but some very usefull events are called by the Core. + Contrary to overwriting addon methods you can use event listener, + which provides additional entry point in the control flow. + Only do very short tasks or use threads. + + **Known Events:** + Most addon methods exists as events. These are the additional known events. + + ===================== ============== ================================== + Name Arguments Description + ===================== ============== ================================== + downloadPreparing fid A download was just queued and will be prepared now. + downloadStarts fid A plugin will immediately starts the download afterwards. + linksAdded links, pid Someone just added links, you are able to modify the links. + allDownloadsProcessed Every link was handled, pyload would idle afterwards. + allDownloadsFinished Every download in queue is finished. + unrarFinished folder, fname An Unrar job finished + configChanged The config was changed via the api. + pluginConfigChanged The plugin config changed, due to api or internal process. + ===================== ============== ================================== + + | Notes: + | allDownloadsProcessed is *always* called before allDownloadsFinished. + | configChanged is *always* called before pluginConfigChanged. + + + """ + + def __init__(self, core): + self.core = core + self.config = self.core.config + + __builtin__.addonManager = self #needed to let addons register themself + + self.log = self.core.log + self.plugins = [] + self.pluginMap = {} + self.methods = {} #dict of names and list of methods usable by rpc + + self.events = {} # contains events + + #registering callback for config event + self.config.pluginCB = MethodType(self.dispatchEvent, "pluginConfigChanged", basestring) + + self.addEvent("pluginConfigChanged", self.manageAddon) + + self.lock = RLock() + self.createIndex() + + def try_catch(func): + def new(*args): + try: + return func(*args) + except Exception, e: + args[0].log.error(_("Error executing addon: %s") % e) + if args[0].core.debug: + traceback.print_exc() + + return new + + + def addRPC(self, plugin, func, doc): + plugin = plugin.rpartition(".")[2] + doc = doc.strip() if doc else "" + + if plugin in self.methods: + self.methods[plugin][func] = doc + else: + self.methods[plugin] = {func: doc} + + def callRPC(self, plugin, func, args, parse): + if not args: args = tuple() + if parse: + args = tuple([literal_eval(x) for x in args]) + + plugin = self.pluginMap[plugin] + f = getattr(plugin, func) + return f(*args) + + + def createIndex(self): + plugins = [] + + active = [] + deactive = [] + + for pluginname in self.core.pluginManager.addonPlugins: + try: + # hookClass = getattr(plugin, plugin.__name__) + + if self.config.getPlugin(pluginname, "activated"): + pluginClass = self.core.pluginManager.loadClass("addon", pluginname) + if not pluginClass: continue + + plugin = pluginClass(self.core, self) + plugins.append(plugin) + self.pluginMap[pluginClass.__name__] = plugin + if plugin.isActivated(): + active.append(pluginClass.__name__) + else: + deactive.append(pluginname) + + + except: + self.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) + if self.core.debug: + traceback.print_exc() + + self.log.info(_("Activated plugins: %s") % ", ".join(sorted(active))) + self.log.info(_("Deactivate plugins: %s") % ", ".join(sorted(deactive))) + + self.plugins = plugins + + def manageAddon(self, plugin, name, value): + if name == "activated" and value: + self.activateAddon(plugin) + elif name == "activated" and not value: + self.deactivateAddon(plugin) + + def activateAddon(self, plugin): + + #check if already loaded + for inst in self.plugins: + if inst.__name__ == plugin: + return + + pluginClass = self.core.pluginManager.loadClass("addon", plugin) + + if not pluginClass: return + + self.log.debug("Plugin loaded: %s" % plugin) + + plugin = pluginClass(self.core, self) + self.plugins.append(plugin) + self.pluginMap[pluginClass.__name__] = plugin + + # call core Ready + start_new_thread(plugin.coreReady, tuple()) + + def deactivateAddon(self, plugin): + + addon = None + for inst in self.plugins: + if inst.__name__ == plugin: + addon = inst + + if not addon: + return + + self.log.debug("Plugin unloaded: %s" % plugin) + + addon.unload() + + #remove periodic call + self.log.debug("Removed callback %s" % self.core.scheduler.removeJob(addon.cb)) + self.plugins.remove(addon) + del self.pluginMap[addon.__name__] + + + @try_catch + def coreReady(self): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.coreReady() + + self.dispatchEvent("coreReady") + + @try_catch + def coreExiting(self): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.coreExiting() + + self.dispatchEvent("coreExiting") + + @lock + def downloadPreparing(self, pyfile): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.downloadPreparing(pyfile) + + self.dispatchEvent("downloadPreparing", pyfile) + + @lock + def downloadFinished(self, pyfile): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.downloadFinished(pyfile) + + self.dispatchEvent("downloadFinished", pyfile) + + @lock + @try_catch + def downloadFailed(self, pyfile): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.downloadFailed(pyfile) + + self.dispatchEvent("downloadFailed", pyfile) + + @lock + def packageFinished(self, package): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.packageFinished(package) + + self.dispatchEvent("packageFinished", package) + + @lock + def beforeReconnecting(self, ip): + for plugin in self.plugins: + plugin.beforeReconnecting(ip) + + self.dispatchEvent("beforeReconnecting", ip) + + @lock + def afterReconnecting(self, ip): + for plugin in self.plugins: + if plugin.isActivated(): + plugin.afterReconnecting(ip) + + self.dispatchEvent("afterReconnecting", ip) + + def startThread(self, function, *args, **kwargs): + t = AddonThread(self.core.threadManager, function, args, kwargs) + + def activePlugins(self): + """ returns all active plugins """ + return [x for x in self.plugins if x.isActivated()] + + def getAllInfo(self): + """returns info stored by hook plugins""" + info = {} + for name, plugin in self.pluginMap.iteritems(): + if plugin.info: + #copy and convert so str + info[name] = dict([(x, str(y) if not isinstance(y, basestring) else y) for x, y in plugin.info.iteritems()]) + return info + + + def getInfo(self, plugin): + info = {} + if plugin in self.pluginMap and self.pluginMap[plugin].info: + info = dict([(x, str(y) if not isinstance(y, basestring) else y) + for x, y in self.pluginMap[plugin].info.iteritems()]) + + return info + + def addEvent(self, event, func): + """Adds an event listener for event name""" + if event in self.events: + self.events[event].append(func) + else: + self.events[event] = [func] + + def removeEvent(self, event, func): + """removes previously added event listener""" + if event in self.events: + self.events[event].remove(func) + + def dispatchEvent(self, event, *args): + """dispatches event with args""" + if event in self.events: + for f in self.events[event]: + try: + f(*args) + except Exception, e: + self.log.warning("Error calling event handler %s: %s, %s, %s" + % (event, f, args, str(e))) + if self.core.debug: + traceback.print_exc() diff --git a/pyload/manager/CaptchaManager.py b/pyload/manager/CaptchaManager.py index 0ba876ae8..06f1347fc 100644 --- a/pyload/manager/CaptchaManager.py +++ b/pyload/manager/CaptchaManager.py @@ -64,7 +64,7 @@ class CaptchaManager: if cli: #client connected -> should solve the captcha task.setWaiting(50) #wait 50 sec for response - for plugin in self.core.hookManager.activePlugins(): + for plugin in self.core.addonManager.activePlugins(): try: plugin.newCaptchaTask(task) except: @@ -87,7 +87,7 @@ class CaptchaTask: self.captchaFormat = format self.captchaFile = file self.captchaResultType = result_type - self.handler = [] #the hook plugins that will take care of the solution + self.handler = [] #: the hook plugins that will take care of the solution self.result = None self.waitUntil = None self.error = None #error message diff --git a/pyload/manager/HookManager.py b/pyload/manager/HookManager.py deleted file mode 100644 index 6f5477aeb..000000000 --- a/pyload/manager/HookManager.py +++ /dev/null @@ -1,305 +0,0 @@ -# -*- 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 . - - @author: RaNaN, mkaay - @interface-version: 0.1 -""" -import __builtin__ - -import traceback -from thread import start_new_thread -from threading import RLock - -from types import MethodType - -from pyload.manager.thread.PluginThread import HookThread -from pyload.manager.PluginManager import literal_eval -from utils import lock - -class HookManager: - """Manages hooks, delegates and handles Events. - - Every plugin can define events, \ - but some very usefull events are called by the Core. - Contrary to overwriting hook methods you can use event listener, - which provides additional entry point in the control flow. - Only do very short tasks or use threads. - - **Known Events:** - Most hook methods exists as events. These are the additional known events. - - ===================== ============== ================================== - Name Arguments Description - ===================== ============== ================================== - downloadPreparing fid A download was just queued and will be prepared now. - downloadStarts fid A plugin will immediately starts the download afterwards. - linksAdded links, pid Someone just added links, you are able to modify the links. - allDownloadsProcessed Every link was handled, pyload would idle afterwards. - allDownloadsFinished Every download in queue is finished. - unrarFinished folder, fname An Unrar job finished - configChanged The config was changed via the api. - pluginConfigChanged The plugin config changed, due to api or internal process. - ===================== ============== ================================== - - | Notes: - | allDownloadsProcessed is *always* called before allDownloadsFinished. - | configChanged is *always* called before pluginConfigChanged. - - - """ - - def __init__(self, core): - self.core = core - self.config = self.core.config - - __builtin__.hookManager = self #needed to let hooks register themself - - self.log = self.core.log - self.plugins = [] - self.pluginMap = {} - self.methods = {} #dict of names and list of methods usable by rpc - - self.events = {} # contains events - - #registering callback for config event - self.config.pluginCB = MethodType(self.dispatchEvent, "pluginConfigChanged", basestring) - - self.addEvent("pluginConfigChanged", self.manageHooks) - - self.lock = RLock() - self.createIndex() - - def try_catch(func): - def new(*args): - try: - return func(*args) - except Exception, e: - args[0].log.error(_("Error executing hooks: %s") % str(e)) - if args[0].core.debug: - traceback.print_exc() - - return new - - - def addRPC(self, plugin, func, doc): - plugin = plugin.rpartition(".")[2] - doc = doc.strip() if doc else "" - - if plugin in self.methods: - self.methods[plugin][func] = doc - else: - self.methods[plugin] = {func: doc} - - def callRPC(self, plugin, func, args, parse): - if not args: args = tuple() - if parse: - args = tuple([literal_eval(x) for x in args]) - - plugin = self.pluginMap[plugin] - f = getattr(plugin, func) - return f(*args) - - - def createIndex(self): - plugins = [] - - active = [] - deactive = [] - - for pluginname in self.core.pluginManager.hookPlugins: - try: - #hookClass = getattr(plugin, plugin.__name__) - - if self.config.getPlugin(pluginname, "activated"): - pluginClass = self.core.pluginManager.loadClass("hooks", pluginname) - if not pluginClass: continue - - plugin = pluginClass(self.core, self) - plugins.append(plugin) - self.pluginMap[pluginClass.__name__] = plugin - if plugin.isActivated(): - active.append(pluginClass.__name__) - else: - deactive.append(pluginname) - - - except: - self.log.warning(_("Failed activating %(name)s") % {"name": pluginname}) - if self.core.debug: - traceback.print_exc() - - self.log.info(_("Activated plugins: %s") % ", ".join(sorted(active))) - self.log.info(_("Deactivate plugins: %s") % ", ".join(sorted(deactive))) - - self.plugins = plugins - - def manageHooks(self, plugin, name, value): - if name == "activated" and value: - self.activateHook(plugin) - elif name == "activated" and not value: - self.deactivateHook(plugin) - - def activateHook(self, plugin): - - #check if already loaded - for inst in self.plugins: - if inst.__name__ == plugin: - return - - pluginClass = self.core.pluginManager.loadClass("hooks", plugin) - - if not pluginClass: return - - self.log.debug("Plugin loaded: %s" % plugin) - - plugin = pluginClass(self.core, self) - self.plugins.append(plugin) - self.pluginMap[pluginClass.__name__] = plugin - - # call core Ready - start_new_thread(plugin.coreReady, tuple()) - - def deactivateHook(self, plugin): - - hook = None - for inst in self.plugins: - if inst.__name__ == plugin: - hook = inst - - if not hook: return - - self.log.debug("Plugin unloaded: %s" % plugin) - - hook.unload() - - #remove periodic call - self.log.debug("Removed callback %s" % self.core.scheduler.removeJob(hook.cb)) - self.plugins.remove(hook) - del self.pluginMap[hook.__name__] - - - @try_catch - def coreReady(self): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.coreReady() - - self.dispatchEvent("coreReady") - - @try_catch - def coreExiting(self): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.coreExiting() - - self.dispatchEvent("coreExiting") - - @lock - def downloadPreparing(self, pyfile): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.downloadPreparing(pyfile) - - self.dispatchEvent("downloadPreparing", pyfile) - - @lock - def downloadFinished(self, pyfile): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.downloadFinished(pyfile) - - self.dispatchEvent("downloadFinished", pyfile) - - @lock - @try_catch - def downloadFailed(self, pyfile): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.downloadFailed(pyfile) - - self.dispatchEvent("downloadFailed", pyfile) - - @lock - def packageFinished(self, package): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.packageFinished(package) - - self.dispatchEvent("packageFinished", package) - - @lock - def beforeReconnecting(self, ip): - for plugin in self.plugins: - plugin.beforeReconnecting(ip) - - self.dispatchEvent("beforeReconnecting", ip) - - @lock - def afterReconnecting(self, ip): - for plugin in self.plugins: - if plugin.isActivated(): - plugin.afterReconnecting(ip) - - self.dispatchEvent("afterReconnecting", ip) - - def startThread(self, function, *args, **kwargs): - t = HookThread(self.core.threadManager, function, args, kwargs) - - def activePlugins(self): - """ returns all active plugins """ - return [x for x in self.plugins if x.isActivated()] - - def getAllInfo(self): - """returns info stored by hook plugins""" - info = {} - for name, plugin in self.pluginMap.iteritems(): - if plugin.info: - #copy and convert so str - info[name] = dict([(x, str(y) if not isinstance(y, basestring) else y) for x, y in plugin.info.iteritems()]) - return info - - - def getInfo(self, plugin): - info = {} - if plugin in self.pluginMap and self.pluginMap[plugin].info: - info = dict([(x, str(y) if not isinstance(y, basestring) else y) - for x, y in self.pluginMap[plugin].info.iteritems()]) - - return info - - def addEvent(self, event, func): - """Adds an event listener for event name""" - if event in self.events: - self.events[event].append(func) - else: - self.events[event] = [func] - - def removeEvent(self, event, func): - """removes previously added event listener""" - if event in self.events: - self.events[event].remove(func) - - def dispatchEvent(self, event, *args): - """dispatches event with args""" - if event in self.events: - for f in self.events[event]: - try: - f(*args) - except Exception, e: - self.log.warning("Error calling event handler %s: %s, %s, %s" - % (event, f, args, str(e))) - if self.core.debug: - traceback.print_exc() diff --git a/pyload/manager/PluginManager.py b/pyload/manager/PluginManager.py index 56e59237c..939b17347 100644 --- a/pyload/manager/PluginManager.py +++ b/pyload/manager/PluginManager.py @@ -17,7 +17,7 @@ from pyload.config.Parser import IGNORE class PluginManager: ROOT = "pyload.plugins." USERROOT = "userplugins." - TYPES = ("accounts", "container", "crypter", "hooks", "hoster", "internal", "ocr") + TYPES = ("account", "addon", "base", "container", "crypter", "hook", "hoster", "internal", "ocr") PATTERN = re.compile(r'__pattern__.*=.*r("|\')([^"\']+)') VERSION = re.compile(r'__version__.*=.*("|\')([0-9.]+)') @@ -49,14 +49,15 @@ class PluginManager: f = open(join("userplugins", "__init__.py"), "wb") f.close() - self.plugins['crypter'] = self.crypterPlugins = self.parse("crypter", pattern=True) + self.plugins['account'] = self.accountPlugins = self.parse("account") + self.plugins['addon'] = self.addonPlugins = self.parse("addon") + self.plugins['base'] = self.basePlugins = self.parse("base") self.plugins['container'] = self.containerPlugins = self.parse("container", pattern=True) + self.plugins['crypter'] = self.crypterPlugins = self.parse("crypter", pattern=True) + # self.plugins['hook'] = self.hookPlugins = self.parse("hook") self.plugins['hoster'] = self.hosterPlugins = self.parse("hoster", pattern=True) - - self.plugins['ocr'] = self.captchaPlugins = self.parse("ocr") - self.plugins['accounts'] = self.accountPlugins = self.parse("accounts") - self.plugins['hooks'] = self.hookPlugins = self.parse("hooks") self.plugins['internal'] = self.internalPlugins = self.parse("internal") + self.plugins['ocr'] = self.ocrPlugins = self.parse("ocr") self.log.debug("created index of plugins") @@ -154,7 +155,7 @@ class PluginManager: else: config = [list(config)] - if folder == "hooks": + if folder == "addon": append = True for item in config: if item[0] == "activated": append = False @@ -167,7 +168,7 @@ class PluginManager: except: self.log.error("Invalid config in %s: %s" % (name, config)) - elif folder == "hooks": #force config creation + elif folder == "addon": #force config creation desc = self.DESC.findall(content) desc = desc[0][1] if desc else "" config = (["activated", "bool", "Activated", False],) @@ -318,7 +319,7 @@ class PluginManager: as_dict = {} for t,n in type_plugins: - if t in ("hooks", "internal"): #: do not reload hooks or internals, because would cause to much side effects + if t in ("base", "addon", "internal"): #: do not reload them because would cause to much side effects continue elif t in as_dict: as_dict[t].append(n) @@ -339,11 +340,13 @@ class PluginManager: reloaded.append(id) #index creation - self.plugins['crypter'] = self.crypterPlugins = self.parse("crypter", pattern=True) + self.plugins['account'] = self.accountPlugins = self.parse("account") self.plugins['container'] = self.containerPlugins = self.parse("container", pattern=True) + self.plugins['crypter'] = self.crypterPlugins = self.parse("crypter", pattern=True) + # self.plugins['hook'] = self.hookPlugins = self.parse("hook") self.plugins['hoster'] = self.hosterPlugins = self.parse("hoster", pattern=True) - self.plugins['ocr'] = self.captchaPlugins = self.parse("ocr") - self.plugins['accounts'] = self.accountPlugins = self.parse("accounts") + self.plugins['ocr'] = self.ocrPlugins = self.parse("ocr") + if "accounts" in as_dict: #: accounts needs to be reloaded self.core.accountManager.initPlugins() diff --git a/pyload/manager/ThreadManager.py b/pyload/manager/ThreadManager.py index 1073f8040..50af4a93a 100644 --- a/pyload/manager/ThreadManager.py +++ b/pyload/manager/ThreadManager.py @@ -42,8 +42,8 @@ class ThreadManager: self.core = core self.log = core.log - self.threads = [] # thread list - self.localThreads = [] #hook+decrypter threads + self.threads = [] #: thread list + self.localThreads = [] #: addon+decrypter threads self.pause = True @@ -185,7 +185,7 @@ class ThreadManager: ip = self.getIP() - self.core.hookManager.beforeReconnecting(ip) + self.core.addonManager.beforeReconnecting(ip) self.log.debug("Old IP: %s" % ip) @@ -202,7 +202,7 @@ class ThreadManager: reconn.wait() sleep(1) ip = self.getIP() - self.core.hookManager.afterReconnecting(ip) + self.core.addonManager.afterReconnecting(ip) self.log.info(_("Reconnected, new IP: %s") % ip) diff --git a/pyload/manager/thread/PluginThread.py b/pyload/manager/thread/PluginThread.py index 5c274fa46..c5092a207 100644 --- a/pyload/manager/thread/PluginThread.py +++ b/pyload/manager/thread/PluginThread.py @@ -182,11 +182,11 @@ class DownloadThread(PluginThread): self.m.log.info(_("Download starts: %s" % pyfile.name)) # start download - self.m.core.hookManager.downloadPreparing(pyfile) + self.m.core.addonManager.downloadPreparing(pyfile) pyfile.plugin.preprocessing(self) self.m.log.info(_("Download finished: %s") % pyfile.name) - self.m.core.hookManager.downloadFinished(pyfile) + self.m.core.addonManager.downloadFinished(pyfile) self.m.core.files.checkPackageFinished(pyfile) except NotImplementedError: @@ -236,7 +236,7 @@ class DownloadThread(PluginThread): self.m.log.warning(_("Download failed: %(name)s | %(msg)s") % {"name": pyfile.name, "msg": msg}) pyfile.error = msg - self.m.core.hookManager.downloadFailed(pyfile) + self.m.core.addonManager.downloadFailed(pyfile) self.clean(pyfile) continue @@ -277,7 +277,7 @@ class DownloadThread(PluginThread): print_exc() self.writeDebugReport(pyfile) - self.m.core.hookManager.downloadFailed(pyfile) + self.m.core.addonManager.downloadFailed(pyfile) self.clean(pyfile) continue @@ -307,7 +307,7 @@ class DownloadThread(PluginThread): print_exc() self.writeDebugReport(pyfile) - self.m.core.hookManager.downloadFailed(pyfile) + self.m.core.addonManager.downloadFailed(pyfile) self.clean(pyfile) continue @@ -409,7 +409,7 @@ class DecrypterThread(PluginThread): exc_clear() - #self.m.core.hookManager.downloadFinished(pyfile) + #self.m.core.addonManager.downloadFinished(pyfile) #self.m.localThreads.remove(self) @@ -418,8 +418,8 @@ class DecrypterThread(PluginThread): pyfile.delete() -class HookThread(PluginThread): - """thread for hooks""" +class AddonThread(PluginThread): + """thread for addons""" #-------------------------------------------------------------------------- def __init__(self, m, function, args, kwargs): diff --git a/pyload/plugins/Plugin.py b/pyload/plugins/Plugin.py index 6bb325760..7ebaed541 100644 --- a/pyload/plugins/Plugin.py +++ b/pyload/plugins/Plugin.py @@ -205,7 +205,7 @@ class Plugin(Base): self.html = None #: quick caller for API - self.api = self.core.api + self.api = self.core.api self.init() @@ -260,7 +260,7 @@ class Plugin(Base): 10 - not implemented 20 - unknown error """ - #@TODO checksum check hook + #@TODO checksum check addon return True, 10 @@ -362,10 +362,10 @@ class Plugin(Base): temp_file.write(img) temp_file.close() - has_plugin = self.__name__ in self.core.pluginManager.captchaPlugins + has_plugin = self.__name__ in self.core.pluginManager.ocrPlugins if self.core.captcha: - Ocr = self.core.pluginManager.loadClass("captcha", self.__name__) + Ocr = self.core.pluginManager.loadClass("ocr", self.__name__) else: Ocr = None @@ -508,7 +508,7 @@ class Plugin(Base): filename = join(location, name) - self.core.hookManager.dispatchEvent("downloadStarts", self.pyfile, url, filename) + self.core.addonManager.dispatchEvent("downloadStarts", self.pyfile, url, filename) try: newname = self.req.httpDownload(url, filename, get=get, post=post, ref=ref, cookies=cookies, diff --git a/pyload/plugins/account/TusfilesNet.py b/pyload/plugins/account/TusfilesNet.py index c4d912022..b00770a59 100644 --- a/pyload/plugins/account/TusfilesNet.py +++ b/pyload/plugins/account/TusfilesNet.py @@ -14,7 +14,7 @@ class TusfilesNet(Account): __type__ = "account" __version__ = "0.01" - __description__ = """ Tusfile.net account plugin """ + __description__ = """Tusfile.net account plugin""" __author_name__ = "guidobelix" __author_mail__ = "guidobelix@hotmail.it" diff --git a/pyload/plugins/addon/AlldebridCom.py b/pyload/plugins/addon/AlldebridCom.py index 8eade2941..7882b9bc2 100644 --- a/pyload/plugins/addon/AlldebridCom.py +++ b/pyload/plugins/addon/AlldebridCom.py @@ -6,7 +6,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class AlldebridCom(MultiHoster): __name__ = "AlldebridCom" - __type__ = "hook" + __type__ = "addon" __version__ = "0.13" __config__ = [("activated", "bool", "Activated", False), @@ -16,7 +16,7 @@ class AlldebridCom(MultiHoster): ("unloadFailing", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """Alldebrid.com hook plugin""" + __description__ = """Alldebrid.com addon plugin""" __author_name__ = "Andy Voigt" __author_mail__ = "spamsales@online.de" diff --git a/pyload/plugins/addon/BypassCaptcha.py b/pyload/plugins/addon/BypassCaptcha.py index fdd1e567c..51b363eed 100644 --- a/pyload/plugins/addon/BypassCaptcha.py +++ b/pyload/plugins/addon/BypassCaptcha.py @@ -5,7 +5,7 @@ from thread import start_new_thread from pyload.network.HTTPRequest import BadHeader from pyload.network.RequestFactory import getURL, getRequest -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon class BypassCaptchaException(Exception): @@ -23,9 +23,9 @@ class BypassCaptchaException(Exception): return "" % self.err -class BypassCaptcha(Hook): +class BypassCaptcha(Addon): __name__ = "BypassCaptcha" - __type__ = "hook" + __type__ = "addon" __version__ = "0.04" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/Captcha9kw.py b/pyload/plugins/addon/Captcha9kw.py index 45890815c..1cd605b5e 100644 --- a/pyload/plugins/addon/Captcha9kw.py +++ b/pyload/plugins/addon/Captcha9kw.py @@ -9,12 +9,12 @@ from thread import start_new_thread from pyload.network.HTTPRequest import BadHeader from pyload.network.RequestFactory import getURL -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class Captcha9kw(Hook): +class Captcha9kw(Addon): __name__ = "Captcha9kw" - __type__ = "hook" + __type__ = "addon" __version__ = "0.09" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/CaptchaBrotherhood.py b/pyload/plugins/addon/CaptchaBrotherhood.py index 8f6f8d68b..a2c9086c8 100644 --- a/pyload/plugins/addon/CaptchaBrotherhood.py +++ b/pyload/plugins/addon/CaptchaBrotherhood.py @@ -11,7 +11,7 @@ from time import sleep from urllib import urlencode from pyload.network.RequestFactory import getURL, getRequest -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon class CaptchaBrotherhoodException(Exception): @@ -29,9 +29,9 @@ class CaptchaBrotherhoodException(Exception): return "" % self.err -class CaptchaBrotherhood(Hook): +class CaptchaBrotherhood(Addon): __name__ = "CaptchaBrotherhood" - __type__ = "hook" + __type__ = "addon" __version__ = "0.05" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/Checksum.py b/pyload/plugins/addon/Checksum.py index ae9ee1325..1ce5415ed 100644 --- a/pyload/plugins/addon/Checksum.py +++ b/pyload/plugins/addon/Checksum.py @@ -9,7 +9,7 @@ import zlib from os import remove from os.path import getsize, isfile, splitext -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon from pyload.utils import safe_join, fs_encode @@ -37,9 +37,9 @@ def computeChecksum(local_file, algorithm): return None -class Checksum(Hook): +class Checksum(Addon): __name__ = "Checksum" - __type__ = "hook" + __type__ = "addon" __version__ = "0.13" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/ClickAndLoad.py b/pyload/plugins/addon/ClickAndLoad.py index ede970ee8..ae541ca09 100644 --- a/pyload/plugins/addon/ClickAndLoad.py +++ b/pyload/plugins/addon/ClickAndLoad.py @@ -3,12 +3,12 @@ import socket import thread -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class ClickAndLoad(Hook): +class ClickAndLoad(Addon): __name__ = "ClickAndLoad" - __type__ = "hook" + __type__ = "addon" __version__ = "0.22" __config__ = [("activated", "bool", "Activated", True), diff --git a/pyload/plugins/addon/DeathByCaptcha.py b/pyload/plugins/addon/DeathByCaptcha.py index 6e7a585ad..ed2602e32 100644 --- a/pyload/plugins/addon/DeathByCaptcha.py +++ b/pyload/plugins/addon/DeathByCaptcha.py @@ -12,7 +12,7 @@ from time import sleep from pyload.utils import json_loads from pyload.network.HTTPRequest import BadHeader from pyload.network.RequestFactory import getRequest -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon class DeathByCaptchaException(Exception): @@ -44,9 +44,9 @@ class DeathByCaptchaException(Exception): return "" % self.err -class DeathByCaptcha(Hook): +class DeathByCaptcha(Addon): __name__ = "DeathByCaptcha" - __type__ = "hook" + __type__ = "addon" __version__ = "0.03" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/DebridItaliaCom.py b/pyload/plugins/addon/DebridItaliaCom.py index 4272b758f..0cb7a6f4f 100644 --- a/pyload/plugins/addon/DebridItaliaCom.py +++ b/pyload/plugins/addon/DebridItaliaCom.py @@ -5,7 +5,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class DebridItaliaCom(MultiHoster): __name__ = "DebridItaliaCom" - __type__ = "hook" + __type__ = "addon" __version__ = "0.07" __config__ = [("activated", "bool", "Activated", False), @@ -14,7 +14,7 @@ class DebridItaliaCom(MultiHoster): ("unloadFailing", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """Debriditalia.com hook plugin""" + __description__ = """Debriditalia.com addon plugin""" __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" diff --git a/pyload/plugins/addon/DeleteFinished.py b/pyload/plugins/addon/DeleteFinished.py index 6da42c4e3..eb6992fec 100644 --- a/pyload/plugins/addon/DeleteFinished.py +++ b/pyload/plugins/addon/DeleteFinished.py @@ -1,12 +1,12 @@ # -*- coding: utf-8 -*- from pyload.database import style -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class DeleteFinished(Hook): +class DeleteFinished(Addon): __name__ = "DeleteFinished" - __type__ = "hook" + __type__ = "addon" __version__ = "1.09" __config__ = [('activated', 'bool', 'Activated', 'False'), diff --git a/pyload/plugins/addon/DownloadScheduler.py b/pyload/plugins/addon/DownloadScheduler.py index 8336953ee..21b756ea6 100644 --- a/pyload/plugins/addon/DownloadScheduler.py +++ b/pyload/plugins/addon/DownloadScheduler.py @@ -4,12 +4,12 @@ import re from time import localtime -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class DownloadScheduler(Hook): +class DownloadScheduler(Addon): __name__ = "DownloadScheduler" - __type__ = "hook" + __type__ = "addon" __version__ = "0.21" __config__ = [("activated", "bool", "Activated", False), @@ -23,7 +23,7 @@ class DownloadScheduler(Hook): def setup(self): - self.cb = None # callback to scheduler job; will be by removed hookmanager when hook unloaded + self.cb = None # callback to scheduler job; will be by removed hookmanager when addon unloaded def coreReady(self): self.updateSchedule() diff --git a/pyload/plugins/addon/EasybytezCom.py b/pyload/plugins/addon/EasybytezCom.py index 9d1cdc0db..a04111f78 100644 --- a/pyload/plugins/addon/EasybytezCom.py +++ b/pyload/plugins/addon/EasybytezCom.py @@ -7,14 +7,14 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class EasybytezCom(MultiHoster): __name__ = "EasybytezCom" - __type__ = "hook" + __type__ = "addon" __version__ = "0.03" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", "")] - __description__ = """EasyBytez.com hook plugin""" + __description__ = """EasyBytez.com addon plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" diff --git a/pyload/plugins/addon/Ev0InFetcher.py b/pyload/plugins/addon/Ev0InFetcher.py index 0df65ceb6..535d16264 100644 --- a/pyload/plugins/addon/Ev0InFetcher.py +++ b/pyload/plugins/addon/Ev0InFetcher.py @@ -4,12 +4,12 @@ import feedparser from time import mktime, time -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class Ev0InFetcher(Hook): +class Ev0InFetcher(Addon): __name__ = "Ev0InFetcher" - __type__ = "hook" + __type__ = "addon" __version__ = "0.21" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/ExpertDecoders.py b/pyload/plugins/addon/ExpertDecoders.py index 3f0f64f1e..87979a8a8 100644 --- a/pyload/plugins/addon/ExpertDecoders.py +++ b/pyload/plugins/addon/ExpertDecoders.py @@ -9,12 +9,12 @@ from uuid import uuid4 from pyload.network.HTTPRequest import BadHeader from pyload.network.RequestFactory import getURL, getRequest -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class ExpertDecoders(Hook): +class ExpertDecoders(Addon): __name__ = "ExpertDecoders" - __type__ = "hook" + __type__ = "addon" __version__ = "0.01" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/ExternalScripts.py b/pyload/plugins/addon/ExternalScripts.py index edf2139f7..023c656dc 100644 --- a/pyload/plugins/addon/ExternalScripts.py +++ b/pyload/plugins/addon/ExternalScripts.py @@ -6,13 +6,13 @@ from itertools import chain from os import listdir, access, X_OK, makedirs from os.path import join, exists, basename, abspath -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon from pyload.utils import safe_join -class ExternalScripts(Hook): +class ExternalScripts(Addon): __name__ = "ExternalScripts" - __type__ = "hook" + __type__ = "addon" __version__ = "0.24" __config__ = [("activated", "bool", "Activated", True)] diff --git a/pyload/plugins/addon/ExtractArchive.py b/pyload/plugins/addon/ExtractArchive.py index 92db9ce04..20693c83d 100644 --- a/pyload/plugins/addon/ExtractArchive.py +++ b/pyload/plugins/addon/ExtractArchive.py @@ -47,14 +47,14 @@ if os.name != "nt": from os import chown from pwd import getpwnam -from pyload.plugins.base.Hook import Hook, threaded, Expose +from pyload.plugins.base.Addon import Addon, threaded, Expose from pyload.plugins.internal.AbstractExtractor import ArchiveError, CRCError, WrongPassword from pyload.utils import safe_join, fs_encode -class ExtractArchive(Hook): +class ExtractArchive(Addon): __name__ = "ExtractArchive" - __type__ = "hook" + __type__ = "addon" __version__ = "0.17" __config__ = [("activated", "bool", "Activated", True), diff --git a/pyload/plugins/addon/FastixRu.py b/pyload/plugins/addon/FastixRu.py index 9e2abd92a..fed0d57fa 100644 --- a/pyload/plugins/addon/FastixRu.py +++ b/pyload/plugins/addon/FastixRu.py @@ -7,7 +7,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class FastixRu(MultiHoster): __name__ = "FastixRu" - __type__ = "hook" + __type__ = "addon" __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), @@ -15,7 +15,7 @@ class FastixRu(MultiHoster): ("unloadFailing", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """Fastix.ru hook plugin""" + __description__ = """Fastix.ru addon plugin""" __author_name__ = "Massimo Rosamilia" __author_mail__ = "max@spiritix.eu" diff --git a/pyload/plugins/addon/FreeWayMe.py b/pyload/plugins/addon/FreeWayMe.py index 635bc3415..e468bd3ab 100644 --- a/pyload/plugins/addon/FreeWayMe.py +++ b/pyload/plugins/addon/FreeWayMe.py @@ -6,7 +6,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class FreeWayMe(MultiHoster): __name__ = "FreeWayMe" - __type__ = "hook" + __type__ = "addon" __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), @@ -15,7 +15,7 @@ class FreeWayMe(MultiHoster): ("unloadFailing", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """FreeWay.me hook plugin""" + __description__ = """FreeWay.me addon plugin""" __author_name__ = "Nicolas Giese" __author_mail__ = "james@free-way.me" diff --git a/pyload/plugins/addon/HotFolder.py b/pyload/plugins/addon/HotFolder.py index 140e6d4a8..0c5008f93 100644 --- a/pyload/plugins/addon/HotFolder.py +++ b/pyload/plugins/addon/HotFolder.py @@ -6,12 +6,12 @@ from os import listdir, makedirs from os.path import exists, isfile, join from shutil import move -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class HotFolder(Hook): +class HotFolder(Addon): __name__ = "HotFolder" - __type__ = "hook" + __type__ = "addon" __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/IRCInterface.py b/pyload/plugins/addon/IRCInterface.py index 04ae87b05..85175f4da 100644 --- a/pyload/plugins/addon/IRCInterface.py +++ b/pyload/plugins/addon/IRCInterface.py @@ -12,13 +12,13 @@ from traceback import print_exc from pyload.api import PackageDoesNotExists, FileDoesNotExists from pyload.network.RequestFactory import getURL -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon from pyload.utils import formatSize -class IRCInterface(Thread, Hook): +class IRCInterface(Thread, Addon): __name__ = "IRCInterface" - __type__ = "hook" + __type__ = "addon" __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), @@ -39,7 +39,7 @@ class IRCInterface(Thread, Hook): def __init__(self, core, manager): Thread.__init__(self) - Hook.__init__(self, core, manager) + Addon.__init__(self, core, manager) self.setDaemon(True) # self.sm = core.server_methods self.api = core.api # todo, only use api diff --git a/pyload/plugins/addon/ImageTyperz.py b/pyload/plugins/addon/ImageTyperz.py index 7317f234d..916638192 100644 --- a/pyload/plugins/addon/ImageTyperz.py +++ b/pyload/plugins/addon/ImageTyperz.py @@ -9,7 +9,7 @@ from pycurl import FORM_FILE, LOW_SPEED_TIME from thread import start_new_thread from pyload.network.RequestFactory import getURL, getRequest -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon class ImageTyperzException(Exception): @@ -27,9 +27,9 @@ class ImageTyperzException(Exception): return "" % self.err -class ImageTyperz(Hook): +class ImageTyperz(Addon): __name__ = "ImageTyperz" - __type__ = "hook" + __type__ = "addon" __version__ = "0.04" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/LinkdecrypterCom.py b/pyload/plugins/addon/LinkdecrypterCom.py index 418ec4ac4..6c59ee5c6 100644 --- a/pyload/plugins/addon/LinkdecrypterCom.py +++ b/pyload/plugins/addon/LinkdecrypterCom.py @@ -3,18 +3,18 @@ import re from pyload.network.RequestFactory import getURL -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon from pyload.utils import remove_chars -class LinkdecrypterCom(Hook): +class LinkdecrypterCom(Addon): __name__ = "LinkdecrypterCom" - __type__ = "hook" + __type__ = "addon" __version__ = "0.19" __config__ = [("activated", "bool", "Activated", False)] - __description__ = """Linkdecrypter.com hook plugin""" + __description__ = """Linkdecrypter.com addon plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" diff --git a/pyload/plugins/addon/LinksnappyCom.py b/pyload/plugins/addon/LinksnappyCom.py index 9086e3c2a..4a89b75d1 100644 --- a/pyload/plugins/addon/LinksnappyCom.py +++ b/pyload/plugins/addon/LinksnappyCom.py @@ -7,7 +7,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class LinksnappyCom(MultiHoster): __name__ = "LinksnappyCom" - __type__ = "hook" + __type__ = "addon" __version__ = "0.01" __config__ = [("activated", "bool", "Activated", False), @@ -16,7 +16,7 @@ class LinksnappyCom(MultiHoster): ("unloadFailing", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """Linksnappy.com hook plugin""" + __description__ = """Linksnappy.com addon plugin""" __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" diff --git a/pyload/plugins/addon/MegaDebridEu.py b/pyload/plugins/addon/MegaDebridEu.py index 0345e47fa..3faa823bf 100644 --- a/pyload/plugins/addon/MegaDebridEu.py +++ b/pyload/plugins/addon/MegaDebridEu.py @@ -7,13 +7,13 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class MegaDebridEu(MultiHoster): __name__ = "MegaDebridEu" - __type__ = "hook" + __type__ = "addon" __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), ("unloadFailing", "bool", "Revert to standard download if download fails", False)] - __description__ = """mega-debrid.eu hook plugin""" + __description__ = """mega-debrid.eu addon plugin""" __author_name__ = "D.Ducatel" __author_mail__ = "dducatel@je-geek.fr" diff --git a/pyload/plugins/addon/MergeFiles.py b/pyload/plugins/addon/MergeFiles.py index 5a39cef65..16c88bcdd 100644 --- a/pyload/plugins/addon/MergeFiles.py +++ b/pyload/plugins/addon/MergeFiles.py @@ -4,13 +4,13 @@ import os import re import traceback -from pyload.plugins.base.Hook import Hook, threaded +from pyload.plugins.base.Addon import Addon, threaded from pyload.utils import safe_join, fs_encode -class MergeFiles(Hook): +class MergeFiles(Addon): __name__ = "MergeFiles" - __type__ = "hook" + __type__ = "addon" __version__ = "0.12" __config__ = [("activated", "bool", "Activated", False)] diff --git a/pyload/plugins/addon/MultiHome.py b/pyload/plugins/addon/MultiHome.py index 771c3549b..2aa60ecc3 100644 --- a/pyload/plugins/addon/MultiHome.py +++ b/pyload/plugins/addon/MultiHome.py @@ -2,12 +2,12 @@ from time import time -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class MultiHome(Hook): +class MultiHome(Addon): __name__ = "MultiHome" - __type__ = "hook" + __type__ = "addon" __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/MultishareCz.py b/pyload/plugins/addon/MultishareCz.py index 9e1bd50a4..34ba3760a 100644 --- a/pyload/plugins/addon/MultishareCz.py +++ b/pyload/plugins/addon/MultishareCz.py @@ -8,14 +8,14 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class MultishareCz(MultiHoster): __name__ = "MultishareCz" - __type__ = "hook" + __type__ = "addon" __version__ = "0.04" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", "uloz.to")] - __description__ = """MultiShare.cz hook plugin""" + __description__ = """MultiShare.cz addon plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" diff --git a/pyload/plugins/addon/MyfastfileCom.py b/pyload/plugins/addon/MyfastfileCom.py index 216dcaf5d..40f5fb680 100644 --- a/pyload/plugins/addon/MyfastfileCom.py +++ b/pyload/plugins/addon/MyfastfileCom.py @@ -7,7 +7,7 @@ from pyload.utils import json_loads class MyfastfileCom(MultiHoster): __name__ = "MyfastfileCom" - __type__ = "hook" + __type__ = "addon" __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), @@ -16,7 +16,7 @@ class MyfastfileCom(MultiHoster): ("unloadFailing", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """Myfastfile.com hook plugin""" + __description__ = """Myfastfile.com addon plugin""" __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" diff --git a/pyload/plugins/addon/OverLoadMe.py b/pyload/plugins/addon/OverLoadMe.py index fae4209f8..87f4b5852 100644 --- a/pyload/plugins/addon/OverLoadMe.py +++ b/pyload/plugins/addon/OverLoadMe.py @@ -6,7 +6,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class OverLoadMe(MultiHoster): __name__ = "OverLoadMe" - __type__ = "hook" + __type__ = "addon" __version__ = "0.01" __config__ = [("activated", "bool", "Activated", False), @@ -16,7 +16,7 @@ class OverLoadMe(MultiHoster): ("unloadFailing", "bool", "Revert to standard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 12)] - __description__ = """Over-Load.me hook plugin""" + __description__ = """Over-Load.me addon plugin""" __author_name__ = "marley" __author_mail__ = "marley@over-load.me" diff --git a/pyload/plugins/addon/PremiumTo.py b/pyload/plugins/addon/PremiumTo.py index b95b15b53..761731435 100644 --- a/pyload/plugins/addon/PremiumTo.py +++ b/pyload/plugins/addon/PremiumTo.py @@ -6,14 +6,14 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class PremiumTo(MultiHoster): __name__ = "PremiumTo" - __type__ = "hook" + __type__ = "addon" __version__ = "0.04" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for downloads from supported hosters:", "all"), ("hosterList", "str", "Hoster list (comma separated)", "")] - __description__ = """Premium.to hook plugin""" + __description__ = """Premium.to addon plugin""" __author_name__ = ("RaNaN", "zoidberg", "stickell") __author_mail__ = ("RaNaN@pyload.org", "zoidberg@mujmail.cz", "l.stickell@yahoo.it") diff --git a/pyload/plugins/addon/PremiumizeMe.py b/pyload/plugins/addon/PremiumizeMe.py index b6d89adb6..05ff781e6 100644 --- a/pyload/plugins/addon/PremiumizeMe.py +++ b/pyload/plugins/addon/PremiumizeMe.py @@ -7,7 +7,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class PremiumizeMe(MultiHoster): __name__ = "PremiumizeMe" - __type__ = "hook" + __type__ = "addon" __version__ = "0.12" __config__ = [("activated", "bool", "Activated", False), @@ -16,7 +16,7 @@ class PremiumizeMe(MultiHoster): ("unloadFailing", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """Premiumize.me hook plugin""" + __description__ = """Premiumize.me addon plugin""" __author_name__ = "Florian Franzen" __author_mail__ = "FlorianFranzen@gmail.com" diff --git a/pyload/plugins/addon/RPNetBiz.py b/pyload/plugins/addon/RPNetBiz.py index b46e326e6..8f3fd298f 100644 --- a/pyload/plugins/addon/RPNetBiz.py +++ b/pyload/plugins/addon/RPNetBiz.py @@ -7,7 +7,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class RPNetBiz(MultiHoster): __name__ = "RPNetBiz" - __type__ = "hook" + __type__ = "addon" __version__ = "0.1" __config__ = [("activated", "bool", "Activated", False), @@ -16,7 +16,7 @@ class RPNetBiz(MultiHoster): ("unloadFailing", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """RPNet.biz hook plugin""" + __description__ = """RPNet.biz addon plugin""" __author_name__ = "Dman" __author_mail__ = "dmanugm@gmail.com" diff --git a/pyload/plugins/addon/RealdebridCom.py b/pyload/plugins/addon/RealdebridCom.py index c1c519ace..cb56052a9 100644 --- a/pyload/plugins/addon/RealdebridCom.py +++ b/pyload/plugins/addon/RealdebridCom.py @@ -6,7 +6,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class RealdebridCom(MultiHoster): __name__ = "RealdebridCom" - __type__ = "hook" + __type__ = "addon" __version__ = "0.43" __config__ = [("activated", "bool", "Activated", False), @@ -16,7 +16,7 @@ class RealdebridCom(MultiHoster): ("unloadFailing", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """Real-Debrid.com hook plugin""" + __description__ = """Real-Debrid.com addon plugin""" __author_name__ = "Devirex Hazzard" __author_mail__ = "naibaf_11@yahoo.de" diff --git a/pyload/plugins/addon/RehostTo.py b/pyload/plugins/addon/RehostTo.py index 059f36284..87196ff09 100644 --- a/pyload/plugins/addon/RehostTo.py +++ b/pyload/plugins/addon/RehostTo.py @@ -6,7 +6,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class RehostTo(MultiHoster): __name__ = "RehostTo" - __type__ = "hook" + __type__ = "addon" __version__ = "0.43" __config__ = [("activated", "bool", "Activated", False), @@ -15,7 +15,7 @@ class RehostTo(MultiHoster): ("unloadFailing", "bool", "Revert to stanard download if download fails", False), ("interval", "int", "Reload interval in hours (0 to disable)", 24)] - __description__ = """Rehost.to hook plugin""" + __description__ = """Rehost.to addon plugin""" __author_name__ = "RaNaN" __author_mail__ = "RaNaN@pyload.org" diff --git a/pyload/plugins/addon/RestartFailed.py b/pyload/plugins/addon/RestartFailed.py index e1a11db3f..db3a61523 100644 --- a/pyload/plugins/addon/RestartFailed.py +++ b/pyload/plugins/addon/RestartFailed.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class RestartFailed(Hook): +class RestartFailed(Addon): __name__ = "RestartFailed" - __type__ = "hook" + __type__ = "addon" __version__ = "1.55" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/SimplyPremiumCom.py b/pyload/plugins/addon/SimplyPremiumCom.py index f0df36b22..3bed0cd2b 100644 --- a/pyload/plugins/addon/SimplyPremiumCom.py +++ b/pyload/plugins/addon/SimplyPremiumCom.py @@ -7,7 +7,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class SimplyPremiumCom(MultiHoster): __name__ = "SimplyPremiumCom" - __type__ = "hook" + __type__ = "addon" __version__ = "0.02" __config__ = [("activated", "bool", "Activated", "False"), @@ -16,7 +16,7 @@ class SimplyPremiumCom(MultiHoster): ("unloadFailing", "bool", "Revert to standard download if download fails", "False"), ("interval", "int", "Reload interval in hours (0 to disable)", "24")] - __description__ = """Simply-Premium.com hook plugin""" + __description__ = """Simply-Premium.com addon plugin""" __author_name__ = "EvolutionClip" __author_mail__ = "evolutionclip@live.de" diff --git a/pyload/plugins/addon/SimplydebridCom.py b/pyload/plugins/addon/SimplydebridCom.py index f7c899a48..212a56a45 100644 --- a/pyload/plugins/addon/SimplydebridCom.py +++ b/pyload/plugins/addon/SimplydebridCom.py @@ -6,14 +6,14 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class SimplydebridCom(MultiHoster): __name__ = "SimplydebridCom" - __type__ = "hook" + __type__ = "addon" __version__ = "0.01" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", "")] - __description__ = """Simply-Debrid.com hook plugin""" + __description__ = """Simply-Debrid.com addon plugin""" __author_name__ = "Kagenoshin" __author_mail__ = "kagenoshin@gmx.ch" diff --git a/pyload/plugins/addon/UnSkipOnFail.py b/pyload/plugins/addon/UnSkipOnFail.py index 5d2db34ae..27662cad3 100644 --- a/pyload/plugins/addon/UnSkipOnFail.py +++ b/pyload/plugins/addon/UnSkipOnFail.py @@ -3,13 +3,13 @@ from os.path import basename from pyload.datatypes.PyFile import PyFile -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon from pyload.utils import fs_encode -class UnSkipOnFail(Hook): +class UnSkipOnFail(Addon): __name__ = "UnSkipOnFail" - __type__ = "hook" + __type__ = "addon" __version__ = "0.01" __config__ = [("activated", "bool", "Activated", True)] diff --git a/pyload/plugins/addon/UnrestrictLi.py b/pyload/plugins/addon/UnrestrictLi.py index 2ca5ad907..237814f3e 100644 --- a/pyload/plugins/addon/UnrestrictLi.py +++ b/pyload/plugins/addon/UnrestrictLi.py @@ -7,7 +7,7 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class UnrestrictLi(MultiHoster): __name__ = "UnrestrictLi" - __type__ = "hook" + __type__ = "addon" __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), @@ -17,7 +17,7 @@ class UnrestrictLi(MultiHoster): ("interval", "int", "Reload interval in hours (0 to disable)", 24), ("history", "bool", "Delete History", False)] - __description__ = """Unrestrict.li hook plugin""" + __description__ = """Unrestrict.li addon plugin""" __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" diff --git a/pyload/plugins/addon/WindowsPhoneToastNotify.py b/pyload/plugins/addon/WindowsPhoneToastNotify.py index 968b3ffa5..a35e28e3b 100644 --- a/pyload/plugins/addon/WindowsPhoneToastNotify.py +++ b/pyload/plugins/addon/WindowsPhoneToastNotify.py @@ -3,12 +3,12 @@ import httplib import time -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class WindowsPhoneToastNotify(Hook): +class WindowsPhoneToastNotify(Addon): __name__ = "WindowsPhoneToastNotify" - __type__ = "hook" + __type__ = "addon" __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/XFileSharingPro.py b/pyload/plugins/addon/XFileSharingPro.py index e926d6655..7e46f7430 100644 --- a/pyload/plugins/addon/XFileSharingPro.py +++ b/pyload/plugins/addon/XFileSharingPro.py @@ -2,12 +2,12 @@ import re -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon -class XFileSharingPro(Hook): +class XFileSharingPro(Addon): __name__ = "XFileSharingPro" - __type__ = "hook" + __type__ = "addon" __version__ = "0.12" __config__ = [("activated", "bool", "Activated", True), @@ -15,7 +15,7 @@ class XFileSharingPro(Hook): ("includeList", "str", "Include hosters (comma separated)", ""), ("excludeList", "str", "Exclude hosters (comma separated)", "")] - __description__ = """XFileSharingPro hook plugin""" + __description__ = """XFileSharingPro addon plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" diff --git a/pyload/plugins/addon/XMPPInterface.py b/pyload/plugins/addon/XMPPInterface.py index 4a01493a6..f442cc0d0 100644 --- a/pyload/plugins/addon/XMPPInterface.py +++ b/pyload/plugins/addon/XMPPInterface.py @@ -6,12 +6,12 @@ from pyxmpp.interface import implements from pyxmpp.interfaces import * from pyxmpp.jabber.client import JabberClient -from pyload.plugins.hooks.IRCInterface import IRCInterface +from pyload.plugins.addon.IRCInterface import IRCInterface class XMPPInterface(IRCInterface, JabberClient): __name__ = "XMPPInterface" - __type__ = "hook" + __type__ = "addon" __version__ = "0.11" __config__ = [("activated", "bool", "Activated", False), diff --git a/pyload/plugins/addon/ZeveraCom.py b/pyload/plugins/addon/ZeveraCom.py index 155143f64..8f784ba9b 100644 --- a/pyload/plugins/addon/ZeveraCom.py +++ b/pyload/plugins/addon/ZeveraCom.py @@ -6,14 +6,14 @@ from pyload.plugins.internal.MultiHoster import MultiHoster class ZeveraCom(MultiHoster): __name__ = "ZeveraCom" - __type__ = "hook" + __type__ = "addon" __version__ = "0.02" __config__ = [("activated", "bool", "Activated", False), ("hosterListMode", "all;listed;unlisted", "Use for hosters (if supported)", "all"), ("hosterList", "str", "Hoster list (comma separated)", "")] - __description__ = """Real-Debrid.com hook plugin""" + __description__ = """Real-Debrid.com addon plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" diff --git a/pyload/plugins/base/Addon.py b/pyload/plugins/base/Addon.py new file mode 100644 index 000000000..a0b8b9782 --- /dev/null +++ b/pyload/plugins/base/Addon.py @@ -0,0 +1,149 @@ +# -*- coding: utf-8 -*- + +from traceback import print_exc + +from pyload.plugins.Plugin import Base + + +class Expose(object): + """ used for decoration to declare rpc services """ + + def __new__(cls, f, *args, **kwargs): + addonManager.addRPC(f.__module__, f.func_name, f.func_doc) + return f + + +def threaded(f): + + def run(*args,**kwargs): + addonManager.startThread(f, *args, **kwargs) + return run + + +class Addon(Base): + """ + Base class for addon plugins. + """ + __name__ = "Addon" + __type__ = "addon" + __version__ = "0.2" + + __config__ = [("name", "type", "desc", "default")] + + __description__ = """Interface for addon""" + __author_name__ = ("mkaay", "RaNaN") + __author_mail__ = ("mkaay@mkaay.de", "RaNaN@pyload.org") + + #: automatically register event listeners for functions, attribute will be deleted dont use it yourself + event_map = None + + # Alternative to event_map + #: List of events the plugin can handle, name the functions exactly like eventname. + event_list = None # dont make duplicate entries in event_map + + #: periodic call interval in secondc + interval = 60 + + + def __init__(self, core, manager): + Base.__init__(self, core) + + #: Provide information in dict here, usable by API `getInfo` + self.info = None + + #: Callback of periodical job task, used by hookmanager + self.cb = None + + #: `AddonManager` + self.manager = manager + + #register events + 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: + for f in self.event_list: + self.manager.addEvent(f, getattr(self,f)) + + self.event_list = None + + self.setup() + self.initPeriodical() + + + def initPeriodical(self): + if self.interval >=1: + self.cb = self.core.scheduler.addJob(0, self._periodical, threaded=False) + + def _periodical(self): + try: + if self.isActivated(): self.periodical() + except Exception, e: + self.logError(_("Error executing addon: %s") % e) + if self.core.debug: + print_exc() + + self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=False) + + + def __repr__(self): + return "" % self.__name__ + + def setup(self): + """ more init stuff if needed """ + pass + + def unload(self): + """ called when addon was deactivated """ + pass + + def isActivated(self): + """ checks if addon is activated""" + return self.config.getPlugin(self.__name__, "activated") + + + #event methods - overwrite these if needed + def coreReady(self): + pass + + def coreExiting(self): + pass + + def downloadPreparing(self, pyfile): + pass + + def downloadFinished(self, pyfile): + pass + + def downloadFailed(self, pyfile): + pass + + def packageFinished(self, pypack): + pass + + def beforeReconnecting(self, ip): + pass + + def afterReconnecting(self, ip): + pass + + def periodical(self): + pass + + def newCaptchaTask(self, task): + """ new captcha task for the plugin, it MUST set the handler and timeout or will be ignored """ + pass + + def captchaCorrect(self, task): + pass + + def captchaInvalid(self, task): + pass diff --git a/pyload/plugins/base/Hook.py b/pyload/plugins/base/Hook.py deleted file mode 100644 index b9ffbc647..000000000 --- a/pyload/plugins/base/Hook.py +++ /dev/null @@ -1,149 +0,0 @@ -# -*- coding: utf-8 -*- - -from traceback import print_exc - -from pyload.plugins.Plugin import Base - - -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(f): - - def run(*args,**kwargs): - hookManager.startThread(f, *args, **kwargs) - return run - - -class Hook(Base): - """ - Base class for hook plugins. - """ - __name__ = "Hook" - __type__ = "hook" - __version__ = "0.2" - - __config__ = [("name", "type", "desc", "default")] - - __description__ = """Interface for hook""" - __author_name__ = ("mkaay", "RaNaN") - __author_mail__ = ("mkaay@mkaay.de", "RaNaN@pyload.org") - - #: automatically register event listeners for functions, attribute will be deleted dont use it yourself - event_map = None - - # Alternative to event_map - #: List of events the plugin can handle, name the functions exactly like eventname. - event_list = None # dont make duplicate entries in event_map - - #: periodic call interval in secondc - interval = 60 - - - def __init__(self, core, manager): - Base.__init__(self, core) - - #: Provide information in dict here, usable by API `getInfo` - self.info = None - - #: Callback of periodical job task, used by hookmanager - self.cb = None - - #: `HookManager` - self.manager = manager - - #register events - 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: - for f in self.event_list: - self.manager.addEvent(f, getattr(self,f)) - - self.event_list = None - - self.setup() - self.initPeriodical() - - - def initPeriodical(self): - if self.interval >=1: - self.cb = self.core.scheduler.addJob(0, self._periodical, threaded=False) - - def _periodical(self): - try: - if self.isActivated(): self.periodical() - except Exception, e: - self.logError(_("Error executing hooks: %s") % str(e)) - if self.core.debug: - print_exc() - - self.cb = self.core.scheduler.addJob(self.interval, self._periodical, threaded=False) - - - def __repr__(self): - return "" % self.__name__ - - def setup(self): - """ more init stuff if needed """ - pass - - def unload(self): - """ called when hook was deactivated """ - pass - - def isActivated(self): - """ checks if hook is activated""" - return self.config.getPlugin(self.__name__, "activated") - - - #event methods - overwrite these if needed - def coreReady(self): - pass - - def coreExiting(self): - pass - - def downloadPreparing(self, pyfile): - pass - - def downloadFinished(self, pyfile): - pass - - def downloadFailed(self, pyfile): - pass - - def packageFinished(self, pypack): - pass - - def beforeReconnecting(self, ip): - pass - - def afterReconnecting(self, ip): - pass - - def periodical(self): - pass - - def newCaptchaTask(self, task): - """ new captcha task for the plugin, it MUST set the handler and timeout or will be ignored """ - pass - - def captchaCorrect(self, task): - pass - - def captchaInvalid(self, task): - pass diff --git a/pyload/plugins/crypter/MultiuploadCom.py b/pyload/plugins/crypter/MultiuploadCom.py index 754247ec7..148d76b8f 100644 --- a/pyload/plugins/crypter/MultiuploadCom.py +++ b/pyload/plugins/crypter/MultiuploadCom.py @@ -10,6 +10,6 @@ class MultiuploadCom(DeadCrypter): __pattern__ = r'http://(?:www\.)?multiupload\.(com|nl)/\w+' - __description__ = """ MultiUpload.com decrypter plugin """ + __description__ = """MultiUpload.com decrypter plugin""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" diff --git a/pyload/plugins/crypter/UploadableChFolder.py b/pyload/plugins/crypter/UploadableChFolder.py index 3be8b0167..acc56580c 100644 --- a/pyload/plugins/crypter/UploadableChFolder.py +++ b/pyload/plugins/crypter/UploadableChFolder.py @@ -10,7 +10,7 @@ class UploadableChFolder(SimpleCrypter): __pattern__ = r'http://(?:www\.)?uploadable\.ch/list/\w+' - __description__ = """ Uploadable.ch folder decrypter plugin """ + __description__ = """Uploadable.ch folder decrypter plugin""" __author_name__ = ("guidobelix", "Walter Purcaro") __author_mail__ = ("guidobelix@hotmail.it", "vuolter@gmail.com") diff --git a/pyload/plugins/hoster/LoadTo.py b/pyload/plugins/hoster/LoadTo.py index ebaaa3d0d..8798819e3 100644 --- a/pyload/plugins/hoster/LoadTo.py +++ b/pyload/plugins/hoster/LoadTo.py @@ -17,7 +17,7 @@ class LoadTo(SimpleHoster): __pattern__ = r'http://(?:www\.)?load\.to/\w+' - __description__ = """ Load.to hoster plugin """ + __description__ = """Load.to hoster plugin""" __author_name__ = ("halfman", "stickell") __author_mail__ = ("Pulpan3@gmail.com", "l.stickell@yahoo.it") diff --git a/pyload/plugins/hoster/LomafileCom.py b/pyload/plugins/hoster/LomafileCom.py index 3b75a79ab..2ae6973c8 100644 --- a/pyload/plugins/hoster/LomafileCom.py +++ b/pyload/plugins/hoster/LomafileCom.py @@ -12,7 +12,7 @@ class LomafileCom(SimpleHoster): __pattern__ = r'https?://lomafile\.com/.+/[\w\.]+' - __description__ = """ Lomafile.com hoster plugin """ + __description__ = """Lomafile.com hoster plugin""" __author_name__ = "nath_schwarz" __author_mail__ = "nathan.notwhite@gmail.com" diff --git a/pyload/plugins/hoster/TurbobitNet.py b/pyload/plugins/hoster/TurbobitNet.py index 5dd01fad5..cc9cf16d3 100644 --- a/pyload/plugins/hoster/TurbobitNet.py +++ b/pyload/plugins/hoster/TurbobitNet.py @@ -21,7 +21,7 @@ class TurbobitNet(SimpleHoster): __pattern__ = r'http://(?:www\.)?turbobit\.net/(?:download/free/)?(?P\w+)' - __description__ = """ Turbobit.net hoster plugin """ + __description__ = """Turbobit.net hoster plugin""" __author_name__ = ("zoidberg", "prOq") __author_mail__ = ("zoidberg@mujmail.cz", None) diff --git a/pyload/plugins/internal/AbstractExtractor.py b/pyload/plugins/internal/AbstractExtractor.py index d1d1a09cb..39bc46b1e 100644 --- a/pyload/plugins/internal/AbstractExtractor.py +++ b/pyload/plugins/internal/AbstractExtractor.py @@ -39,7 +39,7 @@ class AbtractExtractor: def __init__(self, m, file, out, fullpath, overwrite, excludefiles, renice): """Initialize extractor for specific file - :param m: ExtractArchive Hook plugin + :param m: ExtractArchive Addon plugin :param file: Absolute filepath :param out: Absolute path to destination directory :param fullpath: extract to fullpath diff --git a/pyload/plugins/internal/DeadCrypter.py b/pyload/plugins/internal/DeadCrypter.py index c9e1eded1..2d4dfc7e6 100644 --- a/pyload/plugins/internal/DeadCrypter.py +++ b/pyload/plugins/internal/DeadCrypter.py @@ -10,7 +10,7 @@ class DeadCrypter(_Crypter): __pattern__ = None - __description__ = """ Crypter is no longer available """ + __description__ = """Crypter is no longer available""" __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" diff --git a/pyload/plugins/internal/DeadHoster.py b/pyload/plugins/internal/DeadHoster.py index a7b873d30..72fd356bd 100644 --- a/pyload/plugins/internal/DeadHoster.py +++ b/pyload/plugins/internal/DeadHoster.py @@ -18,7 +18,7 @@ class DeadHoster(_Hoster): __pattern__ = None - __description__ = """ Hoster is no longer available """ + __description__ = """Hoster is no longer available""" __author_name__ = "zoidberg" __author_mail__ = "zoidberg@mujmail.cz" diff --git a/pyload/plugins/internal/MultiHoster.py b/pyload/plugins/internal/MultiHoster.py index 48345eeca..c94f87493 100644 --- a/pyload/plugins/internal/MultiHoster.py +++ b/pyload/plugins/internal/MultiHoster.py @@ -2,13 +2,13 @@ import re -from pyload.plugins.base.Hook import Hook +from pyload.plugins.base.Addon import Addon from pyload.utils import remove_chars -class MultiHoster(Hook): +class MultiHoster(Addon): __name__ = "MultiHoster" - __type__ = "hook" + __type__ = "addon" __version__ = "0.20" __description__ = """Generic MultiHoster plugin""" diff --git a/pyload/plugins/internal/UpdateManager.py b/pyload/plugins/internal/UpdateManager.py index 50a965228..7848fa2de 100644 --- a/pyload/plugins/internal/UpdateManager.py +++ b/pyload/plugins/internal/UpdateManager.py @@ -7,13 +7,13 @@ from operator import itemgetter from os import path, remove, stat from pyload.network.RequestFactory import getURL -from pyload.plugins.base.Hook import Expose, Hook, threaded +from pyload.plugins.base.Addon import Expose, Addon, threaded from pyload.utils import safe_join -class UpdateManager(Hook): +class UpdateManager(Addon): __name__ = "UpdateManager" - __type__ = "hook" + __type__ = "addon" __version__ = "0.36" __config__ = [("activated", "bool", "Activated", True), @@ -22,7 +22,7 @@ class UpdateManager(Hook): ("reloadplugins", "bool", "Monitor plugins for code changes (debug mode only)", True), ("nodebugupdate", "bool", "Don't check for updates in debug mode", True)] - __description__ = """ Check for updates """ + __description__ = """Check for updates""" __author_name__ = "Walter Purcaro" __author_mail__ = "vuolter@gmail.com" @@ -287,7 +287,7 @@ class UpdateManager(Hook): if path.isfile(filename): try: if type == "addon": - self.manager.deactivateHook(name) + self.manager.deactivateAddon(name) remove(filename) except Exception, e: self.logDebug("Error deleting: %s" % path.basename(filename), e) -- cgit v1.2.3