Skip to content

Commit

Permalink
added --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 e85d931 commit a8f98f3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ pub struct YoutubeDl {
all_formats: bool,
auth: Option<(String, String)>,
cookies: Option<String>,
cookies_from_browser: Option<String>,
user_agent: Option<String>,
referer: Option<String>,
url: String,
Expand Down Expand Up @@ -281,6 +282,7 @@ impl YoutubeDl {
all_formats: false,
auth: None,
cookies: None,
cookies_from_browser: None,
user_agent: None,
referer: None,
process_timeout: None,
Expand Down Expand Up @@ -383,6 +385,12 @@ impl YoutubeDl {
self
}

/// Specify a file with cookies in Netscape cookie format.
pub fn cookies_from_browser<S: Into<String>>(&mut self, browser_name: S) -> &mut Self {
self.cookies_from_browser = Some(browser_name.into());
self
}

/// Set a process-level timeout for youtube-dl. (this controls the maximum overall duration
/// the process may take, when it times out, `Error::ProcessTimeout` is returned)
pub fn process_timeout(&mut self, timeout: Duration) -> &mut Self {
Expand Down Expand Up @@ -476,6 +484,11 @@ impl YoutubeDl {
args.push(cookie_path);
}

if let Some(browser_name) = &self.cookies_from_browser {
args.push("--cookies-from-browser");
args.push(browser_name);
}

if let Some(user_agent) = &self.user_agent {
args.push("--user-agent");
args.push(user_agent);
Expand Down

0 comments on commit a8f98f3

Please sign in to comment.