rusty_ytdl 0.2.0

A Rust library for Youtube video downloader
Documentation

rusty_ytdl

crates.io Released API docs

Youtube downloading module written with pure Rust. Download videos blazing-fast without getting stuck on Youtube download speed (Downloads 20MB video files in just 10 seconds!)

Overview

Roadmap

  • download normal videos
  • download live videos
  • asynchronous API
  • blocking API
  • Proxy options
  • Cookie options
  • full video info deserialization
  • CLI
  • testing suite
  • benchmarks

Usage

use rusty_ytdl::info::download;
use rusty_ytdl::structs::DownloadOptions;

#[tokio::main]
async fn main() {
  let video_url = "https://www.youtube.com/watch?v=FZ8BxMU3BYc"; // FZ8BxMU3BYc works too!
  let video_buffer: Vec<u8> = download(video_url,None, DownloadOptions::default()).await.unwrap();

  // Do what you want whit video buffer vector
  println!("{:#?}",video_buffer);
}

or get only video informations

use rusty_ytdl::info::get_info;
use rusty_ytdl::utils::choose_format;
use rusty_ytdl::structs::VideoOptions;

#[tokio::main]
async fn main() {
  let video_url = "https://www.youtube.com/watch?v=FZ8BxMU3BYc"; // FZ8BxMU3BYc works too!
  let video_info = get_info(video_url,None).await;
  // Also works with live videos!!

  println!("{:#?}",video_info);
  /*
  VideoInfo {
    ...
    video_details: VideoDetails,
    formats: Vec<serde_json::Value>,
    related_videos: Vec<serde_json::Value>
  }
  */

  let video_options = VideoOptions::default();
  let format = choose_format(&video_info.unwrap().formats,&video_options);

  // Get a format by VideoOptions filter parameter
  println!("{:#?}",format);
}

Limitations

rusty-ytdl cannot download videos that fall into the following

  • Regionally restricted (requires a proxy)
  • Private (if you have access, requires cookies)
  • Rentals (if you have access, requires cookies)
  • YouTube Premium content (if you have access, requires cookies)
  • Only HLS Livestreams are currently supported. Other formats not will be fetch

Generated download links are valid for 6 hours, and may only be downloadable from the same IP address.

Installation

cargo add rusty_ytdl

Or add the following to your Cargo.toml file:

[dependencies]

rusty_ytdl = "0.1.0"