Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
078905e944 | ||
|
|
39319b7caa | ||
|
|
10830f3562 | ||
|
|
87fd6b39fd |
No files matched your search
+9
-3
@@ -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 \
|
||||||
|
|||||||
@@ -26,9 +26,18 @@ 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
|
## Activation de MakeMKV
|
||||||
|
|
||||||
MakeMKV est shareware : sans clé d'activation, `makemkvcon` ne peut pas
|
MakeMKV est shareware : sans clé d'activation, `makemkvcon` ne peut pas
|
||||||
@@ -39,26 +48,36 @@ d'évaluation, puis s'arrête). Deux options :
|
|||||||
(https://forum.makemkv.com/forum/viewtopic.php?t=1053) et renouvelée tous
|
(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
|
les un à deux mois tant que MakeMKV reste en bêta. C'est la voie gratuite
|
||||||
usuelle.
|
usuelle.
|
||||||
- **Clé permanente** achetée (~60 USD, achat à vie) — l'achat est
|
- **Clé permanente** achetée (~60 USD, achat à vie).
|
||||||
ponctuellement indisponible côté éditeur, la clé bêta fait alors foi.
|
|
||||||
|
|
||||||
L'image positionne `HOME=/config` : MakeMKV lit et écrit sa configuration
|
La façon recommandée avec cette image est la variable d'environnement
|
||||||
dans `/config/.MakeMKV/settings.conf`, donc sur le volume persistant. Pour
|
`MAKEMKV_KEY` : l'entrypoint l'écrit dans `/config/.MakeMKV/settings.conf`
|
||||||
activer :
|
(entrée `app_Key`) à chaque démarrage, sous l'UID du service.
|
||||||
|
|
||||||
```bash
|
```yaml
|
||||||
docker exec mkvtool makemkvcon reg T-VOTRE-CLE
|
environment:
|
||||||
|
MAKEMKV_KEY: "T-VOTRE-CLE"
|
||||||
```
|
```
|
||||||
|
|
||||||
Ou en créant le fichier `<montage de /config>/.MakeMKV/settings.conf` sur
|
Manuellement, créez le fichier `<montage de /config>/.MakeMKV/settings.conf`
|
||||||
l'hôte :
|
sur l'hôte :
|
||||||
|
|
||||||
```
|
```
|
||||||
app_MakeMKV_key = "T-VOTRE-CLE"
|
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é :
|
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.
|
reprenez la clé courante sur le forum, mettez à jour `MAKEMKV_KEY` et
|
||||||
|
redémarrez le conteneur.
|
||||||
|
|
||||||
## Variables d'environnement
|
## Variables d'environnement
|
||||||
|
|
||||||
@@ -73,7 +92,8 @@ reprenez la clé courante sur le forum et relancez la commande ci-dessus.
|
|||||||
| `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
|
||||||
|
|
||||||
|
|||||||
+50
-8
@@ -9,6 +9,7 @@ import errno
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -17,6 +18,9 @@ from app.config import settings
|
|||||||
from app.models import IsoMovie
|
from app.models import IsoMovie
|
||||||
|
|
||||||
INVALID_CHARACTERS = re.compile(r'[/\\:*?"<>|]')
|
INVALID_CHARACTERS = re.compile(r'[/\\:*?"<>|]')
|
||||||
|
# Mode robot de makemkvcon: TINFO:<titre>,9,<code>,"H:MM:SS" par titre
|
||||||
|
# (code 9 = duree, voir makemkv.com/developers/usage.txt).
|
||||||
|
TITLE_DURATION = re.compile(r'TINFO:(\d+),9,\d+,"(\d+):(\d{2}):(\d{2})"')
|
||||||
|
|
||||||
|
|
||||||
def guarded_folder(folder: Path) -> Path:
|
def guarded_folder(folder: Path) -> Path:
|
||||||
@@ -77,6 +81,30 @@ def conversion_paths(movie: IsoMovie) -> ConversionPaths:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def longest_title_id(iso: Path) -> str:
|
||||||
|
"""Identifiant du titre le plus long, via ``makemkvcon --robot info``.
|
||||||
|
|
||||||
|
Les identifiants ne suivent pas la duree: le titre 0 n'est pas
|
||||||
|
forcement le film (souvent un bonus). En cas d'echec de l'analyse on
|
||||||
|
retombe sur le titre 0. Le seuil minlength est laisse par defaut (120 s)
|
||||||
|
pour que la numerotation concorde avec la commande ``mkv``.
|
||||||
|
"""
|
||||||
|
result = subprocess.run(
|
||||||
|
["makemkvcon", "--robot", "info", f"iso:{iso}"],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
best_title, best_seconds = "0", -1
|
||||||
|
for line in result.stdout.splitlines():
|
||||||
|
match = TITLE_DURATION.search(line)
|
||||||
|
if not match:
|
||||||
|
continue
|
||||||
|
seconds = int(match[2]) * 3600 + int(match[3]) * 60 + int(match[4])
|
||||||
|
if seconds > best_seconds:
|
||||||
|
best_title, best_seconds = match[1], seconds
|
||||||
|
return best_title
|
||||||
|
|
||||||
|
|
||||||
def extract_mkv(movie: IsoMovie, mkv_path: Path) -> None:
|
def extract_mkv(movie: IsoMovie, mkv_path: Path) -> None:
|
||||||
mkv_path.parent.mkdir(parents=True, exist_ok=True)
|
mkv_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
if settings.simulate_conversion:
|
if settings.simulate_conversion:
|
||||||
@@ -87,22 +115,36 @@ def extract_mkv(movie: IsoMovie, mkv_path: Path) -> None:
|
|||||||
return
|
return
|
||||||
if shutil.which("makemkvcon") is None:
|
if shutil.which("makemkvcon") is None:
|
||||||
raise RuntimeError("MakeMKV (makemkvcon) n'est pas installe sur le serveur")
|
raise RuntimeError("MakeMKV (makemkvcon) n'est pas installe sur le serveur")
|
||||||
|
iso = container_iso_path(movie)
|
||||||
|
title = longest_title_id(iso)
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["makemkvcon", "mkv", f"iso:{container_iso_path(movie)}", "0", str(mkv_path.parent)],
|
["makemkvcon", "mkv", f"iso:{iso}", title, str(mkv_path.parent)],
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
)
|
)
|
||||||
|
output = result.stdout or ""
|
||||||
|
error = result.stderr or ""
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
detail = result.stderr.strip() or result.stdout.strip()
|
if "purchase an activation key" in output or "evaluation period" in output:
|
||||||
if "purchase an activation key" in detail or "evaluation period" in detail:
|
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"MakeMKV n'est pas activé: une clé est requise pour la conversion. "
|
"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é "
|
"Renseignez la variable d'environnement MAKEMKV_KEY (clé bêta gratuite "
|
||||||
"achetée, puis `docker exec mkvtool makemkvcon reg <clé>` "
|
"du forum officiel MakeMKV ou clé achetée) et redémarrez le conteneur, "
|
||||||
"(ou renseignez app_MakeMKV_key dans /config/.MakeMKV/settings.conf). "
|
"ou ajoutez app_Key = \"<clé>\" dans /config/.MakeMKV/settings.conf "
|
||||||
"Voir IMAGE.md."
|
"(nom app_Key, pas app_MakeMKV_key). Voir IMAGE.md."
|
||||||
)
|
)
|
||||||
raise RuntimeError(f"MakeMKV a echoue: {detail}")
|
if result.returncode < 0:
|
||||||
|
# Un code negatif signale un processus tue par un signal:
|
||||||
|
# SIGKILL = en general le tueur OOM (manque de memoire).
|
||||||
|
try:
|
||||||
|
name = signal.Signals(-result.returncode).name
|
||||||
|
except ValueError:
|
||||||
|
name = f"signal {-result.returncode}"
|
||||||
|
reason = f"processus tué par {name} — souvent un manque de mémoire"
|
||||||
|
else:
|
||||||
|
reason = f"code {result.returncode}"
|
||||||
|
detail = "\n".join(part.strip() for part in (error, output) if part.strip())
|
||||||
|
raise RuntimeError(f"MakeMKV a échoué ({reason}): {detail}")
|
||||||
produced = sorted(mkv_path.parent.glob("*.mkv"))
|
produced = sorted(mkv_path.parent.glob("*.mkv"))
|
||||||
if not produced:
|
if not produced:
|
||||||
raise RuntimeError("MakeMKV n'a produit aucun fichier MKV")
|
raise RuntimeError("MakeMKV n'a produit aucun fichier MKV")
|
||||||
|
|||||||
+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)
|
||||||
|
|||||||
@@ -192,6 +192,60 @@ def test_extract_fails_with_activation_error_when_makemkv_unactivated(
|
|||||||
extract_mkv(movie, tmp_path / "out" / "movie.mkv")
|
extract_mkv(movie, tmp_path / "out" / "movie.mkv")
|
||||||
except RuntimeError as error:
|
except RuntimeError as error:
|
||||||
assert "MakeMKV n'est pas activé" in str(error)
|
assert "MakeMKV n'est pas activé" in str(error)
|
||||||
assert "makemkvcon reg" in str(error)
|
assert "MAKEMKV_KEY" in str(error)
|
||||||
else:
|
else:
|
||||||
raise AssertionError("RuntimeError attendue")
|
raise AssertionError("RuntimeError attendue")
|
||||||
|
|
||||||
|
|
||||||
|
def test_extract_reports_signal_kill(monkeypatch, tmp_path) -> None:
|
||||||
|
"""Un processus tue par signal (ex: OOM) est identifie dans l'erreur."""
|
||||||
|
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=-9, stdout="", 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 "SIGKILL" in str(error)
|
||||||
|
else:
|
||||||
|
raise AssertionError("RuntimeError attendue")
|
||||||
|
|
||||||
|
|
||||||
|
def test_extract_picks_longest_title(monkeypatch, tmp_path) -> None:
|
||||||
|
"""Le titre extrait est le plus long, pas le numero 0."""
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
|
robot_info = "\n".join(
|
||||||
|
[
|
||||||
|
'MSG:1005,0,1,"MakeMKV started"',
|
||||||
|
'TINFO:0,9,0,"0:02:30"',
|
||||||
|
'TINFO:1,9,0,"1:57:00"',
|
||||||
|
'TINFO:2,9,0,"0:24:13"',
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
def fake_run(args, **kwargs):
|
||||||
|
if "--robot" in args:
|
||||||
|
return SimpleNamespace(returncode=0, stdout=robot_info, stderr="")
|
||||||
|
# Commande mkv: on verifie le titre choisi et on simule la sortie.
|
||||||
|
assert args[3] == "1", f"titre attendu: 1, commande: {args}"
|
||||||
|
out = tmp_path / "out"
|
||||||
|
out.mkdir(parents=True, exist_ok=True)
|
||||||
|
(out / "movie.mkv").write_text("mkv")
|
||||||
|
return SimpleNamespace(returncode=0, stdout="", stderr="")
|
||||||
|
|
||||||
|
monkeypatch.setattr(settings, "simulate_conversion", False)
|
||||||
|
monkeypatch.setattr("app.converter.shutil.which", lambda _: "/usr/bin/makemkvcon")
|
||||||
|
monkeypatch.setattr("app.converter.subprocess.run", fake_run)
|
||||||
|
movie = IsoMovie(
|
||||||
|
radarr_movie_id=1, radarr_movie_file_id=2, title="ISO Movie", path="/x.iso"
|
||||||
|
)
|
||||||
|
extract_mkv(movie, tmp_path / "out" / "movie.mkv")
|
||||||
|
assert (tmp_path / "out" / "movie.mkv").exists()
|
||||||
Reference in new issue
Block a user