diff --git a/backend/src/config/__init__.py b/backend/src/config/__init__.py index c4f0716..1796724 100644 --- a/backend/src/config/__init__.py +++ b/backend/src/config/__init__.py @@ -6,10 +6,6 @@ from pydantic import BaseModel class BasicConfig(BaseModel): storage_directory: str = os.getenv("STORAGE_FILE_PATH") or "." -class ProwlarrConfig(BaseModel): - enabled: bool = bool(os.getenv("PROWLARR_ENABLED") or True) - api_key: str = os.getenv("PROWLARR_API_KEY") - url: str = os.getenv("PROWLARR_URL") diff --git a/backend/src/indexer/__init__.py b/backend/src/indexer/__init__.py index f1c6d9d..b4c4a11 100644 --- a/backend/src/indexer/__init__.py +++ b/backend/src/indexer/__init__.py @@ -1,7 +1,7 @@ import logging -import config from database.tv import Season +from indexer.config import ProwlarrConfig from indexer.generic import GenericIndexer, IndexerQueryResult from indexer.prowlarr import Prowlarr @@ -23,5 +23,5 @@ def search(query: str | Season) -> list[IndexerQueryResult]: indexers: list[GenericIndexer] = [] -if config.ProwlarrConfig().enabled: +if ProwlarrConfig.enabled: indexers.append(Prowlarr()) diff --git a/backend/src/indexer/config.py b/backend/src/indexer/config.py new file mode 100644 index 0000000..783d88a --- /dev/null +++ b/backend/src/indexer/config.py @@ -0,0 +1,8 @@ +from pydantic_settings import BaseSettings, SettingsConfigDict + + +class ProwlarrConfig(BaseSettings): + model_config = SettingsConfigDict(env_prefix="PROWLARR_") + enabled: bool = True + api_key: str + url: str diff --git a/backend/src/indexer/prowlarr.py b/backend/src/indexer/prowlarr.py index 30f57bf..fb4b298 100644 --- a/backend/src/indexer/prowlarr.py +++ b/backend/src/indexer/prowlarr.py @@ -2,8 +2,8 @@ import logging import requests -from config import ProwlarrConfig from indexer import GenericIndexer, IndexerQueryResult +from indexer.config import ProwlarrConfig log = logging.getLogger(__name__) @@ -17,7 +17,7 @@ class Prowlarr(GenericIndexer): :param kwargs: Additional keyword arguments to pass to the superclass constructor. """ super().__init__(name='prowlarr') - config = ProwlarrConfig() + config = ProwlarrConfig self.api_key = config.api_key self.url = config.url