Skip to content

Commit

Permalink
Input: accept additional user arguments for yt-dlp (#268)
Browse files Browse the repository at this point in the history
This PR makes it possible to give additional user-specified arguments to spawned yt-dlp processes.
  • Loading branch information
Henauxg authored Nov 24, 2024
1 parent fe46da6 commit 71535c5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/input/sources/ytdl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub struct YoutubeDl {
client: Client,
metadata: Option<AuxMetadata>,
query: QueryType,
user_args: Vec<String>,
}

impl YoutubeDl {
Expand All @@ -61,6 +62,7 @@ impl YoutubeDl {
client,
metadata: None,
query: QueryType::Url(url),
user_args: Vec::new(),
}
}

Expand All @@ -80,9 +82,17 @@ impl YoutubeDl {
client,
metadata: None,
query: QueryType::Search(query),
user_args: Vec::new(),
}
}

/// Sets additional arguments for the "yt-dlp" process
#[must_use]
pub fn user_args(mut self, user_args: Vec<String>) -> Self {
self.user_args = user_args;
self
}

/// Runs a search for the given query, returning a list of up to `n_results`
/// possible matches which are `AuxMetadata` objects containing a valid URL.
///
Expand Down Expand Up @@ -123,6 +133,7 @@ impl YoutubeDl {
];

let mut output = Command::new(self.program)
.args(self.user_args.clone())
.args(ytdl_args)
.output()
.await
Expand Down

0 comments on commit 71535c5

Please sign in to comment.