Skip to content

Commit

Permalink
Avoid overwrite config for merge subtitle
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcnx authored and spaam committed Oct 6, 2024
1 parent 515ab99 commit 85d9346
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/svtplay_dl/postprocess/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, stream, config, subfixes=None):
if os.path.isfile(path):
self.detect = path

def merge(self):
def merge(self, merge_subtitle):
if self.detect is None:
logging.error("Cant detect ffmpeg or avconv. Cant mux files without it.")
return
Expand Down Expand Up @@ -60,7 +60,7 @@ def merge(self):
streams = _streams(stderr)
videotrack, audiotrack = _checktracks(streams)

if self.config.get("merge_subtitle"):
if merge_subtitle:
logging.info("Merge audio, video and subtitle into %s", new_name.name)
else:
logging.info(f"Merge audio and video into {str(new_name.name).replace('.audio', '')}")
Expand Down Expand Up @@ -89,7 +89,7 @@ def merge(self):
arguments += ["-map", f"{videotrack}"]
if audiotrack:
arguments += ["-map", f"{audiotrack}"]
if self.config.get("merge_subtitle"):
if merge_subtitle:
langs = _sublanguage(self.stream, self.config, self.subfixes)
tracks = [x for x in [videotrack, audiotrack] if x]
subs_nr = 0
Expand Down Expand Up @@ -135,7 +135,7 @@ def merge(self):
os.remove(audio_filename)

# 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 merge_subtitle and not self.config.get("subtitle"):
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")
Expand Down
5 changes: 3 additions & 2 deletions lib/svtplay_dl/utils/getmedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ def get_one_media(stream):
logging.info("No subtitles available")
return

merge_subtitle = False
if not stream.config.get("list_quality"):
subtitle_decider(stream, subtitles)
merge_subtitle = subtitle_decider(stream, subtitles)
if stream.config.get("force_subtitle"):
return

Expand Down Expand Up @@ -219,6 +220,6 @@ def get_one_media(stream):
if fstream.audio and not post.detect and fstream.finished:
logging.warning("Can't find ffmpeg/avconv. audio and video is in seperate files. if you dont want this use -P hls or hds")
if post.detect and fstream.config.get("no_merge") is False:
post.merge()
post.merge(merge_subtitle)
else:
logging.info("All done. Not postprocessing files, leaving them completely untouched.")
4 changes: 2 additions & 2 deletions lib/svtplay_dl/utils/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def subtitle_decider(stream, subtitles):
print(subtitles[0].url)
else:
subtitles[0].download()
elif stream.config.get("merge_subtitle"):
stream.config.set("merge_subtitle", False)
return stream.config.get("merge_subtitle")
return False


def resolution(streams, resolutions: List) -> List:
Expand Down

0 comments on commit 85d9346

Please sign in to comment.