Crates.io | ytdlp_bindings |
lib.rs | ytdlp_bindings |
version | 0.1.0 |
source | src |
created_at | 2024-11-09 16:04:41.275665 |
updated_at | 2024-11-09 16:04:41.275665 |
description | ytdlp cli bindings |
homepage | |
repository | |
max_upload_size | |
id | 1442178 |
size | 28,905 |
Rust bindings for yt-dlp
, a YouTube video and audio downloader.
The following features are enabled by default:
yt-dlp-vendored
: When enabled, the crate will use a vendored version of yt-dlp.
When disabled, you need to provide the path to the yt-dlp binary when creating an instance of YtDlp.audio-processing
: Adds downloaded audio processing capabilities to YtDlp via vendored ffmpeg (v7*)video-processing
: Adds downloaded video processing capabilities to YtDlp also via vendored ffmpeg (v7*)vtt-processing
: Adds downloaded web VTT (Video Text Tracks) file processing capabilities to YtDlpAdd this to your Cargo.toml
:
[dependencies]
ytdlp-bindings = { git="https://gitub.com/c12i/bunge-bits", package = "ytdlp_bindings" }
By default, this crate uses a vendored yt-dlp
binary. If you want to use your system's yt-dlp installation, disable the default features:
[dependencies]
ytdlp-bindings = { git="https://gitub.com/c12i/bunge-bits", package = "ytdlp_bindings", default-features = false }
use ytdlp_bindings::YtDlp;
use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let ytdlp = YtDlp::new()?;
ytdlp.download_video(
"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
Path::new("video.%(ext)s")
)?;
Ok(())
}
use ytdlp_bindings::YtDlp;
use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let ytdlp = YtDlp::new()?;
ytdlp.download_playlist(
"https://www.youtube.com/playlist?list=PLv3TTBr1W_9tppikBxAE_G6qjWdBljBHJ",
Path::new("playlist/%(playlist_index)s-%(title)s.%(ext)s")
)?;
Ok(())
}
use ytdlp_bindings::{YtDlp, VttProcessor};
use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let ytdlp = YtDlp::new()?;
// Download subtitles
ytdlp.download_auto_sub(
"https://www.youtube.com/watch?v=dQw4w9WgXcQ",
Path::new("subtitles.vtt")
)?;
// Process subtitles
let subtitles = ytdlp.process_vtt_file("subtitles.vtt")?;
for entry in subtitles {
println!("{:?}", entry);
}
Ok(())
}
Contributions are welcome! Please feel free to submit a Pull Request. I am especially open to extending the video/ audio / vtt processing capabilities which at the moment only contain methods that are required by the bunge-bits project project.
This project is licensed under the MIT License - see the LICENSE file for details.