From 1d4eba1ca43ad6ad6632c903eec79501c8c6183d Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 01:06:48 +0100 Subject: yt-dlp: ignore configs and stop option injection --- src/commands/utilities.rs | 8 ++++++-- src/voice/mod.rs | 11 ++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/commands/utilities.rs b/src/commands/utilities.rs index 33d732f..79f4508 100644 --- a/src/commands/utilities.rs +++ b/src/commands/utilities.rs @@ -483,7 +483,11 @@ async fn run_download( }; let mut cmd = tokio::process::Command::new("yt-dlp"); - cmd.arg("-f") + // `--ignore-config` keeps a planted config file from injecting options; + // `--` stops a user-supplied URL from being parsed as a flag. + cmd.arg("--ignore-config") + .arg("--no-playlist") + .arg("-f") .arg("bestaudio/bestvideo+bestaudio") .arg("--merge-output-format") .arg("mp4") @@ -492,7 +496,7 @@ async fn run_download( if is_audio { cmd.arg("--extract-audio").arg("--audio-format").arg(fmt); } - cmd.arg(sanitize_yt_url(url)); + cmd.arg("--").arg(sanitize_yt_url(url)); let output = cmd .output() diff --git a/src/voice/mod.rs b/src/voice/mod.rs index 5a89f93..0b6022c 100644 --- a/src/voice/mod.rs +++ b/src/voice/mod.rs @@ -231,7 +231,16 @@ fn decode_stream(mss: MediaSourceStream) -> Result { /// Works for both finite media and live streams (yt-dlp handles the difference). pub async fn ytdlp_download(url: &str) -> Result> { let output = tokio::process::Command::new("yt-dlp") - .args(["-f", "bestaudio", "-o", "-", "--no-playlist", url]) + .args([ + "--ignore-config", + "-f", + "bestaudio", + "-o", + "-", + "--no-playlist", + "--", + url, + ]) .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped()) .output() -- cgit v1.2.3