[][src]Struct rustube::Video

pub struct Video { /* fields omitted */ }

A YouTube downloader, which allows you to download all available formats and qualities of a YouTube video. Each instance of Video represents an existing, available, and downloadable video.

This type is the easiest way to download a video. There are tow major ways of constructing an instance of Video:

  1. By using the asynchronous Video::from_* methods. These methods will take some kind of video-identifier, like an Url or an Id, will then internally download the necessary video information and finally descramble it.
  2. By calling [VideoDescrambler::descramble]. Since a [VideoDescrambler] already contains the necessary video information, and just need to descramble it, no requests are performed.

Examples

const URL: &str = "https://youtube.com/watch?iv=5jlI4uzZGjU";
let url = Url::parse(URL).unwrap();

let video: Video = Video::from_url(&url).await.unwrap();
  • Constructing using [VideoDescrambler::descramble]
const URL: &str = "https://youtube.com/watch?iv=5jlI4uzZGjU";
let url = Url::parse(URL).unwrap();

let fetcher: VideoFetcher = VideoFetcher::from_url(&url).unwrap();
let descrambler: VideoDescrambler = fetcher.fetch().await.unwrap();  
let video: Video = descrambler.descramble().unwrap();
  • Construction using chained calls
const URL: &str = "https://youtube.com/watch?iv=5jlI4uzZGjU";
let url = Url::parse(URL).unwrap();

let video: Video = VideoFetcher::from_url(&url)
   .unwrap()
   .fetch()
   .await
   .unwrap()  
   .descramble()
   .unwrap();
  • Downloading a video using an existing Video instance
let video_path = video
   .streams()
   .iter()
   .filter(|stream| stream.mime.subtype() == "mp4" && stream.width.is_some())
   .max_by(|stream0, stream1| stream0.width.unwrap().cmp(&stream1.width.unwrap()))
   .unwrap()
   .download()
   .await
   .unwrap();

println!(
   "The video with the id `{}` was downloaded to: `{:?}`",
   video.id(),
   video_path 
);

Implementations

impl Video[src]

pub async fn from_url(url: &Url) -> Result<Self>[src]

Constructs an instance of Video from a Url

pub async fn from_id(id: IdBuf) -> Result<Self>[src]

pub fn video_info(&self) -> &VideoInfo[src]

pub fn streams(&self) -> &Vec<Stream>[src]

pub fn into_streams(self) -> Vec<Stream>[src]

pub fn video_details(&self) -> Arc<VideoDetails>[src]

pub fn id(&self) -> Id<'_>[src]

pub fn title(&self) -> &str[src]

pub fn is_age_restricted(&self) -> bool[src]

pub fn best_quality(&self) -> Option<&Stream>[src]

pub fn worst_quality(&self) -> Option<&Stream>[src]

pub fn best_video(&self) -> Option<&Stream>[src]

pub fn worst_video(&self) -> Option<&Stream>[src]

pub fn best_audio(&self) -> Option<&Stream>[src]

pub fn worst_audio(&self) -> Option<&Stream>[src]

Trait Implementations

impl Clone for Video[src]

impl Debug for Video[src]

impl Display for Video[src]

impl PartialEq<Video> for Video[src]

impl StructuralPartialEq for Video[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.