|
@@ -6,24 +6,23 @@ 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<(String, String), 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("-x")
|
|
.arg("--skip-download")
|
|
.arg("--skip-download")
|
|
|
|
+ .arg("--get-title")
|
|
.arg("--get-url")
|
|
.arg("--get-url")
|
|
.arg("--audio-quality")
|
|
.arg("--audio-quality")
|
|
.arg("128k")
|
|
.arg("128k")
|
|
.arg(query);
|
|
.arg(query);
|
|
let out = cmd.output().await?;
|
|
let out = cmd.output().await?;
|
|
- Ok(String::from_utf8(out.stdout).unwrap())
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-pub async fn ytdl_title(query: &str) -> Result<String, std::io::Error> {
|
|
|
|
- let mut cmd = TokioCommand::new("youtube-dl");
|
|
|
|
- let cmd = cmd.arg("--get-title").arg(query);
|
|
|
|
- let out = cmd.output().await?;
|
|
|
|
- Ok(String::from_utf8(out.stdout).unwrap())
|
|
|
|
|
|
+ let out = String::from_utf8(out.stdout).unwrap();
|
|
|
|
+ let mut lines = out.lines();
|
|
|
|
+ Ok((
|
|
|
|
+ lines.next().unwrap().to_string(),
|
|
|
|
+ lines.next().unwrap().to_string(),
|
|
|
|
+ ))
|
|
}
|
|
}
|
|
|
|
|
|
pub async fn ffmpeg_pcm(url: &str) -> Result<Box<dyn MediaSource + Send>, String> {
|
|
pub async fn ffmpeg_pcm(url: &str) -> Result<Box<dyn MediaSource + Send>, String> {
|