From 6702520b7c9be819fcbec4a2b4263b459596ff81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=28=20=CD=A1=C2=B0=20=CD=9C=CA=96=20=CD=A1=C2=B0=29?=
<35662205+peppizza@users.noreply.github.com>
Date: Fri, 13 Nov 2020 17:27:28 -0500
Subject: [PATCH] Offer youtube-dlc as an alternative to youtube-dl (#1)
* Adds youtube-dlc feature.
---
Cargo.toml | 1 +
src/input/ytdl_src.rs | 8 +++++++-
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/Cargo.toml b/Cargo.toml
index 3bfc42771..9755f2757 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -137,6 +137,7 @@ driver = [
"url",
"xsalsa20poly1305",
]
+youtube-dlc = []
rustls = ["async-tungstenite/tokio-rustls"]
native = ["async-tungstenite/tokio-native-tls"]
serenity-rustls = ["serenity/rustls_backend", "rustls", "gateway", "serenity-deps"]
diff --git a/src/input/ytdl_src.rs b/src/input/ytdl_src.rs
index 1de388005..90cce9080 100644
--- a/src/input/ytdl_src.rs
+++ b/src/input/ytdl_src.rs
@@ -14,6 +14,12 @@ use std::{
use tokio::task;
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`.
pub async fn ytdl(uri: &str) -> Result {
_ytdl(uri, &[]).await
@@ -45,7 +51,7 @@ pub(crate) async fn _ytdl(uri: &str, pre_args: &[&str]) -> Result {
"-",
];
- let mut youtube_dl = Command::new("youtube-dl")
+ let mut youtube_dl = Command::new(YOUTUBE_DL_COMMAND)
.args(&ytdl_args)
.stdin(Stdio::null())
.stderr(Stdio::piped())