aboutsummaryrefslogtreecommitdiffstats
path: root/src/voice
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/voice/mod.rs36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/voice/mod.rs b/src/voice/mod.rs
index a6baa64..5043508 100644
--- a/src/voice/mod.rs
+++ b/src/voice/mod.rs
@@ -237,22 +237,26 @@ fn decode_stream(mss: MediaSourceStream) -> Result<songbird::input::Input> {
237/// Download audio via yt-dlp, collect stdout into memory, return the raw bytes. 237/// Download audio via yt-dlp, collect stdout into memory, return the raw bytes.
238/// Works for both finite media and live streams (yt-dlp handles the difference). 238/// Works for both finite media and live streams (yt-dlp handles the difference).
239pub async fn ytdlp_download(url: &str) -> Result<Vec<u8>> { 239pub async fn ytdlp_download(url: &str) -> Result<Vec<u8>> {
240 let output = tokio::process::Command::new("yt-dlp") 240 let output = tokio::time::timeout(
241 .args([ 241 Duration::from_secs(600),
242 "--ignore-config", 242 tokio::process::Command::new("yt-dlp")
243 "-f", 243 .args([
244 "bestaudio", 244 "--ignore-config",
245 "-o", 245 "-f",
246 "-", 246 "bestaudio",
247 "--no-playlist", 247 "-o",
248 "--", 248 "-",
249 url, 249 "--no-playlist",
250 ]) 250 "--",
251 .stdout(std::process::Stdio::piped()) 251 url,
252 .stderr(std::process::Stdio::piped()) 252 ])
253 .output() 253 .stdout(std::process::Stdio::piped())
254 .await 254 .stderr(std::process::Stdio::piped())
255 .map_err(|e| Error::Custom(lang::fmt_voice_ytdlp_launch(&e)))?; 255 .output(),
256 )
257 .await
258 .map_err(|_| Error::Custom("yt-dlp timed out after 10 minutes".into()))?
259 .map_err(|e| Error::Custom(lang::fmt_voice_ytdlp_launch(&e)))?;
256 260
257 if !output.status.success() { 261 if !output.status.success() {
258 let stderr = String::from_utf8_lossy(&output.stderr); 262 let stderr = String::from_utf8_lossy(&output.stderr);