rmptui94e1581
remove RSong
+2 −87
3 files changed
- M src/browser.rs +1 −19
- M src/handler.rs +1 −1
- D src/song.rs +0 −67
| @@ -1,4 +1,4 @@ | |||
| 1 | − | use crate::{app::AppResult, connection::Connection, song::RSong}; | |
| 1 | + | use crate::{app::AppResult, connection::Connection}; | |
| 2 | 2 | ||
| 3 | 3 | #[derive(Debug)] | |
| 4 | 4 | pub struct FileBrowser { | |
| @@ -7,8 +7,6 @@ pub struct FileBrowser { | |||
| 7 | 7 | pub prev_selected: usize, | |
| 8 | 8 | pub path: String, | |
| 9 | 9 | pub prev_path: String, | |
| 10 | − | ||
| 11 | − | pub rsongs: Vec<Option<RSong>>, | |
| 12 | 10 | } | |
| 13 | 11 | ||
| 14 | 12 | impl FileBrowser { | |
| @@ -19,7 +17,6 @@ impl FileBrowser { | |||
| 19 | 17 | prev_selected: 0, | |
| 20 | 18 | path: ".".to_string(), | |
| 21 | 19 | prev_path: ".".to_string(), | |
| 22 | − | rsongs: Vec::new(), | |
| 23 | 20 | } | |
| 24 | 21 | } | |
| 25 | 22 | ||
| @@ -35,21 +32,6 @@ impl FileBrowser { | |||
| 35 | 32 | Ok(()) | |
| 36 | 33 | } | |
| 37 | 34 | ||
| 38 | − | // read all songs into a vec of RSongs | |
| 39 | − | pub fn get_all_rsongs(&mut self, conn: &mut Connection) -> AppResult<Vec<Option<RSong>>> { | |
| 40 | − | for (t, s) in self.filetree.iter() { | |
| 41 | − | if t == "file" { | |
| 42 | − | let s = conn.get_full_path(s)?; | |
| 43 | − | let s = RSong::new(&mut conn.conn, s); | |
| 44 | − | self.rsongs.push(Some(s)); | |
| 45 | − | } else if t == "directory" { | |
| 46 | − | self.rsongs.push(None) | |
| 47 | − | } | |
| 48 | − | } | |
| 49 | − | ||
| 50 | − | Ok(self.rsongs.clone()) | |
| 51 | − | } | |
| 52 | − | ||
| 53 | 35 | // Go to next item in filetree | |
| 54 | 36 | pub fn next(&mut self) { | |
| 55 | 37 | // if self.selected < self.filetree.len() - 1 { | |
| @@ -239,7 +239,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { | |||
| 239 | 239 | ||
| 240 | 240 | KeyCode::Right => { | |
| 241 | 241 | app.conn | |
| 242 | − | .push_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?; | |
| 242 | + | .load_playlist(app.pl_list.list.get(app.pl_list.index).unwrap())?; | |
| 243 | 243 | } | |
| 244 | 244 | ||
| 245 | 245 | // Fast forward | |
| @@ -1,67 +0,0 @@ | |||
| 1 | − | use mpd::{Client, Song}; | |
| 2 | − | ||
| 3 | − | #[derive(Debug)] | |
| 4 | − | #[derive(Clone )] | |
| 5 | − | pub struct RSong { | |
| 6 | − | pub file: String, | |
| 7 | − | pub artist: Option<String>, | |
| 8 | − | pub title: Option<String>, | |
| 9 | − | pub duration: Option<u32>, | |
| 10 | − | pub last_mod: Option<String>, | |
| 11 | − | pub name: Option<String>, | |
| 12 | − | pub place: Option<String>, | |
| 13 | − | pub range: Option<String>, | |
| 14 | − | pub tags: Vec<(String, String)>, | |
| 15 | − | } | |
| 16 | − | ||
| 17 | − | impl RSong { | |
| 18 | − | pub fn new(c: &mut Client, filename: String) -> Self { | |
| 19 | − | let mut s = RSong { | |
| 20 | − | file: filename.clone(), | |
| 21 | − | artist: None, | |
| 22 | − | title: None, | |
| 23 | − | duration: None, | |
| 24 | − | last_mod: None, | |
| 25 | − | name: None, | |
| 26 | − | place: None, | |
| 27 | − | range: None, | |
| 28 | − | tags: vec![], | |
| 29 | − | }; | |
| 30 | − | ||
| 31 | − | // Dummy song | |
| 32 | − | ||
| 33 | − | let song = Song { | |
| 34 | − | file: filename.clone(), | |
| 35 | − | artist: None, | |
| 36 | − | title: None, | |
| 37 | − | duration: None, | |
| 38 | − | last_mod: None, | |
| 39 | − | name: None, | |
| 40 | − | place: None, | |
| 41 | − | range: None, | |
| 42 | − | tags: vec![("".to_string(), "".to_string())], | |
| 43 | − | }; | |
| 44 | − | ||
| 45 | − | for (k, v) in (c.readcomments(song).unwrap()).flatten() { | |
| 46 | − | if k.to_lowercase().contains("artist") { | |
| 47 | − | s.artist = Some(v); | |
| 48 | − | } else if k.to_lowercase().contains("title") { | |
| 49 | − | s.title = Some(v); | |
| 50 | − | } else if k.to_lowercase().contains("duration") { | |
| 51 | − | s.duration = Some(v.parse::<u32>().unwrap()); | |
| 52 | − | } else if k.to_lowercase().contains("lastmod") { | |
| 53 | − | s.last_mod = Some(v); | |
| 54 | − | } else if k.to_lowercase().contains("name") { | |
| 55 | − | s.name = Some(v); | |
| 56 | − | } else if k.to_lowercase().contains("place") { | |
| 57 | − | s.place = Some(v); | |
| 58 | − | } else if k.to_lowercase().contains("range") { | |
| 59 | − | s.range = Some(v); | |
| 60 | − | } else { | |
| 61 | − | s.tags.push((k, v)); | |
| 62 | − | } | |
| 63 | − | } | |
| 64 | − | ||
| 65 | − | s | |
| 66 | − | } | |
| 67 | − | } | |