From 77b4028c34d36eb6ae5c5541349c61d3f7c1b438 Mon Sep 17 00:00:00 2001 From: kralverde Date: Sun, 28 Jan 2024 16:31:36 -0500 Subject: [PATCH] add no-closed-captions flag --- crunchy-cli-core/src/archive/command.rs | 5 +++++ crunchy-cli-core/src/utils/download.rs | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/crunchy-cli-core/src/archive/command.rs b/crunchy-cli-core/src/archive/command.rs index b61600f..9c054ea 100644 --- a/crunchy-cli-core/src/archive/command.rs +++ b/crunchy-cli-core/src/archive/command.rs @@ -114,6 +114,10 @@ pub struct Archive { #[arg(long)] pub(crate) include_fonts: bool, + #[arg(help = "Omit closed caption subtitles in the downloaded file")] + #[arg(long, default_value_t = false)] + pub(crate) no_closed_caption: bool, + #[arg( help = "If a subtitle byte size is less than this amount, it is not included in the downloaded file." )] @@ -220,6 +224,7 @@ impl Execute for Archive { .audio_sort(Some(self.audio.clone())) .subtitle_sort(Some(self.subtitle.clone())) .meaningful_subtitle_min_size(self.meaningful_subtitle_size) + .no_closed_caption(self.no_closed_caption) .threads(self.threads); for single_formats in single_format_collection.into_iter() { diff --git a/crunchy-cli-core/src/utils/download.rs b/crunchy-cli-core/src/utils/download.rs index cbd59e1..08c047e 100644 --- a/crunchy-cli-core/src/utils/download.rs +++ b/crunchy-cli-core/src/utils/download.rs @@ -59,6 +59,7 @@ pub struct DownloadBuilder { subtitle_sort: Option>, meaningful_subtitle_min_size: u64, force_hardsub: bool, + no_closed_caption: bool, download_fonts: bool, threads: usize, ffmpeg_threads: Option, @@ -76,6 +77,7 @@ impl DownloadBuilder { subtitle_sort: None, meaningful_subtitle_min_size: 0, force_hardsub: false, + no_closed_caption: false, download_fonts: false, threads: num_cpus::get(), ffmpeg_threads: None, @@ -95,6 +97,7 @@ impl DownloadBuilder { force_hardsub: self.force_hardsub, download_fonts: self.download_fonts, + no_closed_caption: self.no_closed_caption, download_threads: self.threads, ffmpeg_threads: self.ffmpeg_threads, @@ -129,6 +132,7 @@ pub struct Downloader { force_hardsub: bool, download_fonts: bool, + no_closed_caption: bool, download_threads: usize, ffmpeg_threads: Option, @@ -271,6 +275,10 @@ impl Downloader { }; for (subtitle, not_cc) in format.subtitles.iter() { + if !not_cc && self.no_closed_caption { + continue; + } + if let Some(pb) = &progress_spinner { let mut progress_message = pb.message(); if !progress_message.is_empty() {