fix: make sure albums and artists are bound to songs

This commit is contained in:
2026-01-28 05:15:35 +01:00
parent 3486b82879
commit b46ab28615

View File

@@ -75,6 +75,8 @@ public static class MediaParser
"ID3v2_3:Album", // Generic mp3/wav ID3 v2.3.0
]) ?? "[Unknown Album]"; // again, weak line of defense
// TODO: Try and find genres
// Try to find relevant artists and albums
Artist artist = db.Artists
.FirstOrDefault(a => a.NormalizedName == artistName.ToLower())
@@ -108,6 +110,7 @@ public static class MediaParser
// Is Update() safe here?
db.Artists.Update(artist);
db.Albums.Update(album);
db.SaveChanges();
db.Songs.Update(song);
artist.Albums.Add(album);
artist.Songs.Add(song);
@@ -115,7 +118,7 @@ public static class MediaParser
}
catch (Exception e)
{
Console.WriteLine("[Error: MediaParser] Failed to extract metadata from {filepath}:\n" +
Console.WriteLine($"[Error: MediaParser] Failed to extract metadata from {filepath}:\n" +
$"{e}");
}