mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-07 01:56:45 +01:00
add year column
This commit is contained in:
parent
4bfdd28638
commit
2ebf2c6cef
5 changed files with 52 additions and 56 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue