diff --git a/src/lib.rs b/src/lib.rs index 5dab6f2..ef0e2ce 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -262,6 +262,7 @@ pub struct YoutubeDl { date: Option, extract_audio: bool, playlist_items: Option, + max_downloads: Option, extra_args: Vec, output_template: Option, output_directory: Option, @@ -292,6 +293,7 @@ impl YoutubeDl { playlist_reverse: false, extract_audio: false, playlist_items: None, + max_downloads: None, extra_args: Vec::new(), output_template: None, output_directory: None, @@ -385,7 +387,7 @@ impl YoutubeDl { self } - /// Specify a file with cookies in Netscape cookie format. + /// Set the `--cookies-from-browser` command line flag. pub fn cookies_from_browser>(&mut self, browser_name: S) -> &mut Self { self.cookies_from_browser = Some(browser_name.into()); self @@ -410,6 +412,12 @@ impl YoutubeDl { self } + /// Set the `--max-downloads` command line flag. + pub fn max_downloads(&mut self, max_downloads: u32) -> &mut Self { + self.max_downloads = Some(max_downloads.to_string()); + self + } + /// Add an additional custom CLI argument. /// /// This allows specifying arguments that are not covered by other @@ -508,6 +516,11 @@ impl YoutubeDl { args.push(playlist_items); } + if let Some(max_downloads) = &self.max_downloads { + args.push("--max-downloads"); + args.push(max_downloads); + } + if let Some(output_template) = &self.output_template { args.push("-o"); args.push(output_template);