mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-07 01:56:45 +01:00
emit tasks for columns
This commit is contained in:
parent
e16e8131aa
commit
59c2fdcbcd
6 changed files with 79 additions and 55 deletions
|
|
@ -1,8 +1,8 @@
|
|||
use crate::*;
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Read};
|
||||
use lofty::{file::TaggedFileExt, probe::Probe, tag::Accessor};
|
||||
use byte_unit::{Byte, Unit::MB};
|
||||
use lofty::{file::TaggedFileExt, probe::Probe, tag::{Accessor, TagItem, ItemKey, ItemValue}};
|
||||
|
||||
#[derive(Ord, Eq, PartialEq, PartialOrd, Debug)]
|
||||
pub enum Metadata {
|
||||
|
|
@ -159,56 +159,70 @@ impl Metadata {
|
|||
_ => None
|
||||
}
|
||||
}
|
||||
pub fn set_artist (&mut self, value: &impl AsRef<str>) -> Option<Task> {
|
||||
pub fn set_artist (&mut self, value: &impl AsRef<str>) -> Option<TagItem> {
|
||||
match self {
|
||||
Metadata::Music { artist, .. } => {
|
||||
*artist = Some(value.as_ref().into());
|
||||
if artist.as_deref() != Some(value.as_ref()) {
|
||||
*artist = Some(value.as_ref().into());
|
||||
Some(TagItem::new(
|
||||
ItemKey::TrackArtist,
|
||||
ItemValue::Text(value.as_ref().into())
|
||||
));
|
||||
}
|
||||
//todo!("emit task");
|
||||
None
|
||||
},
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
pub fn set_year (&mut self, value: &impl AsRef<str> ) -> Option<Task> {
|
||||
pub fn set_year (&mut self, value: &impl AsRef<str> ) -> Option<TagItem> {
|
||||
match self {
|
||||
Metadata::Music { year, .. } => {
|
||||
if let Ok(value) = value.as_ref().trim().parse::<u32>() {
|
||||
*year = Some(value);
|
||||
}
|
||||
//todo!("emit task");
|
||||
None
|
||||
Some(TagItem::new(
|
||||
ItemKey::Year,
|
||||
ItemValue::Text(value.as_ref().into())
|
||||
))
|
||||
},
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
pub fn set_album (&mut self, value: &impl AsRef<str>) -> Option<Task> {
|
||||
pub fn set_album (&mut self, value: &impl AsRef<str>) -> Option<TagItem> {
|
||||
match self {
|
||||
Metadata::Music { album, .. } => {
|
||||
*album = Some(value.as_ref().into());
|
||||
//todo!("emit task");
|
||||
None
|
||||
Some(TagItem::new(
|
||||
ItemKey::AlbumTitle,
|
||||
ItemValue::Text(value.as_ref().into())
|
||||
))
|
||||
},
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
pub fn set_title (&mut self, value: &impl AsRef<str>) -> Option<Task> {
|
||||
pub fn set_title (&mut self, value: &impl AsRef<str>) -> Option<TagItem> {
|
||||
match self {
|
||||
Metadata::Music { title, .. } => {
|
||||
*title = Some(value.as_ref().into());
|
||||
//todo!("emit task");
|
||||
None
|
||||
Some(TagItem::new(
|
||||
ItemKey::TrackTitle,
|
||||
ItemValue::Text(value.as_ref().into())
|
||||
))
|
||||
},
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
pub fn set_track (&mut self, value: &impl AsRef<str>) -> Option<Task> {
|
||||
pub fn set_track (&mut self, value: &impl AsRef<str>) -> Option<TagItem> {
|
||||
match self {
|
||||
Metadata::Music { track, .. } => {
|
||||
if let Ok(value) = value.as_ref().trim().parse::<u32>() {
|
||||
*track = Some(value);
|
||||
}
|
||||
//todo!("emit task");
|
||||
None
|
||||
Some(TagItem::new(
|
||||
ItemKey::TrackNumber,
|
||||
ItemValue::Text(value.as_ref().into())
|
||||
))
|
||||
},
|
||||
_ => None
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue