mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Make --threads usize with a default value
This commit is contained in:
parent
00e7d792b9
commit
d138a1f233
3 changed files with 10 additions and 11 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 = "Override the number of threads used to download")]
|
#[arg(help = "The number of threads used to download")]
|
||||||
#[arg(short, long)]
|
#[arg(short, long, default_value_t = num_cpus::get())]
|
||||||
pub(crate) threads: Option<usize>,
|
pub(crate) threads: usize,
|
||||||
|
|
||||||
#[arg(help = "Crunchyroll series url(s)")]
|
#[arg(help = "Crunchyroll series url(s)")]
|
||||||
#[arg(required = true)]
|
#[arg(required = true)]
|
||||||
|
|
|
||||||
|
|
@ -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 = "Override the number of threads used to download")]
|
#[arg(help = "The number of threads used to download")]
|
||||||
#[arg(short, long)]
|
#[arg(short, long, default_value_t = num_cpus::get())]
|
||||||
pub(crate) threads: Option<usize>,
|
pub(crate) threads: 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)]
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
threads: Option<usize>,
|
threads: 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,
|
||||||
threads: None,
|
threads: num_cpus::get(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ pub struct Downloader {
|
||||||
subtitle_sort: Option<Vec<Locale>>,
|
subtitle_sort: Option<Vec<Locale>>,
|
||||||
|
|
||||||
force_hardsub: bool,
|
force_hardsub: bool,
|
||||||
threads: Option<usize>,
|
threads: usize,
|
||||||
|
|
||||||
formats: Vec<DownloadFormat>,
|
formats: Vec<DownloadFormat>,
|
||||||
}
|
}
|
||||||
|
|
@ -575,8 +575,7 @@ impl Downloader {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
// If `threads` is specified, use that many CPU cores(?).
|
let cpus = self.threads;
|
||||||
let cpus = self.threads.unwrap_or(num_cpus::get());
|
|
||||||
let mut segs: Vec<Vec<VariantSegment>> = Vec::with_capacity(cpus);
|
let mut segs: Vec<Vec<VariantSegment>> = Vec::with_capacity(cpus);
|
||||||
for _ in 0..cpus {
|
for _ in 0..cpus {
|
||||||
segs.push(vec![])
|
segs.push(vec![])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue