Struct youtube_dl::YoutubeDl
source · pub struct YoutubeDl { /* private fields */ }
Expand description
A builder to create a youtube-dl
command to execute.
Implementations§
source§impl YoutubeDl
impl YoutubeDl
sourcepub fn search_for(options: &SearchOptions) -> Self
pub fn search_for(options: &SearchOptions) -> Self
Performs a search with the given search options.
sourcepub fn youtube_dl_path<P: AsRef<Path>>(
&mut self,
youtube_dl_path: P
) -> &mut Self
pub fn youtube_dl_path<P: AsRef<Path>>( &mut self, youtube_dl_path: P ) -> &mut Self
Set the path to the youtube-dl
or `yt-dlp executable.
sourcepub fn format<S: Into<String>>(&mut self, format: S) -> &mut Self
pub fn format<S: Into<String>>(&mut self, format: S) -> &mut Self
Set the -f
command line option.
sourcepub fn flat_playlist(&mut self, flat_playlist: bool) -> &mut Self
pub fn flat_playlist(&mut self, flat_playlist: bool) -> &mut Self
Set the --flat-playlist
command line flag.
sourcepub fn socket_timeout<S: Into<String>>(
&mut self,
socket_timeout: S
) -> &mut Self
pub fn socket_timeout<S: Into<String>>( &mut self, socket_timeout: S ) -> &mut Self
Set the --socket-timeout
command line flag.
sourcepub fn user_agent<S: Into<String>>(&mut self, user_agent: S) -> &mut Self
pub fn user_agent<S: Into<String>>(&mut self, user_agent: S) -> &mut Self
Set the --user-agent
command line flag.
sourcepub fn playlist_reverse(&mut self, playlist_reverse: bool) -> &mut Self
pub fn playlist_reverse(&mut self, playlist_reverse: bool) -> &mut Self
Set the --playlist-reverse
flag. Useful with break-on-reject and date_before
for faster queries.
sourcepub fn date<S: Into<String>>(&mut self, date_string: S) -> &mut Self
pub fn date<S: Into<String>>(&mut self, date_string: S) -> &mut Self
Sets the --date
command line flag only downloading/viewing videos on this date
sourcepub fn date_before<S: Into<String>>(&mut self, date_string: S) -> &mut Self
pub fn date_before<S: Into<String>>(&mut self, date_string: S) -> &mut Self
Set the --datebefore
flag only downloading/viewing videos on or before this date
sourcepub fn date_after<S: Into<String>>(&mut self, date_string: S) -> &mut Self
pub fn date_after<S: Into<String>>(&mut self, date_string: S) -> &mut Self
Set the --dateafter
flag only downloading/viewing vidieos on or after this date
sourcepub fn referer<S: Into<String>>(&mut self, referer: S) -> &mut Self
pub fn referer<S: Into<String>>(&mut self, referer: S) -> &mut Self
Set the --referer
command line flag.
sourcepub fn all_formats(&mut self, all_formats: bool) -> &mut Self
pub fn all_formats(&mut self, all_formats: bool) -> &mut Self
Set the --all-formats
command line flag.
sourcepub fn auth<S: Into<String>>(&mut self, username: S, password: S) -> &mut Self
pub fn auth<S: Into<String>>(&mut self, username: S, password: S) -> &mut Self
Set the -u
and -p
command line flags.
Specify a file with cookies in Netscape cookie format.
Set the --cookies-from-browser
command line flag.
sourcepub fn process_timeout(&mut self, timeout: Duration) -> &mut Self
pub fn process_timeout(&mut self, timeout: Duration) -> &mut 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)
sourcepub fn extract_audio(&mut self, extract_audio: bool) -> &mut Self
pub fn extract_audio(&mut self, extract_audio: bool) -> &mut Self
Set the --extract-audio
command line flag.
sourcepub fn playlist_items(&mut self, index: u32) -> &mut Self
pub fn playlist_items(&mut self, index: u32) -> &mut Self
Set the --playlist-items
command line flag.
sourcepub fn max_downloads(&mut self, max_downloads: u32) -> &mut Self
pub fn max_downloads(&mut self, max_downloads: u32) -> &mut Self
Set the --max-downloads
command line flag.
sourcepub fn extra_arg<S: Into<String>>(&mut self, arg: S) -> &mut Self
pub fn extra_arg<S: Into<String>>(&mut self, arg: S) -> &mut Self
Add an additional custom CLI argument.
This allows specifying arguments that are not covered by other configuration methods.
sourcepub fn output_template<S: Into<String>>(&mut self, arg: S) -> &mut Self
pub fn output_template<S: Into<String>>(&mut self, arg: S) -> &mut Self
Specify the filename template. Only relevant for downloading. (referred to as “output template” by youtube-dl docs)
sourcepub fn output_directory<S: Into<String>>(&mut self, arg: S) -> &mut Self
pub fn output_directory<S: Into<String>>(&mut self, arg: S) -> &mut Self
Specify the output directory. Only relevant for downloading.
(the -P
command line switch)
sourcepub fn ignore_errors(&mut self, arg: bool) -> &mut Self
pub fn ignore_errors(&mut self, arg: bool) -> &mut Self
Specify whether to ignore errors (exit code & flag)
sourcepub fn run(&self) -> Result<YoutubeDlOutput, Error>
pub fn run(&self) -> Result<YoutubeDlOutput, Error>
Run yt-dlp with the arguments specified through the builder and parse its
JSON ouput into YoutubeDlOutput
. Note: This can fail when the JSON output
is not compatible with the struct definitions in this crate.
sourcepub fn run_raw(&self) -> Result<Value, Error>
pub fn run_raw(&self) -> Result<Value, Error>
Run yt-dlp with the arguments through the builder and parse its JSON output
into a serde_json::Value
. This is meant as a fallback for when the JSON
output is not compatible with the struct definitions in this crate.
sourcepub async fn run_async(&self) -> Result<YoutubeDlOutput, Error>
pub async fn run_async(&self) -> Result<YoutubeDlOutput, Error>
Run yt-dlp asynchronously with the arguments specified through the builder.
sourcepub async fn run_raw_async(&self) -> Result<Value, Error>
pub async fn run_raw_async(&self) -> Result<Value, Error>
Run yt-dlp asynchronously with the arguments through the builder and parse its JSON output
into a serde_json::Value
. This is meant as a fallback for when the JSON
output is not compatible with the struct definitions in this crate.