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)]
|
||||
pub(crate) yes: bool,
|
||||
|
||||
#[arg(help = "Download using only one thread")]
|
||||
#[arg(short = 't', long, default_value_t = false)]
|
||||
pub(crate) single_threaded: bool,
|
||||
#[arg(help = "Override the number of threads used to download")]
|
||||
#[arg(short, long)]
|
||||
pub(crate) threads: Option<usize>,
|
||||
|
||||
#[arg(help = "Crunchyroll series url(s)")]
|
||||
#[arg(required = true)]
|
||||
|
|
@ -163,7 +163,7 @@ impl Execute for Archive {
|
|||
.output_format(Some("matroska".to_string()))
|
||||
.audio_sort(Some(self.audio.clone()))
|
||||
.subtitle_sort(Some(self.subtitle.clone()))
|
||||
.single_threaded(self.single_threaded);
|
||||
.threads(self.threads);
|
||||
|
||||
for single_formats in single_format_collection.into_iter() {
|
||||
let (download_formats, mut format) = get_format(&self, &single_formats).await?;
|
||||
|
|
|
|||
|
|
@ -80,9 +80,9 @@ pub struct Download {
|
|||
#[arg(long, default_value_t = false)]
|
||||
pub(crate) force_hardsub: bool,
|
||||
|
||||
#[arg(help = "Download using only one thread")]
|
||||
#[arg(short = 't', long, default_value_t = false)]
|
||||
pub(crate) single_threaded: bool,
|
||||
#[arg(help = "Override the number of threads used to download")]
|
||||
#[arg(short, long)]
|
||||
pub(crate) threads: Option<usize>,
|
||||
|
||||
#[arg(help = "Url(s) to Crunchyroll episodes or series")]
|
||||
#[arg(required = true)]
|
||||
|
|
@ -154,7 +154,7 @@ impl Execute for Download {
|
|||
None
|
||||
})
|
||||
.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() {
|
||||
// the vec contains always only one item
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ pub struct DownloadBuilder {
|
|||
audio_sort: Option<Vec<Locale>>,
|
||||
subtitle_sort: Option<Vec<Locale>>,
|
||||
force_hardsub: bool,
|
||||
single_threaded: bool,
|
||||
threads: Option<usize>,
|
||||
}
|
||||
|
||||
impl DownloadBuilder {
|
||||
|
|
@ -62,7 +62,7 @@ impl DownloadBuilder {
|
|||
audio_sort: None,
|
||||
subtitle_sort: None,
|
||||
force_hardsub: false,
|
||||
single_threaded: false,
|
||||
threads: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ impl DownloadBuilder {
|
|||
subtitle_sort: self.subtitle_sort,
|
||||
|
||||
force_hardsub: self.force_hardsub,
|
||||
single_threaded: self.single_threaded,
|
||||
threads: self.threads,
|
||||
|
||||
formats: vec![],
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ pub struct Downloader {
|
|||
subtitle_sort: Option<Vec<Locale>>,
|
||||
|
||||
force_hardsub: bool,
|
||||
single_threaded: bool,
|
||||
threads: Option<usize>,
|
||||
|
||||
formats: Vec<DownloadFormat>,
|
||||
}
|
||||
|
|
@ -575,9 +575,9 @@ impl Downloader {
|
|||
None
|
||||
};
|
||||
|
||||
// Only use 1 CPU (core?) if `single-threaded` option is enabled
|
||||
let cpus = if self.single_threaded {
|
||||
1
|
||||
// If `threads` is specified, use that many CPU cores(?).
|
||||
let cpus = if let Some(threads) = self.threads {
|
||||
threads
|
||||
} else {
|
||||
num_cpus::get()
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue