Compare commits

...

1 Commits

Author SHA1 Message Date
Connor Johnstone 4f4e6e794a added the cleanup, which was missing. also artist lookup first rather than search on import 2026-03-25 14:04:24 -04:00
2 changed files with 7 additions and 1 deletions
+2 -1
View File
@@ -65,9 +65,10 @@ async fn process_file(
// Upsert artist (use album_artist if available, fall back to artist) // Upsert artist (use album_artist if available, fall back to artist)
let artist_name = meta.album_artist.as_deref().or(meta.artist.as_deref()); let artist_name = meta.album_artist.as_deref().or(meta.artist.as_deref());
let artist_mbid = meta.musicbrainz_artist_id.as_deref();
let artist_id = match artist_name { let artist_id = match artist_name {
Some(name) if !name.is_empty() => { Some(name) if !name.is_empty() => {
Some(queries::artists::upsert(conn, name, None).await?.id) Some(queries::artists::upsert(conn, name, artist_mbid).await?.id)
} }
_ => None, _ => None,
}; };
+5
View File
@@ -23,6 +23,7 @@ pub struct MusicMetadata {
pub codec: Option<String>, pub codec: Option<String>,
pub bitrate: Option<i32>, pub bitrate: Option<i32>,
pub musicbrainz_recording_id: Option<String>, pub musicbrainz_recording_id: Option<String>,
pub musicbrainz_artist_id: Option<String>,
} }
/// Map lofty FileType to a human-readable codec string. /// Map lofty FileType to a human-readable codec string.
@@ -79,6 +80,10 @@ pub fn extract_metadata(path: &Path) -> IndexResult<MusicMetadata> {
meta.musicbrainz_recording_id = tag meta.musicbrainz_recording_id = tag
.get_string(&lofty::tag::ItemKey::MusicBrainzRecordingId) .get_string(&lofty::tag::ItemKey::MusicBrainzRecordingId)
.map(|s| s.to_string()); .map(|s| s.to_string());
meta.musicbrainz_artist_id = tag
.get_string(&lofty::tag::ItemKey::MusicBrainzArtistId)
.map(|s| s.to_string());
} }
Ok(meta) Ok(meta)