Building up a little db of "similar artists"

This commit is contained in:
Connor Johnstone
2026-03-02 22:01:43 -05:00
parent 16e8962be1
commit 4a388c6637
8 changed files with 395 additions and 79 deletions

View File

@@ -35,6 +35,17 @@ pub fn read_all_metadata(path: &Path) -> Result<Option<Vec<TagEntry>>, lofty::er
Ok(Some(entries))
}
/// Extract the artist name from a music file.
pub fn read_artist_name(path: &Path) -> Result<Option<String>, lofty::error::LoftyError> {
let tagged_file = lofty::read_from_path(path)?;
let Some(tag) = tagged_file.primary_tag().or_else(|| tagged_file.first_tag()) else {
return Ok(None);
};
Ok(tag.get_string(ItemKey::TrackArtist).map(String::from))
}
/// Extract the MusicBrainz artist ID from a music file.
pub fn read_artist_mbid(path: &Path) -> Result<Option<String>, lofty::error::LoftyError> {
let tagged_file = lofty::read_from_path(path)?;