add year column

This commit is contained in:
🪞👃🪞 2025-03-23 22:05:54 +02:00
parent 4bfdd28638
commit 2ebf2c6cef
5 changed files with 52 additions and 56 deletions

View file

@ -135,6 +135,12 @@ impl Metadata {
_ => None
}
}
pub fn year (&self) -> Option<Arc<str>> {
match self {
Metadata::Music { year, .. } => year.map(|t|format!("{t}").into()).clone(),
_ => None
}
}
pub fn album (&self) -> Option<Arc<str>> {
match self {
Metadata::Music { album, .. } => album.clone(),
@ -159,6 +165,16 @@ impl Metadata {
_ => {}
}
}
pub fn set_year (&mut self, value: &impl AsRef<str> ) {
match self {
Metadata::Music { year, .. } => {
if let Ok(value) = value.as_ref().trim().parse::<u32>() {
*year = Some(value)
}
},
_ => {}
}
}
pub fn set_album (&mut self, value: &impl AsRef<str> ) {
match self {
Metadata::Music { album, .. } => *album = Some(value.as_ref().into()),
@ -171,9 +187,8 @@ impl Metadata {
_ => {}
}
}
pub fn set_track (&mut self, value: &impl AsRef<str> ) {
pub fn set_track (&mut self, value: &impl AsRef<str>) {
match self {
Metadata::Directory { .. } => todo!("set track for whole directory"),
Metadata::Music { track, .. } => {
if let Ok(value) = value.as_ref().trim().parse::<u32>() {
*track = Some(value)