aboutsummaryrefslogtreecommitdiff
path: root/src/audio/ytdl.rs
diff options
context:
space:
mode:
authorNathan Perry <np@nathanperry.dev>2024-05-08 12:55:35 -0400
committerNathan Perry <np@nathanperry.dev>2024-05-08 14:16:01 -0400
commitffba60b278162707bc4eb004c3bfb6b2e9595213 (patch)
treeedf8172ecad59d46a6056944fd9e79f7dfb327c2 /src/audio/ytdl.rs
parentfe467f60d99efa54f2ef64606e7d39b9b06d7294 (diff)
rework to use songbird
Diffstat (limited to 'src/audio/ytdl.rs')
-rw-r--r--src/audio/ytdl.rs62
1 files changed, 0 insertions, 62 deletions
diff --git a/src/audio/ytdl.rs b/src/audio/ytdl.rs
deleted file mode 100644
index 645f3f4..0000000
--- a/src/audio/ytdl.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-/// This module is entirely adapted from the relevant code in Serenity.
-
-use std::{
- process::{
- Command,
- Stdio,
- },
-};
-
-use serde_json::Value;
-use serenity::{
- voice::{
- VoiceError,
- }
-};
-use lazy_static::lazy_static;
-
-use crate::{Result, CONFIG};
-
-lazy_static! {
- static ref YTDL_COMMAND: String = {
- let result = CONFIG.ytdl.clone().unwrap_or("youtube-dl".to_owned());
- log::debug!("got ytdl: {}", result);
-
- result
- };
-}
-
-pub fn ytdl_url(uri: &str) -> Result<String> {
- let args = [
- "-f",
- "webm[abr>0]/bestaudio/best",
- "--no-playlist",
- "--print-json",
- "--skip-download",
- uri,
- ];
-
- let out = Command::new(&*YTDL_COMMAND)
- .args(&args)
- .stdin(Stdio::null())
- .output()?;
-
- if !out.status.success() {
- log::error!("running ytdl {:?}", out);
- return Err(VoiceError::YouTubeDLRun(out).into());
- }
-
- let value = serde_json::from_reader(&out.stdout[..])?;
- let mut obj = match value {
- Value::Object(obj) => obj,
- other => return Err(VoiceError::YouTubeDLProcessing(other).into()),
- };
-
- match obj.remove("url") {
- Some(v) => match v {
- Value::String(uri) => Ok(uri),
- other => Err(VoiceError::YouTubeDLUrl(other).into()),
- },
- None => Err(VoiceError::YouTubeDLUrl(Value::Object(obj)).into()),
- }
-}