Skip to content

Commit

Permalink
feat(extensions): start building an interface to split notifiers, pro…
Browse files Browse the repository at this point in the history
…viders, metadata, clients, etc out into namespaced plugin packages

Signed-off-by: miigotu <[email protected]>
  • Loading branch information
miigotu committed Oct 31, 2022
1 parent 5d8a4ca commit 2c46004
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 153 deletions.
49 changes: 49 additions & 0 deletions sickchill/extensions/manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import importlib
import pkgutil

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

import sickchill.extensions


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")}
152 changes: 0 additions & 152 deletions sickchill/oldbeard/stevedore.py

This file was deleted.

3 changes: 2 additions & 1 deletion sickchill/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

if TYPE_CHECKING:
from .movies import MovieList
from configobj import ConfigObj

setup_gettext()

Expand Down Expand Up @@ -82,7 +83,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

0 comments on commit 2c46004

Please sign in to comment.