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

source

pub fn new(url: impl Into<String>) -> Self

Create a new builder.

source

pub fn search_for(options: &SearchOptions) -> Self

Performs a search with the given search options.

source

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.

source

pub fn format<S: Into<String>>(&mut self, format: S) -> &mut Self

Set the -f command line option.

source

pub fn flat_playlist(&mut self, flat_playlist: bool) -> &mut Self

Set the --flat-playlist command line flag.

source

pub fn socket_timeout<S: Into<String>>( &mut self, socket_timeout: S ) -> &mut Self

Set the --socket-timeout command line flag.

source

pub fn user_agent<S: Into<String>>(&mut self, user_agent: S) -> &mut Self

Set the --user-agent command line flag.

source

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.

source

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

source

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

source

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

source

pub fn referer<S: Into<String>>(&mut self, referer: S) -> &mut Self

Set the --referer command line flag.

source

pub fn all_formats(&mut self, all_formats: bool) -> &mut Self

Set the --all-formats command line flag.

source

pub fn auth<S: Into<String>>(&mut self, username: S, password: S) -> &mut Self

Set the -u and -p command line flags.

source

pub fn cookies<S: Into<String>>(&mut self, cookie_path: S) -> &mut Self

Specify a file with cookies in Netscape cookie format.

source

pub fn cookies_from_browser<S: Into<String>>( &mut self, browser_name: S, browser_keyring: Option<S>, browser_profile: Option<S>, browser_container: Option<S> ) -> &mut Self

Set the --cookies-from-browser command line flag.

source

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)

source

pub fn extract_audio(&mut self, extract_audio: bool) -> &mut Self

Set the --extract-audio command line flag.

source

pub fn playlist_items(&mut self, index: u32) -> &mut Self

Set the --playlist-items command line flag.

source

pub fn max_downloads(&mut self, max_downloads: u32) -> &mut Self

Set the --max-downloads command line flag.

source

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.

source

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)

source

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)

source

pub fn ignore_errors(&mut self, arg: bool) -> &mut Self

Specify whether to ignore errors (exit code & flag)

source

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.

source

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.

source

pub async fn run_async(&self) -> Result<YoutubeDlOutput, Error>

Run yt-dlp asynchronously with the arguments specified through the builder.

source

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.

source

pub fn download_to(&self, folder: impl AsRef<Path>) -> Result<(), Error>

Download the file to the specified destination folder.

source

pub async fn download_to_async( &self, folder: impl AsRef<Path> ) -> Result<(), Error>

Download the file to the specified destination folder asynchronously.

Trait Implementations§

source§

impl Clone for YoutubeDl

source§

fn clone(&self) -> YoutubeDl

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for YoutubeDl

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more