Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a75527135 | ||
|
|
23132c6219 | ||
|
|
514f417c15 | ||
|
|
e8bbbc7d1e |
No files matched your search
@@ -8,6 +8,7 @@ La configuration des services (Radarr, Sonarr, Prowlarr, Jellyfin, Overseerr/See
|
|||||||
|
|
||||||
- Le backend lit ce fichier.
|
- Le backend lit ce fichier.
|
||||||
- L'interface modifie ce fichier via l'API (écriture atomique côté backend).
|
- L'interface modifie ce fichier via l'API (écriture atomique côté backend).
|
||||||
|
- Chaque service expose un statut dans la page Configuration: `Non configuré` (URL ou clé API manquante), `Configuré · non testé`, `Testé` (dernier test de connexion réussi, version affichée) ou `Test échoué`. Le résultat du dernier test est conservé dans `conf.json` (bloc `test`) et invalidé dès que l'URL ou les identifiants changent.
|
||||||
|
|
||||||
Radarr (rappel API):
|
Radarr (rappel API):
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
from datetime import UTC, datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
@@ -9,10 +10,20 @@ from pydantic import BaseModel, Field
|
|||||||
from app.config import settings
|
from app.config import settings
|
||||||
|
|
||||||
|
|
||||||
|
class TestState(BaseModel):
|
||||||
|
"""Resultat du dernier test de connexion (None = jamais teste)."""
|
||||||
|
|
||||||
|
at: str | None = None
|
||||||
|
ok: bool | None = None
|
||||||
|
version: str | None = None
|
||||||
|
error: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class ApiServiceConfig(BaseModel):
|
class ApiServiceConfig(BaseModel):
|
||||||
url: str | None = None
|
url: str | None = None
|
||||||
port: int | None = None
|
port: int | None = None
|
||||||
api_key: str | None = None
|
api_key: str | None = None
|
||||||
|
test: TestState = Field(default_factory=TestState)
|
||||||
|
|
||||||
|
|
||||||
class QbittorrentConfig(BaseModel):
|
class QbittorrentConfig(BaseModel):
|
||||||
@@ -20,6 +31,7 @@ class QbittorrentConfig(BaseModel):
|
|||||||
port: int | None = None
|
port: int | None = None
|
||||||
username: str | None = None
|
username: str | None = None
|
||||||
password: str | None = None
|
password: str | None = None
|
||||||
|
test: TestState = Field(default_factory=TestState)
|
||||||
|
|
||||||
|
|
||||||
def build_base_url(url: str | None, port: int | None = None) -> str | None:
|
def build_base_url(url: str | None, port: int | None = None) -> str | None:
|
||||||
@@ -54,6 +66,48 @@ def config_path() -> Path:
|
|||||||
return settings.config_dir / "conf.json"
|
return settings.config_dir / "conf.json"
|
||||||
|
|
||||||
|
|
||||||
|
SERVICE_NAMES = ("radarr", "sonarr", "prowlarr", "jellyfin", "seerr", "qbittorrent")
|
||||||
|
|
||||||
|
|
||||||
|
def service_configured(service: ApiServiceConfig | QbittorrentConfig) -> bool:
|
||||||
|
"""Un service est completement configure quand son URL (et sa cle API,
|
||||||
|
quand il en faut une) est renseignee."""
|
||||||
|
if isinstance(service, QbittorrentConfig):
|
||||||
|
return bool(service.url)
|
||||||
|
return bool(service.url and service.api_key)
|
||||||
|
|
||||||
|
|
||||||
|
def service_status(service: ApiServiceConfig | QbittorrentConfig) -> str:
|
||||||
|
"""Statut expose a l'UI: unconfigured | configured | tested | error."""
|
||||||
|
if not service_configured(service):
|
||||||
|
return "unconfigured"
|
||||||
|
if service.test.ok is None:
|
||||||
|
return "configured"
|
||||||
|
return "tested" if service.test.ok else "error"
|
||||||
|
|
||||||
|
|
||||||
|
def record_test(
|
||||||
|
service_name: str, ok: bool, version: str | None = None, error: str | None = None
|
||||||
|
) -> None:
|
||||||
|
"""Persiste dans conf.json le resultat du dernier test de connexion."""
|
||||||
|
if service_name not in SERVICE_NAMES:
|
||||||
|
raise ValueError(f"Service inconnu: {service_name}")
|
||||||
|
cfg = read_config()
|
||||||
|
service = getattr(cfg, service_name)
|
||||||
|
service.test = TestState(
|
||||||
|
at=datetime.now(UTC).isoformat(),
|
||||||
|
ok=ok,
|
||||||
|
version=version if ok else None,
|
||||||
|
error=None if ok else error,
|
||||||
|
)
|
||||||
|
write_config(cfg)
|
||||||
|
|
||||||
|
|
||||||
|
def reset_test(service: ApiServiceConfig | QbittorrentConfig) -> None:
|
||||||
|
"""Reinitialise le statut de test quand la configuration change."""
|
||||||
|
service.test = TestState()
|
||||||
|
|
||||||
|
|
||||||
def read_config() -> AppConfig:
|
def read_config() -> AppConfig:
|
||||||
path = config_path()
|
path = config_path()
|
||||||
if not path.exists():
|
if not path.exists():
|
||||||
|
|||||||
+171
-39
@@ -14,7 +14,17 @@ from sqlalchemy import inspect, select, text, update
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from app import auth
|
from app import auth
|
||||||
from app.conf_store import ApiServiceConfig, build_base_url, read_config, write_config
|
from app.conf_store import (
|
||||||
|
ApiServiceConfig,
|
||||||
|
QbittorrentConfig,
|
||||||
|
build_base_url,
|
||||||
|
read_config,
|
||||||
|
record_test,
|
||||||
|
reset_test,
|
||||||
|
service_configured,
|
||||||
|
service_status,
|
||||||
|
write_config,
|
||||||
|
)
|
||||||
from app.converter import cancel_conversion, conversion_paths, finalize_validation
|
from app.converter import cancel_conversion, conversion_paths, finalize_validation
|
||||||
from app.database import Base, engine, get_db
|
from app.database import Base, engine, get_db
|
||||||
from app.models import IsoMovie
|
from app.models import IsoMovie
|
||||||
@@ -64,6 +74,7 @@ async def lifespan(_: FastAPI):
|
|||||||
# Don't fail app startup for a best-effort migration.
|
# Don't fail app startup for a best-effort migration.
|
||||||
pass
|
pass
|
||||||
auth.bootstrap_setup()
|
auth.bootstrap_setup()
|
||||||
|
_log_config_summary()
|
||||||
worker_task = asyncio.create_task(conversion_worker())
|
worker_task = asyncio.create_task(conversion_worker())
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
@@ -84,7 +95,26 @@ DbSession = Annotated[Session, Depends(get_db)]
|
|||||||
|
|
||||||
def _api_service_read(service: ApiServiceConfig) -> ApiServiceSettingsRead:
|
def _api_service_read(service: ApiServiceConfig) -> ApiServiceSettingsRead:
|
||||||
return ApiServiceSettingsRead(
|
return ApiServiceSettingsRead(
|
||||||
url=service.url, port=service.port, api_key_configured=service.api_key is not None
|
url=service.url,
|
||||||
|
port=service.port,
|
||||||
|
api_key_configured=service.api_key is not None,
|
||||||
|
status=service_status(service),
|
||||||
|
tested_version=service.test.version,
|
||||||
|
tested_at=service.test.at,
|
||||||
|
test_error=service.test.error,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _qbittorrent_read(qb: QbittorrentConfig) -> QbittorrentSettingsRead:
|
||||||
|
return QbittorrentSettingsRead(
|
||||||
|
url=qb.url,
|
||||||
|
port=qb.port,
|
||||||
|
username=qb.username,
|
||||||
|
password_configured=qb.password is not None,
|
||||||
|
status=service_status(qb),
|
||||||
|
tested_version=qb.test.version,
|
||||||
|
tested_at=qb.test.at,
|
||||||
|
test_error=qb.test.error,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -96,11 +126,7 @@ def _settings_read() -> SettingsRead:
|
|||||||
prowlarr=_api_service_read(cfg.prowlarr),
|
prowlarr=_api_service_read(cfg.prowlarr),
|
||||||
jellyfin=_api_service_read(cfg.jellyfin),
|
jellyfin=_api_service_read(cfg.jellyfin),
|
||||||
seerr=_api_service_read(cfg.seerr),
|
seerr=_api_service_read(cfg.seerr),
|
||||||
qbittorrent=QbittorrentSettingsRead(
|
qbittorrent=_qbittorrent_read(cfg.qbittorrent),
|
||||||
url=cfg.qbittorrent.url,
|
|
||||||
username=cfg.qbittorrent.username,
|
|
||||||
password_configured=cfg.qbittorrent.password is not None,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -126,12 +152,7 @@ def health() -> HealthRead:
|
|||||||
|
|
||||||
@app.get("/api/settings/radarr", response_model=RadarrSettingsRead)
|
@app.get("/api/settings/radarr", response_model=RadarrSettingsRead)
|
||||||
def get_radarr_settings() -> RadarrSettingsRead:
|
def get_radarr_settings() -> RadarrSettingsRead:
|
||||||
radarr = read_config().radarr
|
return _api_service_read(read_config().radarr)
|
||||||
return RadarrSettingsRead(
|
|
||||||
url=radarr.url,
|
|
||||||
port=radarr.port,
|
|
||||||
api_key_configured=radarr.api_key is not None,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.put("/api/settings/radarr", response_model=RadarrSettingsRead)
|
@app.put("/api/settings/radarr", response_model=RadarrSettingsRead)
|
||||||
@@ -140,16 +161,19 @@ def put_radarr_settings(
|
|||||||
) -> RadarrSettingsRead:
|
) -> RadarrSettingsRead:
|
||||||
cfg = read_config()
|
cfg = read_config()
|
||||||
url = str(payload.url).strip().rstrip("/")
|
url = str(payload.url).strip().rstrip("/")
|
||||||
|
# Toute modification de la connexion invalide le dernier test.
|
||||||
|
if (
|
||||||
|
url != (cfg.radarr.url or "")
|
||||||
|
or payload.port != cfg.radarr.port
|
||||||
|
or (payload.api_key and payload.api_key != cfg.radarr.api_key)
|
||||||
|
):
|
||||||
|
reset_test(cfg.radarr)
|
||||||
cfg.radarr.url = url
|
cfg.radarr.url = url
|
||||||
cfg.radarr.port = payload.port
|
cfg.radarr.port = payload.port
|
||||||
if payload.api_key:
|
if payload.api_key:
|
||||||
cfg.radarr.api_key = payload.api_key
|
cfg.radarr.api_key = payload.api_key
|
||||||
write_config(cfg)
|
write_config(cfg)
|
||||||
return RadarrSettingsRead(
|
return _api_service_read(cfg.radarr)
|
||||||
url=url,
|
|
||||||
port=cfg.radarr.port,
|
|
||||||
api_key_configured=cfg.radarr.api_key is not None,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.get("/api/settings", response_model=SettingsRead)
|
@app.get("/api/settings", response_model=SettingsRead)
|
||||||
@@ -164,6 +188,13 @@ def put_settings(payload: SettingsWrite) -> SettingsRead:
|
|||||||
def apply_service(target, patch):
|
def apply_service(target, patch):
|
||||||
if patch is None:
|
if patch is None:
|
||||||
return
|
return
|
||||||
|
changed = False
|
||||||
|
if patch.url is not None and str(patch.url).rstrip("/") != (target.url or ""):
|
||||||
|
changed = True
|
||||||
|
if patch.api_key and patch.api_key != target.api_key:
|
||||||
|
changed = True
|
||||||
|
if changed:
|
||||||
|
reset_test(target)
|
||||||
if patch.url is not None:
|
if patch.url is not None:
|
||||||
target.url = str(patch.url).rstrip("/")
|
target.url = str(patch.url).rstrip("/")
|
||||||
if patch.api_key:
|
if patch.api_key:
|
||||||
@@ -177,6 +208,11 @@ def put_settings(payload: SettingsWrite) -> SettingsRead:
|
|||||||
|
|
||||||
if payload.qbittorrent is not None:
|
if payload.qbittorrent is not None:
|
||||||
qb = payload.qbittorrent
|
qb = payload.qbittorrent
|
||||||
|
qb_changed = bool(qb.url) and str(qb.url).rstrip("/") != (cfg.qbittorrent.url or "")
|
||||||
|
qb_changed = qb_changed or bool(qb.username and qb.username != cfg.qbittorrent.username)
|
||||||
|
qb_changed = qb_changed or bool(qb.password)
|
||||||
|
if qb_changed:
|
||||||
|
reset_test(cfg.qbittorrent)
|
||||||
if qb.url is not None:
|
if qb.url is not None:
|
||||||
cfg.qbittorrent.url = str(qb.url).rstrip("/")
|
cfg.qbittorrent.url = str(qb.url).rstrip("/")
|
||||||
if qb.username:
|
if qb.username:
|
||||||
@@ -194,49 +230,123 @@ async def test_radarr() -> ConnectionResult:
|
|||||||
try:
|
try:
|
||||||
status = await client.system_status()
|
status = await client.system_status()
|
||||||
except (httpx.HTTPError, ValueError) as error:
|
except (httpx.HTTPError, ValueError) as error:
|
||||||
|
record_test("radarr", ok=False, error=str(error))
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=502, detail=f"Connexion Radarr impossible: {error}"
|
status_code=502, detail=f"Connexion Radarr impossible: {error}"
|
||||||
) from error
|
) from error
|
||||||
version = str(status.get("version", "inconnue"))
|
version = str(status.get("version", "inconnue"))
|
||||||
|
record_test("radarr", ok=True, version=version)
|
||||||
return ConnectionResult(success=True, version=version, message=f"Radarr {version} accessible")
|
return ConnectionResult(success=True, version=version, message=f"Radarr {version} accessible")
|
||||||
|
|
||||||
|
|
||||||
|
# --- Tests de connexion des autres services API (Sonarr, Prowlarr, Jellyfin,
|
||||||
|
# Overseerr). Chacun expose un endpoint systeme et une version. ---
|
||||||
|
API_SERVICE_TESTS: dict[str, tuple[str, str, str]] = {
|
||||||
|
# service: (endpoint, nom de l'en-tete d'authentification, cle de version)
|
||||||
|
"sonarr": ("api/v3/system/status", "X-Api-Key", "version"),
|
||||||
|
"prowlarr": ("api/v1/system/status", "X-Api-Key", "version"),
|
||||||
|
"jellyfin": ("System/Info", "X-Emby-Token", "Version"),
|
||||||
|
"seerr": ("api/v1/status", "X-Api-Key", "version"),
|
||||||
|
}
|
||||||
|
|
||||||
|
SERVICE_LABELS = {
|
||||||
|
"sonarr": "Sonarr",
|
||||||
|
"prowlarr": "Prowlarr",
|
||||||
|
"jellyfin": "Jellyfin",
|
||||||
|
"seerr": "Overseerr",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def _test_api_service(name: str) -> ConnectionResult:
|
||||||
|
service = getattr(read_config(), name)
|
||||||
|
label = SERVICE_LABELS[name]
|
||||||
|
url = build_base_url(service.url, service.port)
|
||||||
|
if not service_configured(service):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=409, detail=f"La connexion {label} n'est pas configurée"
|
||||||
|
)
|
||||||
|
endpoint, auth_header, version_key = API_SERVICE_TESTS[name]
|
||||||
|
try:
|
||||||
|
async with httpx.AsyncClient(timeout=30) as client:
|
||||||
|
response = await client.get(
|
||||||
|
f"{url}/{endpoint}", headers={auth_header: service.api_key}
|
||||||
|
)
|
||||||
|
response.raise_for_status()
|
||||||
|
data = response.json()
|
||||||
|
except (httpx.HTTPError, ValueError) as error:
|
||||||
|
record_test(name, ok=False, error=str(error))
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=502, detail=f"Connexion {label} impossible: {error}"
|
||||||
|
) from error
|
||||||
|
if not isinstance(data, dict):
|
||||||
|
error = "Réponse inattendue du service"
|
||||||
|
record_test(name, ok=False, error=error)
|
||||||
|
raise HTTPException(status_code=502, detail=f"Connexion {label} impossible: {error}")
|
||||||
|
version = str(data.get(version_key, "inconnue"))
|
||||||
|
record_test(name, ok=True, version=version)
|
||||||
|
return ConnectionResult(success=True, version=version, message=f"{label} {version} accessible")
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/api/settings/sonarr/test", response_model=ConnectionResult)
|
||||||
|
async def test_sonarr() -> ConnectionResult:
|
||||||
|
return await _test_api_service("sonarr")
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/api/settings/prowlarr/test", response_model=ConnectionResult)
|
||||||
|
async def test_prowlarr() -> ConnectionResult:
|
||||||
|
return await _test_api_service("prowlarr")
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/api/settings/jellyfin/test", response_model=ConnectionResult)
|
||||||
|
async def test_jellyfin() -> ConnectionResult:
|
||||||
|
return await _test_api_service("jellyfin")
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/api/settings/seerr/test", response_model=ConnectionResult)
|
||||||
|
async def test_seerr() -> ConnectionResult:
|
||||||
|
return await _test_api_service("seerr")
|
||||||
|
|
||||||
|
|
||||||
def qbittorrent_from_config() -> QbittorrentClient:
|
def qbittorrent_from_config() -> QbittorrentClient:
|
||||||
qb = read_config().qbittorrent
|
qb = read_config().qbittorrent
|
||||||
url = build_base_url(qb.url, qb.port)
|
url = build_base_url(qb.url, qb.port)
|
||||||
if not url or not qb.username or not qb.password:
|
if not url:
|
||||||
raise HTTPException(status_code=409, detail="La connexion qBittorrent n'est pas configurée")
|
raise HTTPException(status_code=409, detail="La connexion qBittorrent n'est pas configurée")
|
||||||
return QbittorrentClient(url, qb.username, qb.password)
|
return QbittorrentClient(url, qb.username, qb.password)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/api/settings/qbittorrent", response_model=QbittorrentSettingsRead)
|
@app.get("/api/settings/qbittorrent", response_model=QbittorrentSettingsRead)
|
||||||
def get_qbittorrent_settings() -> QbittorrentSettingsRead:
|
def get_qbittorrent_settings() -> QbittorrentSettingsRead:
|
||||||
qb = read_config().qbittorrent
|
return _qbittorrent_read(read_config().qbittorrent)
|
||||||
return QbittorrentSettingsRead(
|
|
||||||
url=qb.url,
|
|
||||||
port=qb.port,
|
|
||||||
username=qb.username,
|
|
||||||
password_configured=qb.password is not None,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@app.put("/api/settings/qbittorrent", response_model=QbittorrentSettingsRead)
|
@app.put("/api/settings/qbittorrent", response_model=QbittorrentSettingsRead)
|
||||||
def put_qbittorrent_settings(payload: QbittorrentSettingsWrite) -> QbittorrentSettingsRead:
|
def put_qbittorrent_settings(payload: QbittorrentSettingsWrite) -> QbittorrentSettingsRead:
|
||||||
cfg = read_config()
|
cfg = read_config()
|
||||||
if payload.url is not None:
|
qb = cfg.qbittorrent
|
||||||
cfg.qbittorrent.url = str(payload.url).strip().rstrip("/")
|
qb_changed = payload.url is not None and str(payload.url).strip().rstrip("/") != (
|
||||||
cfg.qbittorrent.port = payload.port
|
qb.url or ""
|
||||||
if payload.username:
|
|
||||||
cfg.qbittorrent.username = payload.username
|
|
||||||
if payload.password:
|
|
||||||
cfg.qbittorrent.password = payload.password
|
|
||||||
write_config(cfg)
|
|
||||||
return QbittorrentSettingsRead(
|
|
||||||
url=cfg.qbittorrent.url,
|
|
||||||
port=cfg.qbittorrent.port,
|
|
||||||
username=cfg.qbittorrent.username,
|
|
||||||
password_configured=cfg.qbittorrent.password is not None,
|
|
||||||
)
|
)
|
||||||
|
qb_changed = qb_changed or bool(payload.username and payload.username != qb.username)
|
||||||
|
qb_changed = qb_changed or bool(payload.password)
|
||||||
|
if qb_changed:
|
||||||
|
reset_test(qb)
|
||||||
|
if payload.url is not None:
|
||||||
|
qb.url = str(payload.url).strip().rstrip("/")
|
||||||
|
qb.port = payload.port
|
||||||
|
if payload.username:
|
||||||
|
qb.username = payload.username
|
||||||
|
if payload.password:
|
||||||
|
qb.password = payload.password
|
||||||
|
elif payload.password:
|
||||||
|
# Mot de passe seul: on conserve l'utilisateur existant.
|
||||||
|
qb.password = payload.password
|
||||||
|
else:
|
||||||
|
# Champs vides: mode bypass d'authentification qBittorrent, sans identifiants.
|
||||||
|
qb.username = None
|
||||||
|
qb.password = None
|
||||||
|
write_config(cfg)
|
||||||
|
return _qbittorrent_read(qb)
|
||||||
|
|
||||||
|
|
||||||
@app.post("/api/settings/qbittorrent/test", response_model=ConnectionResult)
|
@app.post("/api/settings/qbittorrent/test", response_model=ConnectionResult)
|
||||||
@@ -245,9 +355,11 @@ async def test_qbittorrent() -> ConnectionResult:
|
|||||||
try:
|
try:
|
||||||
version = await client.version()
|
version = await client.version()
|
||||||
except (httpx.HTTPError, ValueError) as error:
|
except (httpx.HTTPError, ValueError) as error:
|
||||||
|
record_test("qbittorrent", ok=False, error=str(error))
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=502, detail=f"Connexion qBittorrent impossible: {error}"
|
status_code=502, detail=f"Connexion qBittorrent impossible: {error}"
|
||||||
) from error
|
) from error
|
||||||
|
record_test("qbittorrent", ok=True, version=version)
|
||||||
return ConnectionResult(
|
return ConnectionResult(
|
||||||
success=True, version=version, message=f"qBittorrent {version} accessible"
|
success=True, version=version, message=f"qBittorrent {version} accessible"
|
||||||
)
|
)
|
||||||
@@ -271,6 +383,26 @@ def get_file(file_id: int, db: DbSession) -> IsoMovie:
|
|||||||
return item
|
return item
|
||||||
|
|
||||||
|
|
||||||
|
def _log_config_summary() -> None:
|
||||||
|
"""Rend visible au lancement le chargement de conf.json."""
|
||||||
|
cfg = read_config()
|
||||||
|
configured = [
|
||||||
|
name
|
||||||
|
for name in ("radarr", "sonarr", "prowlarr", "jellyfin", "seerr")
|
||||||
|
if getattr(cfg, name).url
|
||||||
|
]
|
||||||
|
if cfg.qbittorrent.url:
|
||||||
|
mode = "identifiants" if cfg.qbittorrent.username else "bypass d'authentification"
|
||||||
|
configured.append(f"qbittorrent ({mode})")
|
||||||
|
if configured:
|
||||||
|
print(f"conf.json charge: {', '.join(configured)}", flush=True)
|
||||||
|
else:
|
||||||
|
print(
|
||||||
|
"conf.json: aucune connexion configuree — a renseigner dans la page Configuration.",
|
||||||
|
flush=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _poster_url(movie: dict) -> str | None:
|
def _poster_url(movie: dict) -> str | None:
|
||||||
for image in movie.get("images") or []:
|
for image in movie.get("images") or []:
|
||||||
if image.get("coverType") == "poster":
|
if image.get("coverType") == "poster":
|
||||||
|
|||||||
+8
-1
@@ -6,13 +6,20 @@ import httpx
|
|||||||
|
|
||||||
|
|
||||||
class QbittorrentClient:
|
class QbittorrentClient:
|
||||||
def __init__(self, url: str, username: str, password: str) -> None:
|
"""Client WebUI (API v2). Identifiants optionnels: sans eux, aucun login
|
||||||
|
n'est effectue — qBittorrent doit alors autoriser la plage IP (bypass
|
||||||
|
d'authentification), car il n'existe pas d'API key cote qBittorrent."""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self, url: str, username: str | None = None, password: str | None = None
|
||||||
|
) -> None:
|
||||||
self._url = url.rstrip("/")
|
self._url = url.rstrip("/")
|
||||||
self._username = username
|
self._username = username
|
||||||
self._password = password
|
self._password = password
|
||||||
|
|
||||||
async def _request(self, method: str, endpoint: str, **kwargs) -> httpx.Response:
|
async def _request(self, method: str, endpoint: str, **kwargs) -> httpx.Response:
|
||||||
async with httpx.AsyncClient(timeout=30) as client:
|
async with httpx.AsyncClient(timeout=30) as client:
|
||||||
|
if self._username and self._password:
|
||||||
login = await client.post(
|
login = await client.post(
|
||||||
f"{self._url}/api/v2/auth/login",
|
f"{self._url}/api/v2/auth/login",
|
||||||
data={"username": self._username, "password": self._password},
|
data={"username": self._username, "password": self._password},
|
||||||
|
|||||||
+14
-1
@@ -7,6 +7,10 @@ class RadarrSettingsRead(BaseModel):
|
|||||||
url: str | None
|
url: str | None
|
||||||
port: int | None = None
|
port: int | None = None
|
||||||
api_key_configured: bool
|
api_key_configured: bool
|
||||||
|
status: str
|
||||||
|
tested_version: str | None = None
|
||||||
|
tested_at: str | None = None
|
||||||
|
test_error: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class RadarrSettingsWrite(BaseModel):
|
class RadarrSettingsWrite(BaseModel):
|
||||||
@@ -19,6 +23,10 @@ class ApiServiceSettingsRead(BaseModel):
|
|||||||
url: str | None
|
url: str | None
|
||||||
port: int | None = None
|
port: int | None = None
|
||||||
api_key_configured: bool
|
api_key_configured: bool
|
||||||
|
status: str
|
||||||
|
tested_version: str | None = None
|
||||||
|
tested_at: str | None = None
|
||||||
|
test_error: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class ApiServiceSettingsWrite(BaseModel):
|
class ApiServiceSettingsWrite(BaseModel):
|
||||||
@@ -32,12 +40,17 @@ class QbittorrentSettingsRead(BaseModel):
|
|||||||
port: int | None = None
|
port: int | None = None
|
||||||
username: str | None
|
username: str | None
|
||||||
password_configured: bool
|
password_configured: bool
|
||||||
|
status: str
|
||||||
|
tested_version: str | None = None
|
||||||
|
tested_at: str | None = None
|
||||||
|
test_error: str | None = None
|
||||||
|
|
||||||
|
|
||||||
class QbittorrentSettingsWrite(BaseModel):
|
class QbittorrentSettingsWrite(BaseModel):
|
||||||
url: str | None = None
|
url: str | None = None
|
||||||
port: int | None = Field(default=None, ge=1, le=65535)
|
port: int | None = Field(default=None, ge=1, le=65535)
|
||||||
username: str | None = Field(default=None, min_length=1)
|
# Utilisateur vide = bypass d'authentification qBittorrent.
|
||||||
|
username: str | None = None
|
||||||
password: str | None = Field(default=None, min_length=1)
|
password: str | None = Field(default=None, min_length=1)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,11 @@ import respx
|
|||||||
from fastapi.testclient import TestClient
|
from fastapi.testclient import TestClient
|
||||||
from httpx import Response
|
from httpx import Response
|
||||||
|
|
||||||
|
from app import auth as auth_module
|
||||||
from app.conf_store import config_path
|
from app.conf_store import config_path
|
||||||
|
from app.database import SessionLocal
|
||||||
from app.main import app
|
from app.main import app
|
||||||
|
from app.models import User
|
||||||
|
|
||||||
|
|
||||||
def configure_radarr(client: TestClient) -> None:
|
def configure_radarr(client: TestClient) -> None:
|
||||||
@@ -35,6 +38,109 @@ def test_radarr_connection() -> None:
|
|||||||
assert response.json()["version"] == "5.27.0"
|
assert response.json()["version"] == "5.27.0"
|
||||||
|
|
||||||
|
|
||||||
|
@respx.mock
|
||||||
|
def test_service_status_lifecycle() -> None:
|
||||||
|
"""Statut par service: configured -> tested apres un test reussi, puis
|
||||||
|
retour a configured quand la configuration change.
|
||||||
|
|
||||||
|
Utilise une URL distincte des autres tests: conf.json etant partage entre
|
||||||
|
les tests, il faut garantir un reset du statut herite.
|
||||||
|
"""
|
||||||
|
respx.get("http://radarr-lifecycle:7878/api/v3/system/status").mock(
|
||||||
|
return_value=Response(200, json={"version": "5.27.0"})
|
||||||
|
)
|
||||||
|
with TestClient(app) as client:
|
||||||
|
response = client.put(
|
||||||
|
"/api/settings/radarr",
|
||||||
|
json={"url": "http://radarr-lifecycle:7878", "api_key": "test-key"},
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
# Configure mais pas encore teste.
|
||||||
|
settings = client.get("/api/settings").json()
|
||||||
|
assert settings["radarr"]["status"] == "configured"
|
||||||
|
assert settings["qbittorrent"]["status"] in {"configured", "unconfigured"}
|
||||||
|
|
||||||
|
client.post("/api/settings/radarr/test")
|
||||||
|
settings = client.get("/api/settings").json()
|
||||||
|
assert settings["radarr"]["status"] == "tested"
|
||||||
|
assert settings["radarr"]["tested_version"] == "5.27.0"
|
||||||
|
assert settings["radarr"]["tested_at"] is not None
|
||||||
|
|
||||||
|
# Le resultat du test est persiste dans conf.json.
|
||||||
|
raw = json.loads(config_path().read_text(encoding="utf-8"))
|
||||||
|
assert raw["radarr"]["test"]["ok"] is True
|
||||||
|
assert raw["radarr"]["test"]["version"] == "5.27.0"
|
||||||
|
|
||||||
|
# Modifier l'URL invalide le statut de test.
|
||||||
|
client.put(
|
||||||
|
"/api/settings/radarr",
|
||||||
|
json={"url": "http://radarr-alt:7878", "api_key": None},
|
||||||
|
)
|
||||||
|
settings = client.get("/api/settings").json()
|
||||||
|
assert settings["radarr"]["status"] == "configured"
|
||||||
|
|
||||||
|
|
||||||
|
@respx.mock
|
||||||
|
def test_failed_test_marks_service_as_error() -> None:
|
||||||
|
respx.get("http://radarr-fail:7878/api/v3/system/status").mock(
|
||||||
|
return_value=Response(500, text="boom")
|
||||||
|
)
|
||||||
|
with TestClient(app) as client:
|
||||||
|
client.put(
|
||||||
|
"/api/settings/radarr",
|
||||||
|
json={"url": "http://radarr-fail:7878", "api_key": "test-key"},
|
||||||
|
)
|
||||||
|
response = client.post("/api/settings/radarr/test")
|
||||||
|
assert response.status_code == 502
|
||||||
|
settings = client.get("/api/settings").json()
|
||||||
|
assert settings["radarr"]["status"] == "error"
|
||||||
|
assert settings["radarr"]["test_error"] is not None
|
||||||
|
|
||||||
|
|
||||||
|
@respx.mock
|
||||||
|
def test_sonarr_connection() -> None:
|
||||||
|
"""Les services optionnels ont aussi un endpoint de test."""
|
||||||
|
route = respx.get("http://sonarr:8989/api/v3/system/status").mock(
|
||||||
|
return_value=Response(200, json={"version": "4.0.12"})
|
||||||
|
)
|
||||||
|
with TestClient(app) as client:
|
||||||
|
client.put(
|
||||||
|
"/api/settings",
|
||||||
|
json={"sonarr": {"url": "http://sonarr:8989", "api_key": "sonarr-key"}},
|
||||||
|
)
|
||||||
|
response = client.post("/api/settings/sonarr/test")
|
||||||
|
settings = client.get("/api/settings").json()
|
||||||
|
assert response.status_code == 200
|
||||||
|
assert response.json()["version"] == "4.0.12"
|
||||||
|
assert settings["sonarr"]["status"] == "tested"
|
||||||
|
assert route.called
|
||||||
|
assert "sonarr-key" in route.calls.last.request.headers["x-api-key"]
|
||||||
|
|
||||||
|
|
||||||
|
@respx.mock
|
||||||
|
def test_qbittorrent_status_lifecycle() -> None:
|
||||||
|
respx.get("http://qbit-lifecycle:8080/api/v2/app/version").mock(
|
||||||
|
return_value=Response(200, text="v5.0.2")
|
||||||
|
)
|
||||||
|
with TestClient(app) as client:
|
||||||
|
client.put(
|
||||||
|
"/api/settings/qbittorrent",
|
||||||
|
json={"url": "http://qbit-lifecycle:8080", "port": 8080},
|
||||||
|
)
|
||||||
|
assert client.post("/api/settings/qbittorrent/test").status_code == 200
|
||||||
|
settings = client.get("/api/settings").json()
|
||||||
|
assert settings["qbittorrent"]["status"] == "tested"
|
||||||
|
assert settings["qbittorrent"]["tested_version"] == "v5.0.2"
|
||||||
|
|
||||||
|
# Un nouvel enregistrement (URL differente) reinitialise le statut de test.
|
||||||
|
client.put(
|
||||||
|
"/api/settings/qbittorrent",
|
||||||
|
json={"url": "http://qbit-alt:8080", "port": 8080},
|
||||||
|
)
|
||||||
|
settings = client.get("/api/settings").json()
|
||||||
|
assert settings["qbittorrent"]["status"] == "configured"
|
||||||
|
|
||||||
|
|
||||||
@respx.mock
|
@respx.mock
|
||||||
def test_scan_only_imports_iso_files() -> None:
|
def test_scan_only_imports_iso_files() -> None:
|
||||||
respx.get("http://radarr:7878/api/v3/movie?includeMovieFile=true").mock(
|
respx.get("http://radarr:7878/api/v3/movie?includeMovieFile=true").mock(
|
||||||
@@ -102,6 +208,28 @@ def test_qbittorrent_connection_local_address_with_port() -> None:
|
|||||||
assert test.json()["version"] == "v5.0.2"
|
assert test.json()["version"] == "v5.0.2"
|
||||||
|
|
||||||
|
|
||||||
|
@respx.mock
|
||||||
|
def test_qbittorrent_connection_without_credentials() -> None:
|
||||||
|
"""Sans identifiants (bypass d'authentification qBittorrent): aucun login,
|
||||||
|
l'API est appelee directement."""
|
||||||
|
respx.post("http://192.168.1.50:8555/api/v2/auth/login").mock(
|
||||||
|
return_value=Response(404)
|
||||||
|
)
|
||||||
|
respx.get("http://192.168.1.50:8555/api/v2/app/version").mock(
|
||||||
|
return_value=Response(200, text="v5.0.2")
|
||||||
|
)
|
||||||
|
with TestClient(app) as client:
|
||||||
|
put = client.put(
|
||||||
|
"/api/settings/qbittorrent",
|
||||||
|
json={"url": "192.168.1.50", "port": 8555, "username": "", "password": None},
|
||||||
|
)
|
||||||
|
assert put.status_code == 200
|
||||||
|
assert put.json()["password_configured"] is False
|
||||||
|
test = client.post("/api/settings/qbittorrent/test")
|
||||||
|
assert test.status_code == 200
|
||||||
|
assert test.json()["version"] == "v5.0.2"
|
||||||
|
|
||||||
|
|
||||||
def test_settings_persist_to_conf_json() -> None:
|
def test_settings_persist_to_conf_json() -> None:
|
||||||
with TestClient(app) as client:
|
with TestClient(app) as client:
|
||||||
put = client.put(
|
put = client.put(
|
||||||
@@ -123,3 +251,54 @@ def test_settings_persist_to_conf_json() -> None:
|
|||||||
assert raw["qbittorrent"]["port"] == 8080
|
assert raw["qbittorrent"]["port"] == 8080
|
||||||
assert raw["qbittorrent"]["username"] == "admin"
|
assert raw["qbittorrent"]["username"] == "admin"
|
||||||
assert raw["qbittorrent"]["password"] == "pass"
|
assert raw["qbittorrent"]["password"] == "pass"
|
||||||
|
|
||||||
|
|
||||||
|
def test_setup_link_only_without_existing_account() -> None:
|
||||||
|
"""Le lien de premier lancement ne doit pas apparaitre si un compte existe.
|
||||||
|
|
||||||
|
Verifie aussi que l'endpoint de setup refuse tout second compte, meme avec
|
||||||
|
un jeton valide.
|
||||||
|
"""
|
||||||
|
with TestClient(app) as client:
|
||||||
|
client.post("/api/auth/setup", json={"token": "invalide", "username": "x", "password": "y"})
|
||||||
|
# Nettoyage: la base de test est partagee entre les tests.
|
||||||
|
with SessionLocal() as db:
|
||||||
|
db.query(User).delete()
|
||||||
|
db.commit()
|
||||||
|
# Simule un redemarrage: le lifespan relance bootstrap_setup.
|
||||||
|
with TestClient(app):
|
||||||
|
assert auth_module.setup_token is not None
|
||||||
|
with TestClient(app) as client:
|
||||||
|
response = client.post(
|
||||||
|
"/api/auth/setup",
|
||||||
|
json={
|
||||||
|
"token": auth_module.setup_token,
|
||||||
|
"username": "admin",
|
||||||
|
"password": "pass",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
# Le jeton est consomme apres creation du compte.
|
||||||
|
assert auth_module.setup_token is None
|
||||||
|
# Nouveau demarrage: un compte existe -> plus aucun jeton genere,
|
||||||
|
# et la creation d'un second compte est refusee.
|
||||||
|
with TestClient(app) as client:
|
||||||
|
assert auth_module.setup_token is None
|
||||||
|
response = client.post(
|
||||||
|
"/api/auth/setup",
|
||||||
|
json={"token": "peu-importe", "username": "autre", "password": "z"},
|
||||||
|
)
|
||||||
|
assert response.status_code == 403
|
||||||
|
|
||||||
|
|
||||||
|
def test_startup_logs_conf_json_summary(capsys) -> None:
|
||||||
|
"""Au lancement, le log indique si conf.json est charge et ce qu'il contient."""
|
||||||
|
with TestClient(app) as client:
|
||||||
|
client.put(
|
||||||
|
"/api/settings/qbittorrent",
|
||||||
|
json={"url": "192.168.1.50", "port": 8555},
|
||||||
|
)
|
||||||
|
with TestClient(app):
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
assert "conf.json charge" in captured.out
|
||||||
|
assert "qbittorrent (bypass d'authentification)" in captured.out
|
||||||
+8
-6
@@ -987,21 +987,23 @@ export default function App() {
|
|||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
Utilisateur
|
Utilisateur (optionnel)
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
required
|
placeholder="admin — vide = bypass qBittorrent"
|
||||||
placeholder="admin"
|
|
||||||
value={qbitUsername}
|
value={qbitUsername}
|
||||||
onChange={(event) => setQbitUsername(event.target.value)}
|
onChange={(event) => setQbitUsername(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
Mot de passe
|
Mot de passe (optionnel)
|
||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
required={!qbitConfigured}
|
placeholder={
|
||||||
placeholder={qbitConfigured ? "Configuré — laisser vide pour conserver" : "Mot de passe WebUI"}
|
qbitConfigured
|
||||||
|
? "Configuré — laisser vide pour conserver, tout vider = bypass"
|
||||||
|
: "Vide = bypass d'authentification qBittorrent"
|
||||||
|
}
|
||||||
value={qbitPassword}
|
value={qbitPassword}
|
||||||
onChange={(event) => setQbitPassword(event.target.value)}
|
onChange={(event) => setQbitPassword(event.target.value)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import type {ServiceStatus} from "../types";
|
||||||
|
|
||||||
|
type Props = ServiceStatus;
|
||||||
|
|
||||||
|
export default function ServiceStatusBadge({status, tested_version: version, test_error: error}: Props) {
|
||||||
|
if (status === "tested") {
|
||||||
|
return (
|
||||||
|
<span className="status linked" title={error ?? undefined}>
|
||||||
|
Testé{version ? ` · ${version}` : ""}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (status === "error") {
|
||||||
|
return (
|
||||||
|
<span className="status error" title={error ?? undefined}>
|
||||||
|
Test échoué
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (status === "configured") {
|
||||||
|
return <span className="status warn">Configuré · non testé</span>;
|
||||||
|
}
|
||||||
|
return <span className="status">Non configuré</span>;
|
||||||
|
}
|
||||||
+51
-11
@@ -3,6 +3,7 @@ import type React from "react";
|
|||||||
|
|
||||||
import {api, jsonHeaders} from "../lib/api";
|
import {api, jsonHeaders} from "../lib/api";
|
||||||
import type {SettingsRead} from "../types";
|
import type {SettingsRead} from "../types";
|
||||||
|
import ServiceStatusBadge from "../components/ServiceStatusBadge";
|
||||||
|
|
||||||
export default function Settings() {
|
export default function Settings() {
|
||||||
const [radarrUrl, setRadarrUrl] = useState("");
|
const [radarrUrl, setRadarrUrl] = useState("");
|
||||||
@@ -32,6 +33,7 @@ export default function Settings() {
|
|||||||
|
|
||||||
const [message, setMessage] = useState("");
|
const [message, setMessage] = useState("");
|
||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
|
const [settings, setSettings] = useState<SettingsRead | null>(null);
|
||||||
|
|
||||||
const serviceHelp = useMemo(() => "L’URL doit être accessible depuis le conteneur MKVTool.", []);
|
const serviceHelp = useMemo(() => "L’URL doit être accessible depuis le conteneur MKVTool.", []);
|
||||||
|
|
||||||
@@ -56,14 +58,27 @@ export default function Settings() {
|
|||||||
setQbitPasswordConfigured(settings.qbittorrent.password_configured);
|
setQbitPasswordConfigured(settings.qbittorrent.password_configured);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const refreshSettings = useCallback(async () => {
|
const refreshSettings = useCallback(async (): Promise<SettingsRead> => {
|
||||||
hydrateSettings(await api<SettingsRead>("/api/settings"));
|
const fresh = await api<SettingsRead>("/api/settings");
|
||||||
|
hydrateSettings(fresh);
|
||||||
|
setSettings(fresh);
|
||||||
|
return fresh;
|
||||||
}, [hydrateSettings]);
|
}, [hydrateSettings]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refreshSettings().catch((error: Error) => setMessage(error.message));
|
refreshSettings().catch((error: Error) => setMessage(error.message));
|
||||||
}, [refreshSettings]);
|
}, [refreshSettings]);
|
||||||
|
|
||||||
|
async function testService(name: "radarr" | "sonarr" | "prowlarr" | "jellyfin" | "seerr" | "qbittorrent"): Promise<void> {
|
||||||
|
try {
|
||||||
|
const result = await api<{ message: string }>(`/api/settings/${name}/test`, {method: "POST"});
|
||||||
|
setMessage(result.message);
|
||||||
|
} catch (error) {
|
||||||
|
setMessage((error as Error).message);
|
||||||
|
}
|
||||||
|
await refreshSettings().catch(() => undefined);
|
||||||
|
}
|
||||||
|
|
||||||
async function saveRadarr(event: React.FormEvent<HTMLFormElement>) {
|
async function saveRadarr(event: React.FormEvent<HTMLFormElement>) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
@@ -81,8 +96,7 @@ export default function Settings() {
|
|||||||
});
|
});
|
||||||
setRadarrApiKey("");
|
setRadarrApiKey("");
|
||||||
await refreshSettings();
|
await refreshSettings();
|
||||||
const result = await api<{ message: string }>("/api/settings/radarr/test", {method: "POST"});
|
await testService("radarr");
|
||||||
setMessage(result.message);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setMessage((error as Error).message);
|
setMessage((error as Error).message);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -117,8 +131,12 @@ export default function Settings() {
|
|||||||
if (name === "jellyfin") setJellyfinApiKey("");
|
if (name === "jellyfin") setJellyfinApiKey("");
|
||||||
if (name === "seerr") setSeerrApiKey("");
|
if (name === "seerr") setSeerrApiKey("");
|
||||||
|
|
||||||
await refreshSettings();
|
const fresh = await refreshSettings();
|
||||||
|
if (fresh[name].status === "unconfigured") {
|
||||||
setMessage("Configuration enregistrée");
|
setMessage("Configuration enregistrée");
|
||||||
|
} else {
|
||||||
|
await testService(name);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setMessage((error as Error).message);
|
setMessage((error as Error).message);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -144,8 +162,12 @@ export default function Settings() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setQbitPassword("");
|
setQbitPassword("");
|
||||||
await refreshSettings();
|
const fresh = await refreshSettings();
|
||||||
|
if (fresh.qbittorrent.status === "unconfigured") {
|
||||||
setMessage("Configuration enregistrée");
|
setMessage("Configuration enregistrée");
|
||||||
|
} else {
|
||||||
|
await testService("qbittorrent");
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setMessage((error as Error).message);
|
setMessage((error as Error).message);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -168,7 +190,10 @@ export default function Settings() {
|
|||||||
|
|
||||||
<section className="card grid-2">
|
<section className="card grid-2">
|
||||||
<div>
|
<div>
|
||||||
|
<div className="service-head">
|
||||||
<h3>Radarr</h3>
|
<h3>Radarr</h3>
|
||||||
|
{settings && <ServiceStatusBadge {...settings.radarr}/>}
|
||||||
|
</div>
|
||||||
<p className="muted">Obligatoire pour le scan et la détection des films.</p>
|
<p className="muted">Obligatoire pour le scan et la détection des films.</p>
|
||||||
</div>
|
</div>
|
||||||
<form onSubmit={saveRadarr} className="form-2">
|
<form onSubmit={saveRadarr} className="form-2">
|
||||||
@@ -198,7 +223,10 @@ export default function Settings() {
|
|||||||
|
|
||||||
<section className="card grid-2">
|
<section className="card grid-2">
|
||||||
<div>
|
<div>
|
||||||
|
<div className="service-head">
|
||||||
<h3>Sonarr</h3>
|
<h3>Sonarr</h3>
|
||||||
|
{settings && <ServiceStatusBadge {...settings.sonarr}/>}
|
||||||
|
</div>
|
||||||
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
||||||
</div>
|
</div>
|
||||||
<form onSubmit={(e) => saveApiService("sonarr", e)} className="form-2">
|
<form onSubmit={(e) => saveApiService("sonarr", e)} className="form-2">
|
||||||
@@ -220,13 +248,16 @@ export default function Settings() {
|
|||||||
onChange={(event) => setSonarrApiKey(event.target.value)}
|
onChange={(event) => setSonarrApiKey(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<button disabled={busy}>Enregistrer</button>
|
<button disabled={busy}>Enregistrer et tester</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="card grid-2">
|
<section className="card grid-2">
|
||||||
<div>
|
<div>
|
||||||
|
<div className="service-head">
|
||||||
<h3>Prowlarr</h3>
|
<h3>Prowlarr</h3>
|
||||||
|
{settings && <ServiceStatusBadge {...settings.prowlarr}/>}
|
||||||
|
</div>
|
||||||
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
||||||
</div>
|
</div>
|
||||||
<form onSubmit={(e) => saveApiService("prowlarr", e)} className="form-2">
|
<form onSubmit={(e) => saveApiService("prowlarr", e)} className="form-2">
|
||||||
@@ -248,13 +279,16 @@ export default function Settings() {
|
|||||||
onChange={(event) => setProwlarrApiKey(event.target.value)}
|
onChange={(event) => setProwlarrApiKey(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<button disabled={busy}>Enregistrer</button>
|
<button disabled={busy}>Enregistrer et tester</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="card grid-2">
|
<section className="card grid-2">
|
||||||
<div>
|
<div>
|
||||||
|
<div className="service-head">
|
||||||
<h3>Jellyfin</h3>
|
<h3>Jellyfin</h3>
|
||||||
|
{settings && <ServiceStatusBadge {...settings.jellyfin}/>}
|
||||||
|
</div>
|
||||||
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
||||||
</div>
|
</div>
|
||||||
<form onSubmit={(e) => saveApiService("jellyfin", e)} className="form-2">
|
<form onSubmit={(e) => saveApiService("jellyfin", e)} className="form-2">
|
||||||
@@ -276,13 +310,16 @@ export default function Settings() {
|
|||||||
onChange={(event) => setJellyfinApiKey(event.target.value)}
|
onChange={(event) => setJellyfinApiKey(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<button disabled={busy}>Enregistrer</button>
|
<button disabled={busy}>Enregistrer et tester</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="card grid-2">
|
<section className="card grid-2">
|
||||||
<div>
|
<div>
|
||||||
|
<div className="service-head">
|
||||||
<h3>Overseerr</h3>
|
<h3>Overseerr</h3>
|
||||||
|
{settings && <ServiceStatusBadge {...settings.seerr}/>}
|
||||||
|
</div>
|
||||||
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
<p className="muted">Optionnel (hors périmètre MVP), mais stocké dans conf.json.</p>
|
||||||
</div>
|
</div>
|
||||||
<form onSubmit={(e) => saveApiService("seerr", e)} className="form-2">
|
<form onSubmit={(e) => saveApiService("seerr", e)} className="form-2">
|
||||||
@@ -304,13 +341,16 @@ export default function Settings() {
|
|||||||
onChange={(event) => setSeerrApiKey(event.target.value)}
|
onChange={(event) => setSeerrApiKey(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<button disabled={busy}>Enregistrer</button>
|
<button disabled={busy}>Enregistrer et tester</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className="card grid-2">
|
<section className="card grid-2">
|
||||||
<div>
|
<div>
|
||||||
|
<div className="service-head">
|
||||||
<h3>qBittorrent</h3>
|
<h3>qBittorrent</h3>
|
||||||
|
{settings && <ServiceStatusBadge {...settings.qbittorrent}/>}
|
||||||
|
</div>
|
||||||
<p className="muted">Optionnel: nécessaire pour supprimer torrent + données après import validé.</p>
|
<p className="muted">Optionnel: nécessaire pour supprimer torrent + données après import validé.</p>
|
||||||
</div>
|
</div>
|
||||||
<form onSubmit={saveQbittorrent} className="form-3">
|
<form onSubmit={saveQbittorrent} className="form-3">
|
||||||
@@ -341,7 +381,7 @@ export default function Settings() {
|
|||||||
onChange={(event) => setQbitPassword(event.target.value)}
|
onChange={(event) => setQbitPassword(event.target.value)}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
<button disabled={busy}>Enregistrer</button>
|
<button disabled={busy}>Enregistrer et tester</button>
|
||||||
</form>
|
</form>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,7 @@ h1 {
|
|||||||
background: var(--surface);
|
background: var(--surface);
|
||||||
}
|
}
|
||||||
.settings { display: grid; grid-template-columns: 1fr 2fr; gap: 2.5rem; }
|
.settings { display: grid; grid-template-columns: 1fr 2fr; gap: 2.5rem; }
|
||||||
|
.service-head { display: flex; align-items: center; gap: 0.75rem; }
|
||||||
.panel-head h2 { font-size: 1.15rem; font-weight: 650; margin-bottom: 0.4rem; }
|
.panel-head h2 { font-size: 1.15rem; font-weight: 650; margin-bottom: 0.4rem; }
|
||||||
.settings p, article p { color: var(--text-muted); }
|
.settings p, article p { color: var(--text-muted); }
|
||||||
form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 0.75rem; }
|
form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 0.75rem; }
|
||||||
@@ -201,6 +202,10 @@ code { color: var(--text-muted); font-size: 0.8rem; overflow-wrap: anywhere; }
|
|||||||
color: #4ade80;
|
color: #4ade80;
|
||||||
border-color: rgba(74, 222, 128, 0.4);
|
border-color: rgba(74, 222, 128, 0.4);
|
||||||
}
|
}
|
||||||
|
.status.warn {
|
||||||
|
color: #fbbf24;
|
||||||
|
border-color: rgba(251, 191, 36, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
.row-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
|
.row-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
|
||||||
button.small { padding: 0.45rem 0.9rem; font-size: 0.85rem; border-radius: 8px; }
|
button.small { padding: 0.45rem 0.9rem; font-size: 0.85rem; border-radius: 8px; }
|
||||||
|
|||||||
+9
-2
@@ -10,8 +10,15 @@ export type Movie = {
|
|||||||
processed_at?: string | null;
|
processed_at?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ApiServiceSettingsRead = { url: string | null; api_key_configured: boolean };
|
export type ServiceStatus = {
|
||||||
export type QbittorrentSettingsRead = {
|
status: "unconfigured" | "configured" | "tested" | "error";
|
||||||
|
tested_version?: string | null;
|
||||||
|
tested_at?: string | null;
|
||||||
|
test_error?: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ApiServiceSettingsRead = ServiceStatus & { url: string | null; api_key_configured: boolean };
|
||||||
|
export type QbittorrentSettingsRead = ServiceStatus & {
|
||||||
url: string | null;
|
url: string | null;
|
||||||
username: string | null;
|
username: string | null;
|
||||||
password_configured: boolean;
|
password_configured: boolean;
|
||||||
|
|||||||
Reference in new issue
Block a user