[−][src]Struct rustube::Video
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
:
- By using the asynchronous
Video::from_*
methods. These methods will take some kind of video-identifier, like anUrl
or anId
, will then internally download the necessary video information and finally descramble it. - By calling [
VideoDescrambler::descramble
]. Since a [VideoDescrambler
] already contains the necessary video information, and just need to descramble it, no requests are performed.
Examples
- Constructing using
Video::from_url
(orVideo::from_id
) (easiest way)
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
impl !RefUnwindSafe for Video
[src]
impl Send for Video
[src]
impl Sync for Video
[src]
impl Unpin for Video
[src]
impl !UnwindSafe for Video
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,