Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87fd6b39fd | ||
|
|
acc1609b4d |
No files matched your search
+5
-1
@@ -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 \
|
||||
|
||||
@@ -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 `<montage de /config>/.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 |
|
||||
|
||||
@@ -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 <clé>` "
|
||||
"(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:
|
||||
|
||||
@@ -25,6 +25,19 @@ if os.geteuid() == 0 and puid:
|
||||
subprocess.run(
|
||||
["chown", "-R", f"{puid}:{pgid or puid}", config_dir], check=False
|
||||
)
|
||||
# Entree passwd pour PUID: certains binaires (MakeMKV) resolvent le
|
||||
# repertoire utilisateur via getpwuid et non via $HOME. Sans entree,
|
||||
# makemkvcon ne trouve pas sa configuration (/config/.MakeMKV).
|
||||
try:
|
||||
with open("/etc/passwd", encoding="utf-8") as handle:
|
||||
known_uids = {line.split(":")[2] for line in handle if ":" in line}
|
||||
if str(puid) not in known_uids:
|
||||
with open("/etc/passwd", "a", encoding="utf-8") as handle:
|
||||
handle.write(
|
||||
f"mkvtool:x:{puid}:{pgid or puid}::{config_dir}:/usr/sbin/nologin\n"
|
||||
)
|
||||
except OSError:
|
||||
pass
|
||||
os.setgroups([pgid] if pgid else [])
|
||||
if pgid:
|
||||
os.setgid(pgid)
|
||||
|
||||
@@ -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")
|
||||
Reference in new issue
Block a user