0ea5f10b31
Ampel / ampel (push) Failing after 12m31s
- Metadaten-Preview WIEDERHERGESTELLT (Stub ueberschattete echte prescan-Implementierung), tote Altmodule geloescht - Celery update_state statt Phantom-Task/erfundener API - abcde-Kommando korrigiert (CD-Ripping war nie funktionsfaehig) - JWT: fester Schluessel Pflicht, echtes Logout, Cleanup nur Abgelaufene - main.py: crashende Endpoints (Path/secrets/api_keys), year-Bug, Admin-Login aus .env - Ruff gruen (29 Funde), Tests: auth/cache_keys/ripping_helpers, Placebo-test_health raus - SAVEPOINT: offene MakeMKV-Entscheidung SICHTBAR gemacht (Regel B)
58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
"""Validation für Rippy Configuration."""
|
|
|
|
from pydantic import ValidationError
|
|
from config import Settings
|
|
|
|
|
|
class ConfigValidationError(Exception):
|
|
"""Wird geworfen, wenn die Konfiguration ungültig ist."""
|
|
pass
|
|
|
|
|
|
def validate_config() -> Settings:
|
|
"""Validiere Konfiguration und wirf Fehler bei fehlenden Pflicht-Werten."""
|
|
try:
|
|
settings = Settings()
|
|
|
|
# TMDB API Key ist Pflicht (gemäß KONZEPT.md)
|
|
if not settings.tmdb_api_key:
|
|
raise ConfigValidationError(
|
|
"TMDB_API_KEY ist erforderlich für Metadaten-Lookup.\n"
|
|
"Hole dir einen免费en Key auf https://www.themoviedb.org/\n"
|
|
"Setze ihn als Umgebungsvariable: TMDB_API_KEY=dein_key"
|
|
)
|
|
|
|
return settings
|
|
except ValidationError as e:
|
|
raise ConfigValidationError(f"Konfigurationsfehler: {e}")
|
|
|
|
|
|
def get_config_with_fallback() -> tuple[Settings, list[str]]:
|
|
"""Hole Konfiguration mit Fallback-Werten für optionale Felder.
|
|
|
|
Returns:
|
|
tuple: (Settings, List of warnings)
|
|
"""
|
|
settings = Settings()
|
|
warnings = []
|
|
|
|
# Optional: TVDb API Key (Fallback auf TMDB)
|
|
if not settings.thetvdb_api_key:
|
|
warnings.append(
|
|
"THETVDB_API_KEY nicht gesetzt. TheTVDB-Fallback wird verwendet."
|
|
)
|
|
|
|
# Optional: MusicBrainz User (Fallback auf öffentlichen Zugriff)
|
|
if not settings.musicbrainz_user:
|
|
warnings.append(
|
|
"MUSICBRAINZ_USER nicht gesetzt. Öffentlicher Zugriff wird verwendet."
|
|
)
|
|
|
|
# Optional: JWT Secret (wird generiert, wenn nicht gesetzt)
|
|
if not settings.jwt_secret_key:
|
|
warnings.append(
|
|
"JWT_SECRET_KEY nicht gesetzt. Auto-Generierung wird verwendet."
|
|
)
|
|
|
|
return settings, warnings
|