Files
media-map/backend/app/core/config.py
Danilo Reyes 2b1a92fb49
Some checks failed
Test Suite / test (push) Has been cancelled
Add new API endpoints for media retrieval by country and enhance configuration
- Introduced `/api/tmdb` and `/api/collection/missing-locations` endpoints to the backend for improved media management.
- Added a new `get_media_by_country` function in the collection API to fetch media items based on country codes.
- Updated configuration to allow overriding *arr base URLs via environment variables for better flexibility.
- Enhanced frontend with a new `MissingLocations` component and integrated it into the routing structure.
- Improved the `CollectionMap` component to handle country selection and display media items accordingly.
- Added testing dependencies in `requirements.txt` and updated frontend configuration for testing support.
2025-12-28 22:35:06 -06:00

47 lines
1.5 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 = os.getenv("HOST", "0.0.0.0") # Default to all interfaces
# 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 (can be overridden via environment variables)
sonarr_url: str = os.getenv("SONARR_URL", "http://127.0.0.1:8989")
radarr_url: str = os.getenv("RADARR_URL", "http://127.0.0.1:7878")
lidarr_url: str = os.getenv("LIDARR_URL", "http://127.0.0.1:8686")
# Admin
admin_token: Optional[str] = os.getenv("MOVIEMAP_ADMIN_TOKEN")
# External APIs (optional)
tmdb_api_key: str = os.getenv("TMDB_API_KEY", "")
@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()