- Updated `README.md` to include instructions for setting up the TMDB API key and new admin endpoints for managing country metadata. - Implemented `/admin/missing-countries` endpoint to list media items without country metadata, with filtering options for source and media type. - Added `/admin/assign-country` endpoint to manually assign a country code to a media item. - Enhanced country extraction logic in `sync.py` to utilize TMDB and MusicBrainz APIs for automatic country retrieval based on available metadata. - Updated configuration in `config.py` to include optional TMDB API key setting. - Improved error handling and logging for country extraction failures. - Ensured that country data is stored and utilized during media item synchronization across Radarr, Sonarr, and Lidarr.
47 lines
1.4 KiB
Python
47 lines
1.4 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
|
|
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")
|
|
|
|
# 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()
|
|
|