44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""Application configuration"""
|
|
from pydantic_settings import BaseSettings
|
|
from typing import Optional
|
|
import os
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application settings"""
|
|
|
|
# Server
|
|
port: int = int(os.getenv("PORT", "8080"))
|
|
host: str = "127.0.0.1"
|
|
|
|
# Database
|
|
postgres_socket_path: str = os.getenv("POSTGRES_SOCKET_PATH", "/run/postgresql")
|
|
postgres_db: str = os.getenv("POSTGRES_DB", "jawz")
|
|
postgres_user: str = os.getenv("POSTGRES_USER", os.getenv("USER", "jawz"))
|
|
|
|
# *arr API keys
|
|
sonarr_api_key: str = os.getenv("SONARR_API_KEY", "")
|
|
radarr_api_key: str = os.getenv("RADARR_API_KEY", "")
|
|
lidarr_api_key: str = os.getenv("LIDARR_API_KEY", "")
|
|
|
|
# *arr base URLs
|
|
sonarr_url: str = "http://127.0.0.1:8989"
|
|
radarr_url: str = "http://127.0.0.1:7878"
|
|
lidarr_url: str = "http://127.0.0.1:8686"
|
|
|
|
# Admin
|
|
admin_token: Optional[str] = os.getenv("MOVIEMAP_ADMIN_TOKEN")
|
|
|
|
@property
|
|
def database_url(self) -> str:
|
|
"""Build PostgreSQL connection string using Unix socket"""
|
|
return f"postgresql://{self.postgres_user}@/{self.postgres_db}?host={self.postgres_socket_path}"
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = False
|
|
|
|
|
|
settings = Settings()
|
|
|