|
@@ -1,3 +1,4 @@
|
|
|
|
+use serde_json::Value;
|
|
use songbird::input::reader::MediaSource;
|
|
use songbird::input::reader::MediaSource;
|
|
use std::{
|
|
use std::{
|
|
io::BufReader,
|
|
io::BufReader,
|
|
@@ -6,15 +7,12 @@ use std::{
|
|
use symphonia_core::io::ReadOnlySource;
|
|
use symphonia_core::io::ReadOnlySource;
|
|
use tokio::process::Command as TokioCommand;
|
|
use tokio::process::Command as TokioCommand;
|
|
|
|
|
|
-pub async fn ytdl(query: &str) -> Result<String, std::io::Error> {
|
|
|
|
|
|
+pub async fn ytdl(query: &str) -> Result<Value, std::io::Error> {
|
|
let mut cmd = TokioCommand::new("youtube-dl");
|
|
let mut cmd = TokioCommand::new("youtube-dl");
|
|
let cmd = cmd
|
|
let cmd = cmd
|
|
- .arg("-x")
|
|
|
|
- .arg("--skip-download")
|
|
|
|
- .arg("--get-title")
|
|
|
|
- .arg("--get-url")
|
|
|
|
- .arg("--audio-quality")
|
|
|
|
- .arg("128k")
|
|
|
|
|
|
+ .arg("-j")
|
|
|
|
+ .arg("-f")
|
|
|
|
+ .arg("bestaudio")
|
|
.arg(query)
|
|
.arg(query)
|
|
.stdout(Stdio::piped())
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::piped());
|
|
.stderr(Stdio::piped());
|
|
@@ -23,7 +21,7 @@ pub async fn ytdl(query: &str) -> Result<String, std::io::Error> {
|
|
let stdout = String::from_utf8(output.stdout).unwrap();
|
|
let stdout = String::from_utf8(output.stdout).unwrap();
|
|
let stderr = String::from_utf8(output.stderr).unwrap();
|
|
let stderr = String::from_utf8(output.stderr).unwrap();
|
|
if output.status.success() {
|
|
if output.status.success() {
|
|
- Ok(stdout)
|
|
|
|
|
|
+ Ok(serde_json::from_str(&stdout)?)
|
|
} else {
|
|
} else {
|
|
Err(std::io::Error::new(
|
|
Err(std::io::Error::new(
|
|
std::io::ErrorKind::Other,
|
|
std::io::ErrorKind::Other,
|