Expand description
ytdown — a Rust library mirroring yt-dlp’s core functionality.
Resolve media URLs into metadata and formats, select a format, download it.
A companion CLI lives in the ytdown-cli crate (binary ytdown).
§Quickstart
use std::path::Path;
use ytdown::Ytdown;
#[tokio::main]
async fn main() -> ytdown::Result<()> {
let yt = Ytdown::builder().build()?;
let info = yt.resolve("https://youtu.be/dQw4w9WgXcQ").await?;
if let ytdown::MediaInfo::Single(video) = info {
let fmt = video.formats().best_progressive()?;
yt.download(fmt, Path::new("out.mp4"))
.progress(|p| {
if let Some(pct) = p.percent() {
eprintln!("{pct:.1}%");
}
})
.await?;
}
Ok(())
}Re-exports§
pub use download::DownloadOptions;pub use download::Progress;pub use error::Error;pub use error::Result;pub use extractor::Extractor;pub use extractor::ExtractorContext;pub use extractor::Registry;pub use format::FormatSelector;pub use types::*;
Modules§
- download
- Downloading resolved formats to disk. Downloading resolved formats to disk.
- error
- Error types for the crate.
- extractor
- Extractor trait and registry: URL-to-media dispatch.
- format
- Format selection over a video’s available representations. Format selection over a video’s available representations.
- types
- Core media types: the shared data contract for the crate.
Structs§
- Download
Builder - A configurable, awaitable download of one format to a path.
- Ytdown
- The library entry point: resolves URLs into media and downloads formats.
- Ytdown
Builder - Builder for
Ytdown.