Table of Contents
A Rust library for downloading videos from Youtube, choosing between all the available formats.
Add ytb-downloader
to Cargo.toml and import it:
use ytb-downloader::*;
Note that the library is uses async/await so
tokio = { version = "1.27.0", features = ["macros", "rt-multi-thread", "fs"] }
is needed as well. These are the necessary features of Tokio for ytb-downloader
but you can add more if you need to.
The examples below use error_chain for error handling, that's why the Result doesn't also have an error type parameter.
Downloading a video using the download_video!
macro:
```rust
use ytb_downloader::; use errors::;
[tokio::main] async fn main() -> Result<()> { let source = getavailablesources("https://www.youtube.com/watch?v=pqhfyrWBEA").await? .intoiter().next().unwrap(); const OUTPUTFILE: &str = "download.m4a"; downloadvideo!(&source, OUTPUT_FILE).await; Ok(()) } ```
Downloading a video using the actual function call: ```rust use ytb_downloader::; use errors::;
[tokio::main] async fn main() -> Result<()> { let source = getavailablesources("https://www.youtube.com/watch?v=pqhfyrWBEA").await? .intoiter().next().unwrap(); const OUTPUTFILE: &str = "download.m4a"; downloadvideo(&source, OUTPUT_FILE, None).await; Ok(()) } ```
Downloading a video with a chunk size of 10240 bytes: ```rust use ytb_downloader::; use errors::;
[tokio::main] async fn main() -> Result<()> { let source = getavailablesources("https://www.youtube.com/watch?v=pqhfyrWBEA").await? .intoiter().next().unwrap(); const OUTPUTFILE: &str = "download.m4a"; downloadvideo(&source, OUTPUT_FILE, Some(10240)).await; Ok(()) } ```
Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)Distributed under the MIT License. See LICENSE.txt
for more information.
Pavlos Smith - paulsmith4561+at+gmail.com