Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
39319b7caa | ||
|
|
10830f3562 | ||
|
|
87fd6b39fd | ||
|
|
acc1609b4d |
No files matched your search
+14
-4
@@ -1,6 +1,6 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
|
|
||||||
ARG MAKEMKV_VERSION=2.0.0
|
ARG MAKEMKV_VERSION=1.18.4
|
||||||
|
|
||||||
# --- Interface web ---
|
# --- Interface web ---
|
||||||
FROM node:22-slim AS web
|
FROM node:22-slim AS web
|
||||||
@@ -31,9 +31,15 @@ RUN apt-get update \
|
|||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# MakeMKV (makemkvcon) — version explicite, licence a fournir via makemkv.
|
# MakeMKV (makemkvcon) — version explicite, licence a fournir via makemkv.
|
||||||
|
# 1.18.4 et non 2.0.0: la 2.0.0 a une regression qui fait planter makemkvcon
|
||||||
|
# sur les ISO Blu-ray sans dossier AACS (non chiffrees / pre-dechiffrees) —
|
||||||
|
# forum MakeMKV, fil "Version 2.0.0 won't open the disk structure (bug?)".
|
||||||
|
# Les anciennes versions vivent sous /download/old/.
|
||||||
RUN curl -fsSLO "https://www.makemkv.com/download/makemkv-oss-${MAKEMKV_VERSION}.tar.gz" \
|
RUN curl -fsSLO "https://www.makemkv.com/download/makemkv-oss-${MAKEMKV_VERSION}.tar.gz" \
|
||||||
&& curl -fsSLO "https://www.makemkv.com/download/makemkv-bin-${MAKEMKV_VERSION}.tar.gz" \
|
|| curl -fsSLO "https://www.makemkv.com/download/old/makemkv-oss-${MAKEMKV_VERSION}.tar.gz"; \
|
||||||
&& tar -xzf "makemkv-oss-${MAKEMKV_VERSION}.tar.gz" \
|
curl -fsSLO "https://www.makemkv.com/download/makemkv-bin-${MAKEMKV_VERSION}.tar.gz" \
|
||||||
|
|| curl -fsSLO "https://www.makemkv.com/download/old/makemkv-bin-${MAKEMKV_VERSION}.tar.gz"; \
|
||||||
|
tar -xzf "makemkv-oss-${MAKEMKV_VERSION}.tar.gz" \
|
||||||
&& tar -xzf "makemkv-bin-${MAKEMKV_VERSION}.tar.gz" \
|
&& tar -xzf "makemkv-bin-${MAKEMKV_VERSION}.tar.gz" \
|
||||||
&& cd "makemkv-oss-${MAKEMKV_VERSION}" \
|
&& cd "makemkv-oss-${MAKEMKV_VERSION}" \
|
||||||
&& ./configure --disable-gui \
|
&& ./configure --disable-gui \
|
||||||
@@ -56,7 +62,11 @@ COPY app/ app/
|
|||||||
COPY --from=web /web/dist /app/web/dist
|
COPY --from=web /web/dist /app/web/dist
|
||||||
COPY docker/entrypoint.py /entrypoint.py
|
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_WEB_DIR=/app/web/dist \
|
||||||
MKVTOOL_FILMS_DIR=/films \
|
MKVTOOL_FILMS_DIR=/films \
|
||||||
MKVTOOL_RADARR_FILMS_DIR=/nas_storage/jellyfin/films \
|
MKVTOOL_RADARR_FILMS_DIR=/nas_storage/jellyfin/films \
|
||||||
|
|||||||
@@ -26,9 +26,59 @@ L'image est construite par la CI (job `container:image`, Kaniko) a chaque tag
|
|||||||
| `api` | `python:3.13-slim` | ffmpeg, MakeMKV compile depuis les sources, dependances `uv sync --no-dev` |
|
| `api` | `python:3.13-slim` | ffmpeg, MakeMKV compile depuis les sources, dependances `uv sync --no-dev` |
|
||||||
|
|
||||||
MakeMKV (`makemkvcon`) est compile dans l'image a partir de la version definie
|
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
|
par l'argument de build `MAKEMKV_VERSION` (par defaut `1.18.4`). Le build local
|
||||||
reste possible : `docker build -t mkvtool .`.
|
reste possible : `docker build -t mkvtool .`.
|
||||||
|
|
||||||
|
**Pourquoi 1.18.4 et pas 2.0.0** : la 2.0.0 a une regression confirmee qui
|
||||||
|
fait planter `makemkvcon` sur les ISO Blu-ray sans dossier AACS (non chiffrees
|
||||||
|
ou pre-dechiffrees — « AACS directory not present, assuming unencrypted disc »
|
||||||
|
puis « Fatal error occurred »). Voir le forum MakeMKV, fil « Version 2.0.0
|
||||||
|
won't open the disk structure (bug?) ». Les disques physiques chiffres ne
|
||||||
|
sont pas affectes; si vous n'utilisez que ceux-la, `--build-arg
|
||||||
|
MAKEMKV_VERSION=2.0.0` reste possible. Les anciennes versions sont
|
||||||
|
telechargees depuis https://www.makemkv.com/download/old/ .
|
||||||
|
|
||||||
|
## 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).
|
||||||
|
|
||||||
|
La façon recommandée avec cette image est la variable d'environnement
|
||||||
|
`MAKEMKV_KEY` : l'entrypoint l'écrit dans `/config/.MakeMKV/settings.conf`
|
||||||
|
(entrée `app_Key`) à chaque démarrage, sous l'UID du service.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
environment:
|
||||||
|
MAKEMKV_KEY: "T-VOTRE-CLE"
|
||||||
|
```
|
||||||
|
|
||||||
|
Manuellement, créez le fichier `<montage de /config>/.MakeMKV/settings.conf`
|
||||||
|
sur l'hôte :
|
||||||
|
|
||||||
|
```
|
||||||
|
app_Key = "T-VOTRE-CLE"
|
||||||
|
```
|
||||||
|
|
||||||
|
Notes importantes :
|
||||||
|
|
||||||
|
- Le nom du paramètre est **`app_Key`** (pas `app_MakeMKV_key`, que
|
||||||
|
`makemkvcon` ignore silencieusement).
|
||||||
|
- La commande `makemkvcon reg <clé>` est peu fiable sur Linux (« Key not
|
||||||
|
found or invalid » même avec une clé valide) : préférez le fichier.
|
||||||
|
- L'image positionne `HOME=/config` et crée une entrée passwd pour
|
||||||
|
PUID: c'est ainsi que `makemkvcon` trouve `/config/.MakeMKV`.
|
||||||
|
|
||||||
|
Si une conversion échoue avec le message d'activation, la clé a expiré :
|
||||||
|
reprenez la clé courante sur le forum, mettez à jour `MAKEMKV_KEY` et
|
||||||
|
redémarrez le conteneur.
|
||||||
|
|
||||||
## Variables d'environnement
|
## Variables d'environnement
|
||||||
|
|
||||||
| Variable | Defaut image | Role |
|
| Variable | Defaut image | Role |
|
||||||
@@ -42,7 +92,8 @@ reste possible : `docker build -t mkvtool .`.
|
|||||||
| `MKVTOOL_DOWNLOADS_DIR` | `/qbittorrentdownloads` | Racine des telechargements qBittorrent |
|
| `MKVTOOL_DOWNLOADS_DIR` | `/qbittorrentdownloads` | Racine des telechargements qBittorrent |
|
||||||
| `MKVTOOL_SIMULATE_CONVERSION` | `false` | `true` = produit un faux MKV sans appeler MakeMKV (dev/tests) |
|
| `MKVTOOL_SIMULATE_CONVERSION` | `false` | `true` = produit un faux MKV sans appeler MakeMKV (dev/tests) |
|
||||||
| `MKVTOOL_WORKER_INTERVAL` | `10` | Secondes entre deux tours de la file de conversion |
|
| `MKVTOOL_WORKER_INTERVAL` | `10` | Secondes entre deux tours de la file de conversion |
|
||||||
| `MAKEMKV_VERSION` | `2.0.0` | Version MakeMKV embarquee (visible dans `/api/health`) |
|
| `MAKEMKV_KEY` | (vide) | Clé d'activation MakeMKV (voir « Activation de MakeMKV »), écrite dans `/config/.MakeMKV/settings.conf` par l'entrypoint |
|
||||||
|
| `MAKEMKV_VERSION` | `1.18.4` | Version MakeMKV embarquee (visible dans `/api/health`) |
|
||||||
|
|
||||||
## Volumes
|
## Volumes
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,14 @@ def extract_mkv(movie: IsoMovie, mkv_path: Path) -> None:
|
|||||||
)
|
)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
detail = result.stderr.strip() or result.stdout.strip()
|
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. "
|
||||||
|
"Renseignez la variable d'environnement MAKEMKV_KEY (clé bêta gratuite "
|
||||||
|
"du forum officiel MakeMKV ou clé achetée) et redémarrez le conteneur, "
|
||||||
|
"ou ajoutez app_Key = \"<clé>\" dans /config/.MakeMKV/settings.conf "
|
||||||
|
"(nom app_Key, pas app_MakeMKV_key). Voir IMAGE.md."
|
||||||
|
)
|
||||||
raise RuntimeError(f"MakeMKV a echoue: {detail}")
|
raise RuntimeError(f"MakeMKV a echoue: {detail}")
|
||||||
produced = sorted(mkv_path.parent.glob("*.mkv"))
|
produced = sorted(mkv_path.parent.glob("*.mkv"))
|
||||||
if not produced:
|
if not produced:
|
||||||
|
|||||||
+6
-1
@@ -7,7 +7,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
args:
|
args:
|
||||||
MAKEMKV_VERSION: "2.0.0"
|
# 1.18.4: la 2.0.0 plante sur les ISO Blu-ray non chiffrees
|
||||||
|
# (regression connue, voir IMAGE.md).
|
||||||
|
MAKEMKV_VERSION: "1.18.4"
|
||||||
container_name: mkvtool
|
container_name: mkvtool
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
@@ -27,6 +29,9 @@ services:
|
|||||||
# Chemin de la bibliotheque tel que Radarr le rapporte (traduction ISO).
|
# Chemin de la bibliotheque tel que Radarr le rapporte (traduction ISO).
|
||||||
MKVTOOL_RADARR_FILMS_DIR: /nas_storage/jellyfin/films
|
MKVTOOL_RADARR_FILMS_DIR: /nas_storage/jellyfin/films
|
||||||
MKVTOOL_DOWNLOADS_DIR: /qbittorrentdownloads
|
MKVTOOL_DOWNLOADS_DIR: /qbittorrentdownloads
|
||||||
|
# Clé d'activation MakeMKV: clé bêta gratuite du forum officiel
|
||||||
|
# (rotation tous les 1-2 mois) ou clé permanente — voir IMAGE.md.
|
||||||
|
MAKEMKV_KEY: "T-VOTRE-CLE"
|
||||||
volumes:
|
volumes:
|
||||||
# La bibliotheque Jellyfin est montee en /films dans le conteneur; les
|
# La bibliotheque Jellyfin est montee en /films dans le conteneur; les
|
||||||
# chemins Radarr (MKVTOOL_RADARR_FILMS_DIR) sont traduits par l'API.
|
# chemins Radarr (MKVTOOL_RADARR_FILMS_DIR) sont traduits par l'API.
|
||||||
|
|||||||
+42
-1
@@ -15,16 +15,57 @@ puisse créer, supprimer et lier des fichiers dedans, sans que le bit
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
puid = int(os.environ.get("PUID", "0") or "0")
|
puid = int(os.environ.get("PUID", "0") or "0")
|
||||||
pgid = int(os.environ.get("PGID", "0") or "0")
|
pgid = int(os.environ.get("PGID", "0") or "0")
|
||||||
config_dir = os.environ.get("MKVTOOL_CONFIG_DIR", "/config")
|
config_dir = os.environ.get("MKVTOOL_CONFIG_DIR", "/config")
|
||||||
|
|
||||||
if os.geteuid() == 0 and puid:
|
|
||||||
|
def write_makemkv_key() -> None:
|
||||||
|
"""Ecrit la cle MakeMKV (env MAKEMKV_KEY) dans settings.conf.
|
||||||
|
|
||||||
|
MakeMKV lit ``app_Key`` dans ``/config/.MakeMKV/settings.conf``
|
||||||
|
(la commande ``makemkvcon reg <cle>`` est peu fiable sur Linux).
|
||||||
|
La cle bêta courante: forum officiel MakeMKV, fil « MakeMKV is free
|
||||||
|
while in beta » (rotation tous les un a deux mois).
|
||||||
|
"""
|
||||||
|
key = os.environ.get("MAKEMKV_KEY", "").strip()
|
||||||
|
if not key:
|
||||||
|
return
|
||||||
|
settings_path = Path(config_dir) / ".MakeMKV" / "settings.conf"
|
||||||
|
settings_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
lines = []
|
||||||
|
if settings_path.exists():
|
||||||
|
lines = [
|
||||||
|
line
|
||||||
|
for line in settings_path.read_text(encoding="utf-8").splitlines()
|
||||||
|
if not line.strip().startswith("app_Key")
|
||||||
|
]
|
||||||
|
lines.append(f'app_Key = "{key}"')
|
||||||
|
settings_path.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
if os.geteuid() == 0:
|
||||||
|
write_makemkv_key()
|
||||||
|
if puid:
|
||||||
if os.path.isdir(config_dir):
|
if os.path.isdir(config_dir):
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["chown", "-R", f"{puid}:{pgid or puid}", config_dir], check=False
|
["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 [])
|
os.setgroups([pgid] if pgid else [])
|
||||||
if pgid:
|
if pgid:
|
||||||
os.setgid(pgid)
|
os.setgid(pgid)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ from fastapi.testclient import TestClient
|
|||||||
from httpx import Response
|
from httpx import Response
|
||||||
|
|
||||||
from app.config import settings
|
from app.config import settings
|
||||||
|
from app.converter import extract_mkv
|
||||||
from app.database import SessionLocal
|
from app.database import SessionLocal
|
||||||
from app.main import app
|
from app.main import app
|
||||||
from app.models import IsoMovie
|
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]
|
movie = client.get("/api/movies").json()[0]
|
||||||
assert movie["radarr_linked"] is False
|
assert movie["radarr_linked"] is False
|
||||||
assert movie["status"] == "detected"
|
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 "MAKEMKV_KEY" in str(error)
|
||||||
|
else:
|
||||||
|
raise AssertionError("RuntimeError attendue")
|
||||||
Reference in new issue
Block a user