From acc1609b4d462a49ec4ac9b8aac91bc214ee9570 Mon Sep 17 00:00:00 2001 From: Orionis312050 Date: Mon, 12 Oct 2026 23:27:32 +0000 Subject: [PATCH] :wrench: MakeMKV: HOME=/config pour la cle d'activation persistante + erreur d'activation explicite --- Dockerfile | 6 +++++- IMAGE.md | 31 +++++++++++++++++++++++++++++++ app/converter.py | 8 ++++++++ tests/test_conversion.py | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8bbeb2a..0964e5a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -56,7 +56,11 @@ COPY app/ app/ COPY --from=web /web/dist /app/web/dist COPY docker/entrypoint.py /entrypoint.py -ENV MKVTOOL_CONFIG_DIR=/config \ +# HOME pointe vers /config pour que MakeMKV y lise et y ecrite sa +# configuration (settings.conf, cle d'activation) : le processus tourne sous +# PUID/PGID et ne peut pas acceder a /root, et /config est le volume persistant. +ENV HOME=/config \ + MKVTOOL_CONFIG_DIR=/config \ MKVTOOL_WEB_DIR=/app/web/dist \ MKVTOOL_FILMS_DIR=/films \ MKVTOOL_RADARR_FILMS_DIR=/nas_storage/jellyfin/films \ diff --git a/IMAGE.md b/IMAGE.md index 6c2fd2b..915d3bf 100644 --- a/IMAGE.md +++ b/IMAGE.md @@ -29,6 +29,37 @@ MakeMKV (`makemkvcon`) est compile dans l'image a partir de la version definie par l'argument de build `MAKEMKV_VERSION` (par defaut `2.0.0`). Le build local reste possible : `docker build -t mkvtool .`. +## Activation de MakeMKV + +MakeMKV est shareware : sans clé d'activation, `makemkvcon` ne peut pas +convertir en mode non interactif (il demande le lancement de la période +d'évaluation, puis s'arrête). Deux options : + +- **Clé bêta gratuite**, publiée par l'éditeur sur le forum officiel + (https://forum.makemkv.com/forum/viewtopic.php?t=1053) et renouvelée tous + les un à deux mois tant que MakeMKV reste en bêta. C'est la voie gratuite + usuelle. +- **Clé permanente** achetée (~60 USD, achat à vie) — l'achat est + ponctuellement indisponible côté éditeur, la clé bêta fait alors foi. + +L'image positionne `HOME=/config` : MakeMKV lit et écrit sa configuration +dans `/config/.MakeMKV/settings.conf`, donc sur le volume persistant. Pour +activer : + +```bash +docker exec mkvtool makemkvcon reg T-VOTRE-CLE +``` + +Ou en créant le fichier `/.MakeMKV/settings.conf` sur +l'hôte : + +``` +app_MakeMKV_key = "T-VOTRE-CLE" +``` + +Si une conversion échoue avec le message d'activation, la clé a expiré : +reprenez la clé courante sur le forum et relancez la commande ci-dessus. + ## Variables d'environnement | Variable | Defaut image | Role | diff --git a/app/converter.py b/app/converter.py index 4dd4c84..f0fb381 100644 --- a/app/converter.py +++ b/app/converter.py @@ -94,6 +94,14 @@ def extract_mkv(movie: IsoMovie, mkv_path: Path) -> None: ) if result.returncode != 0: detail = result.stderr.strip() or result.stdout.strip() + if "purchase an activation key" in detail or "evaluation period" in detail: + raise RuntimeError( + "MakeMKV n'est pas activé: une clé est requise pour la conversion. " + "Utilisez la clé bêta gratuite du forum officiel MakeMKV ou une clé " + "achetée, puis `docker exec mkvtool makemkvcon reg ` " + "(ou renseignez app_MakeMKV_key dans /config/.MakeMKV/settings.conf). " + "Voir IMAGE.md." + ) raise RuntimeError(f"MakeMKV a echoue: {detail}") produced = sorted(mkv_path.parent.glob("*.mkv")) if not produced: diff --git a/tests/test_conversion.py b/tests/test_conversion.py index 7606534..f064b32 100644 --- a/tests/test_conversion.py +++ b/tests/test_conversion.py @@ -7,6 +7,7 @@ from fastapi.testclient import TestClient from httpx import Response from app.config import settings +from app.converter import extract_mkv from app.database import SessionLocal from app.main import app from app.models import IsoMovie @@ -161,3 +162,36 @@ def test_scan_marks_missing_radarr_files_as_unlinked() -> None: movie = client.get("/api/movies").json()[0] assert movie["radarr_linked"] is False assert movie["status"] == "detected" + + +def test_extract_fails_with_activation_error_when_makemkv_unactivated( + monkeypatch, tmp_path +) -> None: + """Sans cle MakeMKV (message shareware), l'erreur guide vers l'activation.""" + from types import SimpleNamespace + + monkeypatch.setattr(settings, "simulate_conversion", False) + monkeypatch.setattr("app.converter.shutil.which", lambda _: "/usr/bin/makemkvcon") + monkeypatch.setattr( + "app.converter.subprocess.run", + lambda *args, **kwargs: SimpleNamespace( + returncode=10, + stdout=( + "This functionality is shareware. You may evaluate it for 30 days " + "after what you would need to purchase an activation key.\n" + "Do you want to start evaluation period now?\n" + "Evaluation version, 30 day(s) out of 30 remaining" + ), + stderr="", + ), + ) + movie = IsoMovie( + radarr_movie_id=1, radarr_movie_file_id=2, title="ISO Movie", path="/x.iso" + ) + try: + extract_mkv(movie, tmp_path / "out" / "movie.mkv") + except RuntimeError as error: + assert "MakeMKV n'est pas activé" in str(error) + assert "makemkvcon reg" in str(error) + else: + raise AssertionError("RuntimeError attendue")