From 4dff597af2d0237a04e91145a4df878072b07f3c Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 5 Aug 2025 15:48:17 +0000 Subject: [PATCH] feat(dl): Fix track selection to support combining -V, -A, -S flags Previously, using multiple track selection flags like `-S -A` would not work as expected. The flags were treated as mutually exclusive, resulting in only one type of track being downloaded. This change refactors the track selection logic to properly handle combinations: - Multiple "only" flags now work together (e.g., `-S -A` downloads both) - Exclusion flags (`--no-*`) continue to work and override selections - Default behavior (no flags) remains unchanged Fixes #10 --- unshackle/commands/dl.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/unshackle/commands/dl.py b/unshackle/commands/dl.py index f7f239d..b0acdf7 100644 --- a/unshackle/commands/dl.py +++ b/unshackle/commands/dl.py @@ -783,23 +783,26 @@ class dl: sys.exit(1) if video_only or audio_only or subs_only or chapters_only or no_subs or no_audio or no_chapters: - # Determine which track types to keep based on the flags - keep_videos = True - keep_audio = True - keep_subtitles = True - keep_chapters = True + keep_videos = False + keep_audio = False + keep_subtitles = False + keep_chapters = False - # Handle exclusive flags (only keep one type) - if video_only: - keep_audio = keep_subtitles = keep_chapters = False - elif audio_only: - keep_videos = keep_subtitles = keep_chapters = False - elif subs_only: - keep_videos = keep_audio = keep_chapters = False - elif chapters_only: - keep_videos = keep_audio = keep_subtitles = False + if video_only or audio_only or subs_only or chapters_only: + if video_only: + keep_videos = True + if audio_only: + keep_audio = True + if subs_only: + keep_subtitles = True + if chapters_only: + keep_chapters = True + else: + keep_videos = True + keep_audio = True + keep_subtitles = True + keep_chapters = True - # Handle exclusion flags (remove specific types) if no_subs: keep_subtitles = False if no_audio: @@ -807,7 +810,6 @@ class dl: if no_chapters: keep_chapters = False - # Build the kept_tracks list without duplicates kept_tracks = [] if keep_videos: kept_tracks.extend(title.tracks.videos)