pub struct YoutubeDl<'a> { /* private fields */ }Expand description
A lazily instantiated call to download a file, finding its URL via youtube-dl.
By default, this uses yt-dlp and is backed by an HttpRequest. This handler
attempts to find the best audio-only source (typically WebM, enabling low-cost
Opus frame passthrough).
Implementations§
Source§impl<'a> YoutubeDl<'a>
impl<'a> YoutubeDl<'a>
Sourcepub fn new(client: Client, url: impl Into<Cow<'a, str>>) -> Self
pub fn new(client: Client, url: impl Into<Cow<'a, str>>) -> Self
Creates a lazy request to select an audio stream from url, using “yt-dlp”.
This requires a reqwest client: ideally, one should be created and shared between all requests.
Sourcepub fn new_ytdl_like(
program: &'a str,
client: Client,
url: impl Into<Cow<'a, str>>,
) -> Self
pub fn new_ytdl_like( program: &'a str, client: Client, url: impl Into<Cow<'a, str>>, ) -> Self
Creates a lazy request to select an audio stream from url as in new, using program.
Sourcepub fn new_search(client: Client, query: impl Into<Cow<'a, str>>) -> Self
pub fn new_search(client: Client, query: impl Into<Cow<'a, str>>) -> Self
Creates a request to search youtube for an optionally specified number of videos matching query,
using “yt-dlp”.
Sourcepub fn new_search_ytdl_like(
program: &'a str,
client: Client,
query: impl Into<Cow<'a, str>>,
) -> Self
pub fn new_search_ytdl_like( program: &'a str, client: Client, query: impl Into<Cow<'a, str>>, ) -> Self
Creates a request to search youtube for an optionally specified number of videos matching query,
using program.
Sourcepub fn user_args(self, user_args: Vec<String>) -> Self
pub fn user_args(self, user_args: Vec<String>) -> Self
Sets additional arguments for the “yt-dlp” process
Sourcepub async fn search(
&mut self,
n_results: Option<usize>,
) -> Result<impl Iterator<Item = AuxMetadata>, AudioStreamError>
pub async fn search( &mut self, n_results: Option<usize>, ) -> Result<impl Iterator<Item = AuxMetadata>, AudioStreamError>
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.
Returns up to 5 matches by default.
Sourcepub async fn query(
&mut self,
n_results: usize,
) -> Result<Vec<YoutubeDlOutput>, AudioStreamError>
pub async fn query( &mut self, n_results: usize, ) -> Result<Vec<YoutubeDlOutput>, AudioStreamError>
Runs a search for the given query, returning a list of up to n_results
possible matches.
Sourcepub async fn get_stream(
&self,
result: &YoutubeDlOutput,
) -> Result<AudioStream<Box<dyn MediaSource>>, AudioStreamError>
pub async fn get_stream( &self, result: &YoutubeDlOutput, ) -> Result<AudioStream<Box<dyn MediaSource>>, AudioStreamError>
Get the audio stream from a YoutubeDlOutput.