|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use std::io::Read;
|
|
|
|
|
pub struct Player {
|
|
|
|
|
pub sink: rodio::Sink,
|
|
|
|
|
pub stream_thread: std::thread::JoinHandle<()>,
|
|
|
|
@ -42,6 +41,16 @@ impl Player {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn get_song_meta(&self) -> String {
|
|
|
|
|
let mut file = std::fs::File::open(&crate::RADIO_STREAM).unwrap();
|
|
|
|
|
let mut buffer = [0u8; 384];
|
|
|
|
|
file.read_exact(&mut buffer).unwrap();
|
|
|
|
|
let s = std::string::String::from_utf8_lossy(&buffer);
|
|
|
|
|
let re = regex::Regex::new(r"title=(.*).{4}server=").unwrap();
|
|
|
|
|
let caps = re.captures(&s).unwrap();
|
|
|
|
|
return caps.get(1).map_or("", |m| m.as_str()).to_owned();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn get_radio_source(&self) -> rodio::Decoder<std::io::BufReader<std::fs::File>> {
|
|
|
|
|
Self::wait_for_source();
|
|
|
|
|
let file: std::io::BufReader<std::fs::File> = std::io::BufReader::new(std::fs::File::open(&crate::RADIO_STREAM).unwrap());
|
|
|
|
|