Added tracks to db, beginning to get playlist creation

This commit is contained in:
Connor Johnstone
2026-03-02 22:20:35 -05:00
parent 4a388c6637
commit 6a16cb1395
4 changed files with 129 additions and 23 deletions

View File

@@ -56,3 +56,14 @@ pub fn read_artist_mbid(path: &Path) -> Result<Option<String>, lofty::error::Lof
Ok(tag.get_string(ItemKey::MusicBrainzArtistId).map(String::from))
}
/// Extract the MusicBrainz recording ID from a music file.
pub fn read_track_mbid(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::MusicBrainzRecordingId).map(String::from))
}