Krolyxon
Commit 94e1581

rmptui94e1581

remove RSong

Author
krolxon
Date
2024-04-28 20:05 +0530
Parent
fd371e8
Commit
94e15815005c302546fe7e11fd08078f86c4dc72

+2 −87

3 files changed

  1. M src/browser.rs +1 −19
  2. M src/handler.rs +1 −1
  3. D src/song.rs +0 −67
M src/browser.rs View
@@ -1,4 +1,4 @@
1−use crate::{app::AppResult, connection::Connection, song::RSong};
1+use crate::{app::AppResult, connection::Connection};
22
33 #[derive(Debug)]
44 pub struct FileBrowser {
@@ -7,8 +7,6 @@ pub struct FileBrowser {
77 pub prev_selected: usize,
88 pub path: String,
99 pub prev_path: String,
10−
11− pub rsongs: Vec<Option<RSong>>,
1210 }
1311
1412 impl FileBrowser {
@@ -19,7 +17,6 @@ impl FileBrowser {
1917 prev_selected: 0,
2018 path: ".".to_string(),
2119 prev_path: ".".to_string(),
22− rsongs: Vec::new(),
2320 }
2421 }
2522
@@ -35,21 +32,6 @@ impl FileBrowser {
3532 Ok(())
3633 }
3734
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−
5335 // Go to next item in filetree
5436 pub fn next(&mut self) {
5537 // if self.selected < self.filetree.len() - 1 {
M src/handler.rs View
@@ -239,7 +239,7 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
239239
240240 KeyCode::Right => {
241241 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())?;
243243 }
244244
245245 // Fast forward
D src/song.rs View
@@ -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−}