added the cleanup, which was missing. also artist lookup first rather than search on import
This commit is contained in:
+2
-1
@@ -65,9 +65,10 @@ async fn process_file(
|
||||
|
||||
// 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_mbid = meta.musicbrainz_artist_id.as_deref();
|
||||
let artist_id = match artist_name {
|
||||
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,
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@ pub struct MusicMetadata {
|
||||
pub codec: Option<String>,
|
||||
pub bitrate: Option<i32>,
|
||||
pub musicbrainz_recording_id: Option<String>,
|
||||
pub musicbrainz_artist_id: Option<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
|
||||
.get_string(&lofty::tag::ItemKey::MusicBrainzRecordingId)
|
||||
.map(|s| s.to_string());
|
||||
|
||||
meta.musicbrainz_artist_id = tag
|
||||
.get_string(&lofty::tag::ItemKey::MusicBrainzArtistId)
|
||||
.map(|s| s.to_string());
|
||||
}
|
||||
|
||||
Ok(meta)
|
||||
|
||||
Reference in New Issue
Block a user