Building up a little db of "similar artists"
This commit is contained in:
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user