Skip to content

Commit

Permalink
added --max-downloads flag, documented --cookies-from-browser flag
Browse files Browse the repository at this point in the history
  • Loading branch information
AtlasRW committed Mar 4, 2024
1 parent a8f98f3 commit d4f9bd4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ pub struct YoutubeDl {
date: Option<String>,
extract_audio: bool,
playlist_items: Option<String>,
max_downloads: Option<String>,
extra_args: Vec<String>,
output_template: Option<String>,
output_directory: Option<String>,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<S: Into<String>>(&mut self, browser_name: S) -> &mut Self {
self.cookies_from_browser = Some(browser_name.into());
self
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d4f9bd4

Please sign in to comment.