From 87ff66f8fe8c8f42980fbf758641e380282870c8 Mon Sep 17 00:00:00 2001 From: Andy Date: Sun, 9 Nov 2025 21:27:19 +0000 Subject: [PATCH] fix: ensure subtitles use requests downloader instead of n_m3u8dl_re if Descriptor.URL PR #38 refactored n_m3u8dl_re track selection to support DASH/ISM subtitle tracks, but this broke some subtitle downloads. Services that use direct URL downloads (Descriptor.URL) for subtitles, which n_m3u8dl_re does not support. --- unshackle/core/downloaders/n_m3u8dl_re.py | 6 ++++++ unshackle/core/tracks/track.py | 26 +++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/unshackle/core/downloaders/n_m3u8dl_re.py b/unshackle/core/downloaders/n_m3u8dl_re.py index 52ea3be..7472c59 100644 --- a/unshackle/core/downloaders/n_m3u8dl_re.py +++ b/unshackle/core/downloaders/n_m3u8dl_re.py @@ -142,6 +142,12 @@ def get_track_selection_args(track: Any) -> list[str]: parts.append(f"lang={lang}") return _create_args("-ss", parts, "subtitle", extra_args=["--auto-subtitle-fix", "false"]) + case "URL": + raise ValueError( + f"[N_m3u8DL-RE]: Direct URL downloads are not supported for {track_type} tracks. " + f"The track should use a different downloader (e.g., 'requests', 'aria2c')." + ) + raise ValueError(f"[N_m3u8DL-RE]: Unsupported manifest type: {descriptor}") diff --git a/unshackle/core/tracks/track.py b/unshackle/core/tracks/track.py index 6cf12c9..0b1a38f 100644 --- a/unshackle/core/tracks/track.py +++ b/unshackle/core/tracks/track.py @@ -211,17 +211,21 @@ class Track: save_path = config.directories.temp / f"{track_type}_{self.id}.mp4" if track_type == "Subtitle": save_path = save_path.with_suffix(f".{self.codec.extension}") - # n_m3u8dl_re doesn't support directly downloading subtitles - if self.downloader.__name__ == "n_m3u8dl_re" and get_extension(self.url) in { - ".srt", - ".vtt", - ".ttml", - ".ssa", - ".ass", - ".stpp", - ".wvtt", - ".xml", - }: + # n_m3u8dl_re doesn't support directly downloading subtitles from URLs + # or when the subtitle has a direct file extension + if self.downloader.__name__ == "n_m3u8dl_re" and ( + self.descriptor == self.Descriptor.URL + or get_extension(self.url) in { + ".srt", + ".vtt", + ".ttml", + ".ssa", + ".ass", + ".stpp", + ".wvtt", + ".xml", + } + ): self.downloader = requests if self.descriptor != self.Descriptor.URL: