Skip to content

Commit

Permalink
Offer youtube-dlc as an alternative to youtube-dl (#1)
Browse files Browse the repository at this point in the history
* Adds youtube-dlc feature.
  • Loading branch information
peppizza authored Nov 13, 2020
1 parent a9f8d6c commit 6702520
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
8 changes: 7 additions & 1 deletion src/input/ytdl_src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Input> {
_ytdl(uri, &[]).await
Expand Down Expand Up @@ -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)
.stdin(Stdio::null())
.stderr(Stdio::piped())
Expand Down

0 comments on commit 6702520

Please sign in to comment.