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

* Add `single-threaded` option to downloading commands

* Replace `--single-threaded` boolean option with `--threads` optional `usize` option

* Simplify `threads` field unwrapping

* Make `--threads` `usize` with a default value
This commit is contained in:
Valentine Briese 2023-10-15 11:52:53 -07:00 committed by GitHub
parent 13335c020b
commit bbb5a78765
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 166 additions and 149 deletions

View file

@ -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>,
@ -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