mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Replace --single-threaded boolean option with --threads optional usize option
This commit is contained in:
parent
9ace4f3476
commit
bdd4d8f899
3 changed files with 15 additions and 15 deletions
|
|
@ -98,9 +98,9 @@ pub struct Archive {
|
||||||
#[arg(short, long, default_value_t = false)]
|
#[arg(short, long, default_value_t = false)]
|
||||||
pub(crate) yes: bool,
|
pub(crate) yes: bool,
|
||||||
|
|
||||||
#[arg(help = "Download using only one thread")]
|
#[arg(help = "Override the number of threads used to download")]
|
||||||
#[arg(short = 't', long, default_value_t = false)]
|
#[arg(short, long)]
|
||||||
pub(crate) single_threaded: bool,
|
pub(crate) threads: Option<usize>,
|
||||||
|
|
||||||
#[arg(help = "Crunchyroll series url(s)")]
|
#[arg(help = "Crunchyroll series url(s)")]
|
||||||
#[arg(required = true)]
|
#[arg(required = true)]
|
||||||
|
|
@ -163,7 +163,7 @@ impl Execute for Archive {
|
||||||
.output_format(Some("matroska".to_string()))
|
.output_format(Some("matroska".to_string()))
|
||||||
.audio_sort(Some(self.audio.clone()))
|
.audio_sort(Some(self.audio.clone()))
|
||||||
.subtitle_sort(Some(self.subtitle.clone()))
|
.subtitle_sort(Some(self.subtitle.clone()))
|
||||||
.single_threaded(self.single_threaded);
|
.threads(self.threads);
|
||||||
|
|
||||||
for single_formats in single_format_collection.into_iter() {
|
for single_formats in single_format_collection.into_iter() {
|
||||||
let (download_formats, mut format) = get_format(&self, &single_formats).await?;
|
let (download_formats, mut format) = get_format(&self, &single_formats).await?;
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,9 @@ pub struct Download {
|
||||||
#[arg(long, default_value_t = false)]
|
#[arg(long, default_value_t = false)]
|
||||||
pub(crate) force_hardsub: bool,
|
pub(crate) force_hardsub: bool,
|
||||||
|
|
||||||
#[arg(help = "Download using only one thread")]
|
#[arg(help = "Override the number of threads used to download")]
|
||||||
#[arg(short = 't', long, default_value_t = false)]
|
#[arg(short, long)]
|
||||||
pub(crate) single_threaded: bool,
|
pub(crate) threads: Option<usize>,
|
||||||
|
|
||||||
#[arg(help = "Url(s) to Crunchyroll episodes or series")]
|
#[arg(help = "Url(s) to Crunchyroll episodes or series")]
|
||||||
#[arg(required = true)]
|
#[arg(required = true)]
|
||||||
|
|
@ -154,7 +154,7 @@ impl Execute for Download {
|
||||||
None
|
None
|
||||||
})
|
})
|
||||||
.ffmpeg_preset(self.ffmpeg_preset.clone().unwrap_or_default())
|
.ffmpeg_preset(self.ffmpeg_preset.clone().unwrap_or_default())
|
||||||
.single_threaded(self.single_threaded);
|
.threads(self.threads);
|
||||||
|
|
||||||
for mut single_formats in single_format_collection.into_iter() {
|
for mut single_formats in single_format_collection.into_iter() {
|
||||||
// the vec contains always only one item
|
// the vec contains always only one item
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ pub struct DownloadBuilder {
|
||||||
audio_sort: Option<Vec<Locale>>,
|
audio_sort: Option<Vec<Locale>>,
|
||||||
subtitle_sort: Option<Vec<Locale>>,
|
subtitle_sort: Option<Vec<Locale>>,
|
||||||
force_hardsub: bool,
|
force_hardsub: bool,
|
||||||
single_threaded: bool,
|
threads: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DownloadBuilder {
|
impl DownloadBuilder {
|
||||||
|
|
@ -62,7 +62,7 @@ impl DownloadBuilder {
|
||||||
audio_sort: None,
|
audio_sort: None,
|
||||||
subtitle_sort: None,
|
subtitle_sort: None,
|
||||||
force_hardsub: false,
|
force_hardsub: false,
|
||||||
single_threaded: false,
|
threads: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ impl DownloadBuilder {
|
||||||
subtitle_sort: self.subtitle_sort,
|
subtitle_sort: self.subtitle_sort,
|
||||||
|
|
||||||
force_hardsub: self.force_hardsub,
|
force_hardsub: self.force_hardsub,
|
||||||
single_threaded: self.single_threaded,
|
threads: self.threads,
|
||||||
|
|
||||||
formats: vec![],
|
formats: vec![],
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +102,7 @@ pub struct Downloader {
|
||||||
subtitle_sort: Option<Vec<Locale>>,
|
subtitle_sort: Option<Vec<Locale>>,
|
||||||
|
|
||||||
force_hardsub: bool,
|
force_hardsub: bool,
|
||||||
single_threaded: bool,
|
threads: Option<usize>,
|
||||||
|
|
||||||
formats: Vec<DownloadFormat>,
|
formats: Vec<DownloadFormat>,
|
||||||
}
|
}
|
||||||
|
|
@ -575,9 +575,9 @@ impl Downloader {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only use 1 CPU (core?) if `single-threaded` option is enabled
|
// If `threads` is specified, use that many CPU cores(?).
|
||||||
let cpus = if self.single_threaded {
|
let cpus = if let Some(threads) = self.threads {
|
||||||
1
|
threads
|
||||||
} else {
|
} else {
|
||||||
num_cpus::get()
|
num_cpus::get()
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue