mirror of
https://github.com/narrrl/ytd-rs.git
synced 2026-11-03 16:41:27 +01:00
updated readme
This commit is contained in:
1 parent
9005a9c647
commit
5bbf2988a8
1 file changed
+19
-17
@@ -4,23 +4,25 @@ This is a simple wrapper for [youtube-dl](https://youtube-dl.org/) in rust.
|
|||||||
|
|
||||||
```rust
|
```rust
|
||||||
use ytd_rs::{YoutubeDL, ResultType, Arg};
|
use ytd_rs::{YoutubeDL, ResultType, Arg};
|
||||||
// youtube-dl arguments quietly run process and to format the output
|
use std::path::PathBuf;
|
||||||
// one doesn't take any input and is an option, the other takes the desired output format as input
|
use std::error::Error;
|
||||||
let args = vec![Arg::new("--quiet"), Arg::new_with_arg("--output", "%(title).90s.%(ext)s")];
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let link = "https://www.youtube.com/watch?v=uTO0KnDsVH0";
|
// youtube-dl arguments quietly run process and to format the output
|
||||||
let ytd = YoutubeDL::new("./path/to/download/directory", args, link)?;
|
// 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
|
// start download
|
||||||
let download = ytd.download();
|
let download = ytd.download();
|
||||||
|
|
||||||
// check what the result is and print out the path to the download or the error
|
// check what the result is and print out the path to the download or the error
|
||||||
match download.result_type() {
|
match download.result_type() {
|
||||||
ResultType::SUCCESS => println!("Your download: {}", download.output_dir().to_string_lossy()),
|
ResultType::SUCCESS => println!("Your download: {}", download.output_dir().to_string_lossy()),
|
||||||
ResultType::IOERROR | ResultType::FAILURE =>
|
ResultType::IOERROR | ResultType::FAILURE =>
|
||||||
println!("Couldn't start download: {}", download.output()),
|
println!("Couldn't start download: {}", download.output()),
|
||||||
};
|
};
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in new issue
Block a user