From 485f3fa6d8fd046f2d93c9a99a955817bd9e807f Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Thu, 1 Jun 2023 21:11:31 +0200 Subject: [PATCH] postprocess: remove file when only use merge subtitles In some cases we could end up with two subtitles but we only have "one" subtitle. like one from HLS and one from a different way. --- lib/svtplay_dl/postprocess/__init__.py | 2 +- lib/svtplay_dl/utils/parser.py | 3 --- lib/svtplay_dl/utils/stream.py | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/svtplay_dl/postprocess/__init__.py b/lib/svtplay_dl/postprocess/__init__.py index 89f4f5e..768c307 100644 --- a/lib/svtplay_dl/postprocess/__init__.py +++ b/lib/svtplay_dl/postprocess/__init__.py @@ -133,7 +133,7 @@ class postprocess: # This if statement is for use cases where both -S and -M are specified to not only merge the subtitle but also store it separately. if self.config.get("merge_subtitle") and not self.config.get("subtitle"): - if self.subfixes and len(self.subfixes) >= 2: + if self.subfixes and len(self.subfixes) >= 2 and self.config.get("get_all_subtitles"): for subfix in self.subfixes: subfile = orig_filename.parent / (orig_filename.stem + "." + subfix + ".srt") os.remove(subfile) diff --git a/lib/svtplay_dl/utils/parser.py b/lib/svtplay_dl/utils/parser.py index 015854a..567b1dc 100644 --- a/lib/svtplay_dl/utils/parser.py +++ b/lib/svtplay_dl/utils/parser.py @@ -444,9 +444,6 @@ def _special_settings(config): if config.get("get_only_episode_url"): config.set("get_url", True) - if config.get("get_all_subtitles"): - config.set("subtitle", True) - return config diff --git a/lib/svtplay_dl/utils/stream.py b/lib/svtplay_dl/utils/stream.py index 8b6addf..696ab73 100644 --- a/lib/svtplay_dl/utils/stream.py +++ b/lib/svtplay_dl/utils/stream.py @@ -97,7 +97,7 @@ def subtitle_filter(subtitles) -> List: def subtitle_decider(stream, subtitles): - if subtitles and (stream.config.get("merge_subtitle") or stream.config.get("subtitle")): + if subtitles and (stream.config.get("merge_subtitle") or stream.config.get("subtitle") or stream.config("get_all_subtitles")): subtitles = subtitle_filter(subtitles) if stream.config.get("get_all_subtitles"): for sub in subtitles: