also add attribute labels on id3 extraction

feat/vaults
Tomáš Mládek 2022-03-01 21:17:45 +01:00
parent 4f36bff549
commit 1aa779e816
No known key found for this signature in database
GPG Key ID: 65E225C8B3E2ED8A
1 changed files with 17 additions and 9 deletions

View File

@ -2,6 +2,7 @@ use super::Extractor;
use crate::{
addressing::Address,
database::{
constants,
entry::{Entry, EntryValue},
UpEndConnection,
},
@ -58,16 +59,23 @@ impl Extractor for ID3Extractor {
let result: Vec<Entry> = tags
.frames()
.filter_map(|frame| match frame.content() {
id3::Content::Text(text) => Some(Entry {
entity: address.clone(),
attribute: format!("ID3_{}", frame.id()),
value: match frame.id() {
"TYER" | "TBPM" => EntryValue::guess_from(text),
_ => text.clone().into(),
.flat_map(|frame| match frame.content() {
id3::Content::Text(text) => vec![
Entry {
entity: address.clone(),
attribute: format!("ID3_{}", frame.id()),
value: match frame.id() {
"TYER" | "TBPM" => EntryValue::guess_from(text),
_ => text.clone().into(),
},
},
}),
_ => None,
Entry {
entity: Address::Attribute(format!("ID3_{}", frame.id())),
attribute: constants::LABEL_ATTR.into(),
value: format!("ID3: {}", frame.name()).into(),
},
],
_ => vec![],
})
.collect();