diff --git a/Cargo.toml b/Cargo.toml index 4ebf92c..bdf6ebd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ytd-rs" -version = "0.1.4" +version = "0.1.5" authors = ["Nils Pukropp "] edition = "2018" license-file ="LICENSE" @@ -9,6 +9,10 @@ homepage = "https://github.com/Nirusu99/ytd-rs" repository = "https://github.com/Nirusu99/ytd-rs" readme = "README.md" +[features] +yt-dlp = [] +youtube-dlc = [] + [dependencies] regex = "1.5" diff --git a/src/lib.rs b/src/lib.rs index a8c10f7..38cbacf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,14 @@ use std::{path::Path, process::Command}; type Result = std::result::Result; +const YOUTUBE_DL_COMMAND: &str = if cfg!(feature = "youtube-dlc") { + "youtube-dlc" +} else if cfg!(feature = "yt-dlp") { + "yt-dlp" +} else { + "youtube-dl" +}; + /// A structure that represents an argument of a youtube-dl command. /// /// There are two different kinds of Arg: @@ -246,7 +254,7 @@ impl YoutubeDL { } fn spawn_youtube_dl(&self) -> Result { - let mut cmd = Command::new("youtube-dl"); + let mut cmd = Command::new(YOUTUBE_DL_COMMAND); cmd.current_dir(&self.path) .env("LC_ALL", "en_US.UTF-8") .stdout(Stdio::piped())