From 3463c1e371c0cd3e57bfa835827d28a4abd0851c Mon Sep 17 00:00:00 2001 From: Maveno Date: Sun, 20 Oct 2024 18:29:49 +0200 Subject: [PATCH] improving unmux --- bin/ffx.py | 24 ++++++++++++++---------- bin/ffx/file_properties.py | 5 +++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/bin/ffx.py b/bin/ffx.py index d545693..3b09e2b 100755 --- a/bin/ffx.py +++ b/bin/ffx.py @@ -105,8 +105,6 @@ def getUnmuxSequence(trackDescriptor: TrackDescriptor, sourcePath, targetPrefix, @click.option("-o", "--output-directory", type=str, default='') @click.option("-s", "--subtitles-only", is_flag=True, default=False) @click.option("--dry-run", is_flag=True, default=False) - - def unmux(ctx, paths, label, @@ -121,21 +119,27 @@ def unmux(ctx, fp = FileProperties(ctx.obj, sourcePath) - print(f"\nFile {sourcePath}\n") - + try: sourceMediaDescriptor = fp.getMediaDescriptor() + season = fp.getSeason() + episode = fp.getEpisode() + + #TODO: Recognition für alle Formate anpassen + targetLabel = label if label else fp.getFileBasename() + targetIndicator = f"_S{season}E{episode}" if label and season != -1 and episode != -1 else '' + + if label and not targetIndicator: + click.echo(f"Skipping file {fp.getFilename()}: Label set but no indicator recognized") + continue + else: + click.echo(f"\nUnmuxing file {fp.getFilename()}\n") + for trackDescriptor in sourceMediaDescriptor.getAllTrackDescriptors(): if trackDescriptor.getType() == TrackType.SUBTITLE or not subtitles_only: - season = fp.getSeason() - episode = fp.getEpisode() - - targetLabel = label if label else fp.getFileBasename() - targetIndicator = f"_S{season}E{episode}" if label and season != -1 and episode != -1 else '' - # SEASON_EPISODE_STREAM_LANGUAGE_MATCH = '[sS]([0-9]+)[eE]([0-9]+)_([0-9]+)_([a-z]{3})' targetPrefix = f"{targetLabel}{targetIndicator}_{trackDescriptor.getIndex()}_{trackDescriptor.getLanguage().threeLetter()}" diff --git a/bin/ffx/file_properties.py b/bin/ffx/file_properties.py index cd5965f..99a9afa 100644 --- a/bin/ffx/file_properties.py +++ b/bin/ffx/file_properties.py @@ -185,9 +185,14 @@ class FileProperties(): def getEpisode(self): return int(self.__episode) + + def getFilename(self): + return self.__sourceFilename + def getFileBasename(self): return self.__sourceFileBasename + def assembleTargetFileBasename(self, label: str = "", quality: int = -1,