add youtube download

This commit is contained in:
Oleg Sobolev 2024-03-23 22:55:48 +07:00
parent 584b36820a
commit 90e34b8108
6 changed files with 58 additions and 1383 deletions

View file

@ -1,4 +1,8 @@
mod track;
pub mod channel;
pub mod download;
pub use track::TrackInfo;
use channel::{Requester, Responder, TryRecvError};
use rodio::{Decoder, OutputStream, OutputStreamHandle, Sink};
@ -6,24 +10,10 @@ use std::{
collections::VecDeque,
fs::File,
io::BufReader,
path::{Path, PathBuf},
thread,
thread::JoinHandle,
};
#[derive(Debug, Clone)]
pub struct TrackInfo {
pub path: PathBuf,
}
impl TrackInfo {
pub fn new(path: &Path) -> TrackInfo {
TrackInfo {
path: PathBuf::from(path),
}
}
}
#[derive(Debug, Clone)]
enum WorkerRequest {
AddTrack(TrackInfo),
@ -57,7 +47,7 @@ struct Worker {
}
fn get_source(track: TrackInfo) -> Decoder<BufReader<File>> {
let file = BufReader::new(File::open(track.path).unwrap());
let file = BufReader::new(File::open(&track.path).unwrap());
Decoder::new(file).unwrap()
}