Tag::year() returns re‑release year (from MusicBrainz Picard) instead of the original album year. #531
-
Hi everyone, I’m using the latest version of lofty crate (lofty = "*" in Cargo.toml) to display an album’s original release year in my GTK app. Is there a built‑in way in lofty to pull the original release year (TDOR) first and only fall back to TDRC? Or am I doing something wrong? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello!
What you're looking for is ItemKey, specifically ItemKey::OriginalReleaseDate. You can use it like so: use lofty::tag::items::Timestamp;
use lofty::prelude::*;
fn main() -> lofty::error::Result<()> {
let file = lofty::read_from_path("foo.mp3")?;
let tag = file.primary_tag().expect("No tag!");
if let Some(original_release_date_str) = tag.get_string(&ItemKey::OriginalReleaseDate) {
let original_release_date: Timestamp = original_release_date_str.parse()?;
let original_release_year = original_release_date.year;
println!("Originally released in: {original_release_year}");
}
Ok(())
} |
Beta Was this translation helpful? Give feedback.
Hello!
year()
comes from Accessor which only has methods for a few items, since it's meant to only support items that every tag format supports.What you're looking for is ItemKey, specifically ItemKey::OriginalReleaseDate.
You can use it like so: