From 5bbf2988a8763ec6ecd04b565fa22d5a6beacd38 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Sun, 18 Jul 2021 18:09:37 +0200 Subject: [PATCH] updated readme --- README.md | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b37e029..cf6c7a6 100644 --- a/README.md +++ b/README.md @@ -4,23 +4,25 @@ This is a simple wrapper for [youtube-dl](https://youtube-dl.org/) in rust. ```rust use ytd_rs::{YoutubeDL, ResultType, Arg}; -// 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 ytd = YoutubeDL::new("./path/to/download/directory", args, link)?; +use std::path::PathBuf; +use std::error::Error; +fn main() -> Result<(), Box> { + // 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(); + // start download + let download = ytd.download(); -// check what the result is and print out the path to the download or the error -match download.result_type() { - ResultType::SUCCESS => println!("Your download: {}", download.output_dir().to_string_lossy()), - ResultType::IOERROR | ResultType::FAILURE => - println!("Couldn't start download: {}", download.output()), -}; + // check what the result is and print out the path to the download or the error + match download.result_type() { + ResultType::SUCCESS => println!("Your download: {}", download.output_dir().to_string_lossy()), + ResultType::IOERROR | ResultType::FAILURE => + println!("Couldn't start download: {}", download.output()), + }; +Ok(()) +} ``` - - - -