refactor indexer module

This commit is contained in:
maxDorninger
2025-03-27 19:14:31 +01:00
parent 89f53040ed
commit 9d3e6d6eba
4 changed files with 12 additions and 8 deletions

View File

@@ -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")

View File

@@ -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())

View File

@@ -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

View File

@@ -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