mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-27 19:25:40 +02:00
refactor indexer module
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
8
backend/src/indexer/config.py
Normal file
8
backend/src/indexer/config.py
Normal 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
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user