yt_info

Crates.ioyt_info
lib.rsyt_info
version0.3.2
sourcesrc
created_at2019-08-16 17:59:48.752421
updated_at2019-08-16 19:05:28.881362
descriptionRust library to download YouTube content and retrieve metadata
homepage
repositoryhttps://github.com/kubasitck/yt-info
max_upload_size
id157422
size22,966
Jakub Tomana (kubastick)

documentation

README

yt_info

Rust Toolchain Crates.io Docs.rs

Rust library to fetch YouTube content and retrieve metadata. Fork of rafy-rs

Installation

Put the below in your Cargo.toml

[dependencies]

yt_info = "0.3.1"

Usage Examples

use yt_info::VideoInfo;
use std::fs::File;
use std::io;

fn main() {
    let youtube_token = env!("YOUTUBE_TOKEN");

    let video = VideoInfo::new(youtube_token,"https://www.youtube.com/watch?v=C0DPdy98e4c").unwrap();
    let streams = video.streams;
    let stream = &streams[0];

    let filename = format!("{}-stream.{}",&video.title,&stream.extension);

    let mut file = File::create(filename).unwrap();
    let mut stream_reader = stream.get_reader().unwrap();

    io::copy(&mut stream_reader,&mut file).unwrap();
}

For more examples check out the Documentation.

Limitations

  • This library won't be able to fetch audiostreams and videostreams for unpopular videos, because YouTube does not generate separate streams for unpopular videos. However, it will still be able to fetch normal streams.

  • Since this library does not depend on youtube-dl, there are some more things (not mentioning here) that we'll be missing out.

Running Tests

$ cargo test

Contributing

All pull requests all welcome

Thanks

The basic method of extracting streams was stolen from rust-youtube-downloader by smoqadam.

License

The MIT License

Commit count: 0

cargo fmt