diff --git a/src/browser.rs b/src/browser.rs index 895eaa0..6af4f59 100755 --- a/src/browser.rs +++ b/src/browser.rs @@ -1,4 +1,4 @@ -use crate::{app::AppResult, connection::Connection, song::RSong}; +use crate::{app::AppResult, connection::Connection}; #[derive(Debug)] pub struct FileBrowser { @@ -7,8 +7,6 @@ pub struct FileBrowser { pub prev_selected: usize, pub path: String, pub prev_path: String, - - pub rsongs: Vec>, } impl FileBrowser { @@ -19,7 +17,6 @@ impl FileBrowser { prev_selected: 0, path: ".".to_string(), prev_path: ".".to_string(), - rsongs: Vec::new(), } } @@ -35,21 +32,6 @@ impl FileBrowser { Ok(()) } - // read all songs into a vec of RSongs - pub fn get_all_rsongs(&mut self, conn: &mut Connection) -> AppResult>> { - for (t, s) in self.filetree.iter() { - if t == "file" { - let s = conn.get_full_path(s)?; - let s = RSong::new(&mut conn.conn, s); - self.rsongs.push(Some(s)); - } else if t == "directory" { - self.rsongs.push(None) - } - } - - Ok(self.rsongs.clone()) - } - // Go to next item in filetree pub fn next(&mut self) { // if self.selected < self.filetree.len() - 1 { diff --git a/src/handler.rs b/src/handler.rs index 8736328..e2b25a1 100755 --- a/src/handler.rs +++ b/src/handler.rs @@ -239,7 +239,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { KeyCode::Right => { app.conn - .push_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?; + .load_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?; } // Fast forward diff --git a/src/song.rs b/src/song.rs deleted file mode 100755 index f1a10eb..0000000 --- a/src/song.rs +++ /dev/null @@ -1,67 +0,0 @@ -use mpd::{Client, Song}; - -#[derive(Debug)] -#[derive(Clone )] -pub struct RSong { - pub file: String, - pub artist: Option, - pub title: Option, - pub duration: Option, - pub last_mod: Option, - pub name: Option, - pub place: Option, - pub range: Option, - pub tags: Vec<(String, String)>, -} - -impl RSong { - pub fn new(c: &mut Client, filename: String) -> Self { - let mut s = RSong { - file: filename.clone(), - artist: None, - title: None, - duration: None, - last_mod: None, - name: None, - place: None, - range: None, - tags: vec![], - }; - - // Dummy song - - let song = Song { - file: filename.clone(), - artist: None, - title: None, - duration: None, - last_mod: None, - name: None, - place: None, - range: None, - tags: vec![("".to_string(), "".to_string())], - }; - - for (k, v) in (c.readcomments(song).unwrap()).flatten() { - if k.to_lowercase().contains("artist") { - s.artist = Some(v); - } else if k.to_lowercase().contains("title") { - s.title = Some(v); - } else if k.to_lowercase().contains("duration") { - s.duration = Some(v.parse::().unwrap()); - } else if k.to_lowercase().contains("lastmod") { - s.last_mod = Some(v); - } else if k.to_lowercase().contains("name") { - s.name = Some(v); - } else if k.to_lowercase().contains("place") { - s.place = Some(v); - } else if k.to_lowercase().contains("range") { - s.range = Some(v); - } else { - s.tags.push((k, v)); - } - } - - s - } -}