ffmpeg handling py

proper testing for chapters and metadata
remove all russian finction
This commit is contained in:
Lucas Vivo committed 2026-10-19 13:24:14 +02:00
1 parent 99573fb241
commit c5cf55fe21
7 files changed
+894 -392

No files matched your search

+1 -47
View File
@@ -7,7 +7,7 @@ import shutil
import subprocess
import sys
from pathlib import Path
from serverlibrary import get_audio_tracks
def check_command(command):
if shutil.which(command) is None:
@@ -60,52 +60,6 @@ def scan_dvd(dvd_name: Path):
return titles
def get_audio_tracks(dvd, title):
"""Return HandBrake audio track information for a DVD title."""
result = subprocess.run(
[
"HandBrakeCLI",
"-i", dvd,
"-t", str(title),
"--scan",
],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
check=True,
)
output = result.stdout
# Examples HandBrake may produce:
#
# + 1, Deutsch (AC3, 2.0 ch, 192 kbps)
# + 2, English (AC3, 2.0 ch, 224 kbps)
#
# Also handles German/Englisch/deu/eng where present.
tracks = []
pattern = re.compile(
r"\+\s+(\d+),\s+(.+?)\s+\((?:AC3|AAC|MP3|E-AC-3|DTS)"
)
for match in pattern.finditer(output):
track_number = int(match.group(1))
description = match.group(2).strip()
tracks.append({
"number": track_number,
"description": description,
})
if not tracks:
tracks.append({
"number": 0,
"description": "",
})
return tracks
def choose_audio_tracks(tracks):
"""
Select German first, English second.