Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a plugin system #8272

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions sickchill/extensions/manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import importlib
import pkgutil

import sickchill.extensions
from sickchill import logger, settings
from sickchill.oldbeard import config


def iter_namespace(ns_pkg):
return pkgutil.iter_modules(ns_pkg.__path__, ns_pkg.__name__ + ".")


def discover():
global extenstions
extensions = {}
for finder, name, ispkg in iter_namespace(sickchill.extensions):
if name == __name__:
continue
try:
plugin = importlib.import_module(name)
extensions[name] = plugin
except Exception as e:
logger.debug("Error importing extension: {0}".format(name), exc_info=e)

config.check_section(settings.CFG, "extensions")
for extension in extensions:
logger.debug("Loading {extension} from {path}".format(extension=extension, path=extensions[extension].__path__))
config.check_section(settings.CFG["extensions"], extension.name)

global clients, providers, metadata, notifiers, indexers, post_processors

# Clients
clients = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "Client")}

# Providers
providers = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "Provider")}

# Metadata
metadata = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "Metadata")}

# Notifiers
notifiers = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "Notifier")}

# TVDB, TVMAZE, TMDB, etc
indexers = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "Indexer")}

# Post Processors
post_processors = {extension.name: extension for name, extension in extensions.items() if hasattr(extension, "PostProcessor")}
4 changes: 3 additions & 1 deletion sickchill/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
from .init_helpers import setup_gettext, sickchill_dir

if TYPE_CHECKING:
from configobj import ConfigObj

from .movies import MovieList

setup_gettext()
Expand Down Expand Up @@ -84,7 +86,7 @@
CALENDAR_UNPROTECTED = False
CF_AUTH_DOMAIN = ""
CF_POLICY_AUD = ""
CFG = None
CFG: "ConfigObj" = None
CHECK_PROPERS_INTERVAL = None
CLIENT_WEB_URLS = {"torrent": "", "newznab": ""}
COMING_EPS_DISPLAY_PAUSED = False
Expand Down
Loading