Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
add archive no-closed-captions flag (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
kralverde authored Jan 29, 2024
1 parent 982e521 commit f8309f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crunchy-cli-core/src/archive/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,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 = "Skip files which are already existing")]
#[arg(long, default_value_t = false)]
pub(crate) skip_existing: bool,
Expand Down Expand Up @@ -224,6 +228,7 @@ impl Execute for Archive {
.output_format(Some("matroska".to_string()))
.audio_sort(Some(self.audio.clone()))
.subtitle_sort(Some(self.subtitle.clone()))
.no_closed_caption(self.no_closed_caption)
.threads(self.threads);

for single_formats in single_format_collection.into_iter() {
Expand Down
8 changes: 8 additions & 0 deletions crunchy-cli-core/src/utils/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub struct DownloadBuilder {
subtitle_sort: Option<Vec<Locale>>,
force_hardsub: bool,
download_fonts: bool,
no_closed_caption: bool,
threads: usize,
ffmpeg_threads: Option<usize>,
}
Expand All @@ -74,6 +75,7 @@ impl DownloadBuilder {
subtitle_sort: None,
force_hardsub: false,
download_fonts: false,
no_closed_caption: false,
threads: num_cpus::get(),
ffmpeg_threads: None,
}
Expand All @@ -91,6 +93,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,
Expand Down Expand Up @@ -124,6 +127,7 @@ pub struct Downloader {

force_hardsub: bool,
download_fonts: bool,
no_closed_caption: bool,

download_threads: usize,
ffmpeg_threads: Option<usize>,
Expand Down Expand Up @@ -266,6 +270,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() {
Expand Down

0 comments on commit f8309f2

Please sign in to comment.