Update original_media_type to use enum and set it on VideoFile instance

This commit is contained in:
Esa Kataja
2025-04-17 12:58:19 +03:00
parent 5ec816c163
commit 0c71d3c58b
+3 -2
View File
@@ -3,7 +3,7 @@ import subprocess
import typer import typer
from pathlib import Path from pathlib import Path
from models.streams import VideoFile, VideoStream, AudioStream, SubtitleStream from models.streams import VideoFile, VideoStream, AudioStream, SubtitleStream, OriginalMediaType
from movie_details import get_movie_details from movie_details import get_movie_details
from lib.fs import write_shell_script from lib.fs import write_shell_script
@@ -30,7 +30,7 @@ def main(
nosubtitles: bool = typer.Option(False, "-ns", "--nosubtitles", help="Remove subtitles"), nosubtitles: bool = typer.Option(False, "-ns", "--nosubtitles", help="Remove subtitles"),
preset: int = typer.Option(2, "-p", "--preset", help="Encoding preset"), preset: int = typer.Option(2, "-p", "--preset", help="Encoding preset"),
crf: int = typer.Option(30, "-c", "--crf", help="CRF value"), crf: int = typer.Option(30, "-c", "--crf", help="CRF value"),
original_media_type: str = typer.Option("DVD", "-o", "--original-media-type", help="Set the ORIGINAL_MEDIA_TYPE metadata"), original_media_type: OriginalMediaType = typer.Option(OriginalMediaType.DVD, "-o", "--original-media-type", case_sensitive=False, help="Source of the original media."),
film_grain: int = typer.Option(20, "-fg", "--film-grain", help="Film grain amount (default: 20)") film_grain: int = typer.Option(20, "-fg", "--film-grain", help="Film grain amount (default: 20)")
): ):
video_details = VideoFile( video_details = VideoFile(
@@ -50,6 +50,7 @@ def main(
] ]
result = subprocess.run(cmd, capture_output=True, check=True) result = subprocess.run(cmd, capture_output=True, check=True)
data = parse_streams(json.loads(result.stdout), video_details) data = parse_streams(json.loads(result.stdout), video_details)
data.original_media_type = original_media_type
for stream in data.video_streams: for stream in data.video_streams:
stream.preset = preset stream.preset = preset
stream.crf = crf stream.crf = crf