remove RSong
This commit is contained in:
parent
fd371e8960
commit
94e1581500
|
|
@ -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<Option<RSong>>,
|
||||
}
|
||||
|
||||
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<Vec<Option<RSong>>> {
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
67
src/song.rs
67
src/song.rs
|
|
@ -1,67 +0,0 @@
|
|||
use mpd::{Client, Song};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone )]
|
||||
pub struct RSong {
|
||||
pub file: String,
|
||||
pub artist: Option<String>,
|
||||
pub title: Option<String>,
|
||||
pub duration: Option<u32>,
|
||||
pub last_mod: Option<String>,
|
||||
pub name: Option<String>,
|
||||
pub place: Option<String>,
|
||||
pub range: Option<String>,
|
||||
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::<u32>().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
|
||||
}
|
||||
}
|
||||
Reference in New Issue