Input: accept additional user arguments for yt-dlp (#268)
This PR makes it possible to give additional user-specified arguments to spawned yt-dlp processes.
This commit is contained in:
@@ -39,6 +39,7 @@ pub struct YoutubeDl {
|
|||||||
client: Client,
|
client: Client,
|
||||||
metadata: Option<AuxMetadata>,
|
metadata: Option<AuxMetadata>,
|
||||||
query: QueryType,
|
query: QueryType,
|
||||||
|
user_args: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl YoutubeDl {
|
impl YoutubeDl {
|
||||||
@@ -61,6 +62,7 @@ impl YoutubeDl {
|
|||||||
client,
|
client,
|
||||||
metadata: None,
|
metadata: None,
|
||||||
query: QueryType::Url(url),
|
query: QueryType::Url(url),
|
||||||
|
user_args: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,9 +82,17 @@ impl YoutubeDl {
|
|||||||
client,
|
client,
|
||||||
metadata: None,
|
metadata: None,
|
||||||
query: QueryType::Search(query),
|
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`
|
/// 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.
|
/// possible matches which are `AuxMetadata` objects containing a valid URL.
|
||||||
///
|
///
|
||||||
@@ -123,6 +133,7 @@ impl YoutubeDl {
|
|||||||
];
|
];
|
||||||
|
|
||||||
let mut output = Command::new(self.program)
|
let mut output = Command::new(self.program)
|
||||||
|
.args(self.user_args.clone())
|
||||||
.args(ytdl_args)
|
.args(ytdl_args)
|
||||||
.output()
|
.output()
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in New Issue
Block a user