fix formatting
This commit is contained in:
parent
91eca478c4
commit
22659046be
3 changed files with 18 additions and 15 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use crate::track::TrackInfo;
|
||||
use std::{path::Path, process::Command};
|
||||
|
||||
use crate::track::TrackInfo;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct DownloadError;
|
||||
|
||||
|
|
@ -14,12 +15,13 @@ pub fn download_from_youtube(url: &str) -> Result<TrackInfo, DownloadError> {
|
|||
"mp3",
|
||||
"--print",
|
||||
"%(id)s",
|
||||
"--no-simulate",
|
||||
url,
|
||||
])
|
||||
.output()
|
||||
.unwrap();
|
||||
|
||||
if !output.stderr.is_empty() {
|
||||
if !output.stderr.is_empty() || output.stdout.is_empty() {
|
||||
return Err(DownloadError);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use std::{collections::VecDeque, fs::File, io::BufReader, thread, thread::JoinHandle};
|
||||
use rodio::{Decoder, OutputStream, OutputStreamHandle, Sink};
|
||||
|
||||
use crate::channel::{self, Requester, Responder, TryRecvError};
|
||||
use crate::track::TrackInfo;
|
||||
use rodio::{Decoder, OutputStream, OutputStreamHandle, Sink};
|
||||
use std::{collections::VecDeque, fs::File, io::BufReader, thread, thread::JoinHandle};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
enum WorkerRequest {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
use std::{
|
||||
path::Path,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
use teloxide::{prelude::*, utils::command::BotCommands};
|
||||
|
||||
use crate::{player::MusicPlayer, TrackInfo};
|
||||
use crate::{player::MusicPlayer, download};
|
||||
|
||||
#[derive(BotCommands, Clone)]
|
||||
#[command(
|
||||
|
|
@ -47,11 +43,15 @@ impl TelegramBot {
|
|||
match cmd {
|
||||
Command::Play(url) => {
|
||||
println!("{}", url);
|
||||
player
|
||||
.lock()
|
||||
.unwrap()
|
||||
.enqueue(TrackInfo::new(Path::new("8bB0FNGlrEs.mp3")));
|
||||
bot.send_message(msg.chat.id, "Added to the queue.").await?;
|
||||
match download::download_from_youtube(&url) {
|
||||
Ok(track_info) => {
|
||||
player.lock().unwrap().enqueue(track_info);
|
||||
bot.send_message(msg.chat.id, "Added to the queue.").await?;
|
||||
},
|
||||
Err(_) => {
|
||||
bot.send_message(msg.chat.id, format!("Failed to download.")).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Command::Stop => {
|
||||
player.lock().unwrap().stop();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue