Offer youtube-dlc as an alternative to youtube-dl (#1)

* Adds youtube-dlc feature.
This commit is contained in:
( ͡° ͜ʖ ͡°)
2020-11-13 17:27:28 -05:00
committed by GitHub
parent a9f8d6c93a
commit 6702520b7c
2 changed files with 8 additions and 1 deletions

View File

@@ -137,6 +137,7 @@ driver = [
"url", "url",
"xsalsa20poly1305", "xsalsa20poly1305",
] ]
youtube-dlc = []
rustls = ["async-tungstenite/tokio-rustls"] rustls = ["async-tungstenite/tokio-rustls"]
native = ["async-tungstenite/tokio-native-tls"] native = ["async-tungstenite/tokio-native-tls"]
serenity-rustls = ["serenity/rustls_backend", "rustls", "gateway", "serenity-deps"] serenity-rustls = ["serenity/rustls_backend", "rustls", "gateway", "serenity-deps"]

View File

@@ -14,6 +14,12 @@ use std::{
use tokio::task; use tokio::task;
use tracing::trace; use tracing::trace;
const YOUTUBE_DL_COMMAND: &str = if cfg!(feature = "youtube-dlc") {
"youtube-dlc"
} else {
"youtube-dl"
};
/// Creates a streamed audio source with `youtube-dl` and `ffmpeg`. /// Creates a streamed audio source with `youtube-dl` and `ffmpeg`.
pub async fn ytdl(uri: &str) -> Result<Input> { pub async fn ytdl(uri: &str) -> Result<Input> {
_ytdl(uri, &[]).await _ytdl(uri, &[]).await
@@ -45,7 +51,7 @@ pub(crate) async fn _ytdl(uri: &str, pre_args: &[&str]) -> Result<Input> {
"-", "-",
]; ];
let mut youtube_dl = Command::new("youtube-dl") let mut youtube_dl = Command::new(YOUTUBE_DL_COMMAND)
.args(&ytdl_args) .args(&ytdl_args)
.stdin(Stdio::null()) .stdin(Stdio::null())
.stderr(Stdio::piped()) .stderr(Stdio::piped())