From c6d87515c6702c3ca22fef6ba1420ffc00eeaa77 Mon Sep 17 00:00:00 2001 From: Richard Samuels <1666322+richardsamuels@users.noreply.github.com> Date: Thu, 21 Aug 2025 18:35:55 -0400 Subject: [PATCH] fix(subsonic): populate ArtistID and AlbumID for playlists (#567) * fix(playlist): populate ArtistID and AlbumID * update keys for CI lint config * fix lint config again * fix golden samples * prettier testdata * fix merge --- .../ctrlsubsonic/spec/construct_by_folder.go | 4 ++ .../test_get_music_directory_with_tracks | 6 +++ .../testdata/test_search_two_q_tra | 40 +++++++++++++++++++ 3 files changed, 50 insertions(+) diff --git a/server/ctrlsubsonic/spec/construct_by_folder.go b/server/ctrlsubsonic/spec/construct_by_folder.go index c86fd3e..41aaac0 100644 --- a/server/ctrlsubsonic/spec/construct_by_folder.go +++ b/server/ctrlsubsonic/spec/construct_by_folder.go @@ -88,6 +88,7 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild { } if t.Album != nil { trCh.Album = t.Album.RightPath + trCh.AlbumID = t.Album.SID() } if t.TrackStar != nil { trCh.Starred = &t.TrackStar.StarDate @@ -102,6 +103,9 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild { trCh.Genres = append(trCh.Genres, &GenreRef{Name: g.Name}) } for _, a := range t.Artists { + if a.Name == t.TagTrackArtist { + trCh.ArtistID = a.SID() + } trCh.Artists = append(trCh.Artists, &ArtistRef{ID: a.SID(), Name: a.Name}) } if t.ReplayGainTrackGain != 0 || t.ReplayGainAlbumGain != 0 { diff --git a/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks b/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks index a9468a9..41c5547 100644 --- a/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks +++ b/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks @@ -13,7 +13,9 @@ { "id": "tr-1", "album": "album-0", + "albumId": "al-3", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -39,7 +41,9 @@ { "id": "tr-2", "album": "album-0", + "albumId": "al-3", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -65,7 +69,9 @@ { "id": "tr-3", "album": "album-0", + "albumId": "al-3", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, diff --git a/server/ctrlsubsonic/testdata/test_search_two_q_tra b/server/ctrlsubsonic/testdata/test_search_two_q_tra index b1cfd43..8d787f8 100644 --- a/server/ctrlsubsonic/testdata/test_search_two_q_tra +++ b/server/ctrlsubsonic/testdata/test_search_two_q_tra @@ -10,7 +10,9 @@ { "id": "tr-1", "album": "album-0", + "albumId": "al-3", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -36,7 +38,9 @@ { "id": "tr-2", "album": "album-0", + "albumId": "al-3", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -62,7 +66,9 @@ { "id": "tr-3", "album": "album-0", + "albumId": "al-3", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -88,7 +94,9 @@ { "id": "tr-4", "album": "album-1", + "albumId": "al-4", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -114,7 +122,9 @@ { "id": "tr-5", "album": "album-1", + "albumId": "al-4", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -140,7 +150,9 @@ { "id": "tr-6", "album": "album-1", + "albumId": "al-4", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -166,7 +178,9 @@ { "id": "tr-7", "album": "album-2", + "albumId": "al-5", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -192,7 +206,9 @@ { "id": "tr-8", "album": "album-2", + "albumId": "al-5", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -218,7 +234,9 @@ { "id": "tr-9", "album": "album-2", + "albumId": "al-5", "artist": "artist-0", + "artistId": "ar-1", "artists": [{ "id": "ar-1", "name": "artist-0" }], "displayArtist": "", "albumArtists": null, @@ -244,7 +262,9 @@ { "id": "tr-10", "album": "album-0", + "albumId": "al-7", "artist": "artist-1", + "artistId": "ar-2", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "", "albumArtists": null, @@ -270,7 +290,9 @@ { "id": "tr-11", "album": "album-0", + "albumId": "al-7", "artist": "artist-1", + "artistId": "ar-2", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "", "albumArtists": null, @@ -296,7 +318,9 @@ { "id": "tr-12", "album": "album-0", + "albumId": "al-7", "artist": "artist-1", + "artistId": "ar-2", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "", "albumArtists": null, @@ -322,7 +346,9 @@ { "id": "tr-13", "album": "album-1", + "albumId": "al-8", "artist": "artist-1", + "artistId": "ar-2", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "", "albumArtists": null, @@ -348,7 +374,9 @@ { "id": "tr-14", "album": "album-1", + "albumId": "al-8", "artist": "artist-1", + "artistId": "ar-2", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "", "albumArtists": null, @@ -374,7 +402,9 @@ { "id": "tr-15", "album": "album-1", + "albumId": "al-8", "artist": "artist-1", + "artistId": "ar-2", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "", "albumArtists": null, @@ -400,7 +430,9 @@ { "id": "tr-16", "album": "album-2", + "albumId": "al-9", "artist": "artist-1", + "artistId": "ar-2", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "", "albumArtists": null, @@ -426,7 +458,9 @@ { "id": "tr-17", "album": "album-2", + "albumId": "al-9", "artist": "artist-1", + "artistId": "ar-2", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "", "albumArtists": null, @@ -452,7 +486,9 @@ { "id": "tr-18", "album": "album-2", + "albumId": "al-9", "artist": "artist-1", + "artistId": "ar-2", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "", "albumArtists": null, @@ -478,7 +514,9 @@ { "id": "tr-19", "album": "album-0", + "albumId": "al-11", "artist": "artist-2", + "artistId": "ar-3", "artists": [{ "id": "ar-3", "name": "artist-2" }], "displayArtist": "", "albumArtists": null, @@ -504,7 +542,9 @@ { "id": "tr-20", "album": "album-0", + "albumId": "al-11", "artist": "artist-2", + "artistId": "ar-3", "artists": [{ "id": "ar-3", "name": "artist-2" }], "displayArtist": "", "albumArtists": null,