Crates.io | ytd-rs |
lib.rs | ytd-rs |
version | 0.1.7 |
source | src |
created_at | 2021-05-12 03:33:55.510155 |
updated_at | 2022-04-05 16:25:33.337427 |
description | A simple wrapper for youtube-dl. Youtube-dl has to be installed on the system |
homepage | https://github.com/Nirusu99/ytd-rs |
repository | https://github.com/Nirusu99/ytd-rs |
max_upload_size | |
id | 396400 |
size | 11,376 |
This is a simple wrapper for youtube-dl in rust.
use ytd_rs::{YoutubeDL, Arg};
use std::path::PathBuf;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
// youtube-dl arguments quietly run process and to format the output
// one doesn't take any input and is an option, the other takes the desired output format as input
let args = vec![Arg::new("--quiet"), Arg::new_with_arg("--output", "%(title).90s.%(ext)s")];
let link = "https://www.youtube.com/watch?v=uTO0KnDsVH0";
let path = PathBuf::from("./path/to/download/directory");
let ytd = YoutubeDL::new(&path, args, link)?;
// start download
let download = ytd.download()?;
// print out the download path
println!("Your download: {}", download.output_dir().to_string_lossy())
Ok(())
}