51b10438a9
- backend/ uses proper Python src layout (src/media_library_viewer_api/) with pyproject.toml, hatchling build, and PYTHONPATH=src convention - frontend/ is a Vite + React + TypeScript SPA - archive/ preserves the original Streamlit prototype for reference - Cleaned up root to only contain docs, license, and subproject dirs - Updated README for the new dual-subproject architecture
50 lines
1.3 KiB
Python
50 lines
1.3 KiB
Python
"""Configuration loading for the app.
|
|
|
|
Configuration is intentionally environment/.env based so credentials stay out of
|
|
source control and the same package can be reused by different frontends or
|
|
process managers.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class JellyfinConfig:
|
|
"""Jellyfin connection settings."""
|
|
|
|
url: str = os.getenv("JELLYFIN_URL", "")
|
|
api_key: str = os.getenv("JELLYFIN_API_KEY", "")
|
|
user_id: str = os.getenv("JELLYFIN_USER_ID", "")
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class SSHConfig:
|
|
"""SSH connection settings for remote file/resource access."""
|
|
|
|
host: str = os.getenv("SSH_HOST", "")
|
|
username: str = os.getenv("SSH_USERNAME", "")
|
|
port: int = int(os.getenv("SSH_PORT", "22"))
|
|
key_filename: str = os.getenv("SSH_KEY_FILENAME", str(Path.home() / ".ssh" / "id_rsa"))
|
|
password: str = os.getenv("SSH_PASSWORD", "")
|
|
media_root: str = os.getenv("REMOTE_MEDIA_ROOT", "")
|
|
path_prefix: str = os.getenv("REMOTE_PATH_PREFIX", "")
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class AppConfig:
|
|
jellyfin: JellyfinConfig = JellyfinConfig()
|
|
ssh: SSHConfig = SSHConfig()
|
|
|
|
|
|
def load_config() -> AppConfig:
|
|
"""Build an AppConfig snapshot from the current environment/.env file."""
|
|
return AppConfig()
|