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

Add --threads (-t) option to downloading commands #256

Merged
merged 4 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crunchy-cli-core/src/archive/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ pub struct Archive {
#[arg(short, long, default_value_t = false)]
pub(crate) yes: bool,

#[arg(help = "The number of threads used to download")]
#[arg(short, long, default_value_t = num_cpus::get())]
pub(crate) threads: usize,

#[arg(help = "Crunchyroll series url(s)")]
#[arg(required = true)]
pub(crate) urls: Vec<String>,
Expand Down Expand Up @@ -158,7 +162,8 @@ impl Execute for Archive {
.ffmpeg_preset(self.ffmpeg_preset.clone().unwrap_or_default())
.output_format(Some("matroska".to_string()))
.audio_sort(Some(self.audio.clone()))
.subtitle_sort(Some(self.subtitle.clone()));
.subtitle_sort(Some(self.subtitle.clone()))
.threads(self.threads);

for single_formats in single_format_collection.into_iter() {
let (download_formats, mut format) = get_format(&self, &single_formats).await?;
Expand Down
7 changes: 6 additions & 1 deletion crunchy-cli-core/src/download/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ pub struct Download {
#[arg(long, default_value_t = false)]
pub(crate) force_hardsub: bool,

#[arg(help = "The number of threads used to download")]
#[arg(short, long, default_value_t = num_cpus::get())]
pub(crate) threads: usize,

#[arg(help = "Url(s) to Crunchyroll episodes or series")]
#[arg(required = true)]
pub(crate) urls: Vec<String>,
Expand Down Expand Up @@ -149,7 +153,8 @@ impl Execute for Download {
} else {
None
})
.ffmpeg_preset(self.ffmpeg_preset.clone().unwrap_or_default());
.ffmpeg_preset(self.ffmpeg_preset.clone().unwrap_or_default())
.threads(self.threads);

for mut single_formats in single_format_collection.into_iter() {
// the vec contains always only one item
Expand Down
Loading