From f98b2326da31c15192f1c3b4bb17dcbfa59a058a Mon Sep 17 00:00:00 2001 From: sentriz Date: Sat, 2 Dec 2023 17:58:18 +0000 Subject: [PATCH] feat(subsonic): expose track musicbrainz id Release-As: 0.16.3 --- .../ctrlsubsonic/spec/construct_by_folder.go | 1 + server/ctrlsubsonic/spec/construct_by_tags.go | 1 + server/ctrlsubsonic/spec/spec.go | 3 + .../testdata/test_get_album_list_random | 76 +++++------ .../testdata/test_get_album_list_two_random | 120 +++++++++--------- .../testdata/test_get_album_with_cover | 9 +- .../test_get_music_directory_with_tracks | 9 +- .../test_get_music_directory_without_tracks | 9 +- .../testdata/test_search_three_q_tra | 60 ++++++--- .../testdata/test_search_two_q_alb | 27 ++-- .../testdata/test_search_two_q_tra | 60 ++++++--- 11 files changed, 219 insertions(+), 156 deletions(-) diff --git a/server/ctrlsubsonic/spec/construct_by_folder.go b/server/ctrlsubsonic/spec/construct_by_folder.go index dc65d4a0..bbd06557 100644 --- a/server/ctrlsubsonic/spec/construct_by_folder.go +++ b/server/ctrlsubsonic/spec/construct_by_folder.go @@ -74,6 +74,7 @@ func NewTCTrackByFolder(t *db.Track, parent *db.Album) *TrackChild { Bitrate: t.Bitrate, IsDir: false, Type: "music", + MusicBrainzID: t.TagBrainzID, CreatedAt: t.CreatedAt, AverageRating: formatRating(t.AverageRating), } diff --git a/server/ctrlsubsonic/spec/construct_by_tags.go b/server/ctrlsubsonic/spec/construct_by_tags.go index a44d4c70..07d64c7f 100644 --- a/server/ctrlsubsonic/spec/construct_by_tags.go +++ b/server/ctrlsubsonic/spec/construct_by_tags.go @@ -77,6 +77,7 @@ func NewTrackByTags(t *db.Track, album *db.Album) *TrackChild { TrackNumber: t.TagTrackNumber, DiscNumber: t.TagDiscNumber, Type: "music", + MusicBrainzID: t.TagBrainzID, Year: album.TagYear, AverageRating: formatRating(t.AverageRating), TranscodeMeta: TranscodeMeta{}, diff --git a/server/ctrlsubsonic/spec/spec.go b/server/ctrlsubsonic/spec/spec.go index cd514757..4a33caa8 100644 --- a/server/ctrlsubsonic/spec/spec.go +++ b/server/ctrlsubsonic/spec/spec.go @@ -200,6 +200,9 @@ type TrackChild struct { DiscNumber int `xml:"discNumber,attr,omitempty" json:"discNumber,omitempty"` Type string `xml:"type,attr,omitempty" json:"type,omitempty"` Year int `xml:"year,attr,omitempty" json:"year,omitempty"` + + MusicBrainzID string `xml:"musicBrainzId,attr" json:"musicBrainzId"` + // star / rating Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"` UserRating int `xml:"userRating,attr,omitempty" json:"userRating,omitempty"` diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_random b/server/ctrlsubsonic/testdata/test_get_album_list_random index 99b12dc5..64fd041d 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_random +++ b/server/ctrlsubsonic/testdata/test_get_album_list_random @@ -8,16 +8,31 @@ "albumList": { "album": [ { - "id": "al-4", + "id": "al-12", "created": "2019-11-30T00:00:00Z", - "artist": "artist-0", + "artist": "artist-2", "artists": null, "displayArtist": "", "title": "album-1", "album": "album-1", - "parent": "al-2", + "parent": "al-10", "isDir": true, - "coverArt": "al-4", + "coverArt": "al-12", + "name": "album-1", + "songCount": 3, + "duration": 300 + }, + { + "id": "al-8", + "created": "2019-11-30T00:00:00Z", + "artist": "artist-1", + "artists": null, + "displayArtist": "", + "title": "album-1", + "album": "album-1", + "parent": "al-6", + "isDir": true, + "coverArt": "al-8", "name": "album-1", "songCount": 3, "duration": 300 @@ -38,16 +53,31 @@ "duration": 300 }, { - "id": "al-12", + "id": "al-9", "created": "2019-11-30T00:00:00Z", - "artist": "artist-2", + "artist": "artist-1", + "artists": null, + "displayArtist": "", + "title": "album-2", + "album": "album-2", + "parent": "al-6", + "isDir": true, + "coverArt": "al-9", + "name": "album-2", + "songCount": 3, + "duration": 300 + }, + { + "id": "al-4", + "created": "2019-11-30T00:00:00Z", + "artist": "artist-0", "artists": null, "displayArtist": "", "title": "album-1", "album": "album-1", - "parent": "al-10", + "parent": "al-2", "isDir": true, - "coverArt": "al-12", + "coverArt": "al-4", "name": "album-1", "songCount": 3, "duration": 300 @@ -111,36 +141,6 @@ "name": "album-0", "songCount": 3, "duration": 300 - }, - { - "id": "al-9", - "created": "2019-11-30T00:00:00Z", - "artist": "artist-1", - "artists": null, - "displayArtist": "", - "title": "album-2", - "album": "album-2", - "parent": "al-6", - "isDir": true, - "coverArt": "al-9", - "name": "album-2", - "songCount": 3, - "duration": 300 - }, - { - "id": "al-8", - "created": "2019-11-30T00:00:00Z", - "artist": "artist-1", - "artists": null, - "displayArtist": "", - "title": "album-1", - "album": "album-1", - "parent": "al-6", - "isDir": true, - "coverArt": "al-8", - "name": "album-1", - "songCount": 3, - "duration": 300 } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_album_list_two_random b/server/ctrlsubsonic/testdata/test_get_album_list_two_random index 50cab380..0267d2ce 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_list_two_random +++ b/server/ctrlsubsonic/testdata/test_get_album_list_two_random @@ -8,91 +8,91 @@ "albumList2": { "album": [ { - "id": "al-12", + "id": "al-7", "created": "2019-11-30T00:00:00Z", - "artistId": "ar-3", - "artist": "artist-2", - "artists": [{ "id": "ar-3", "name": "artist-2" }], - "displayArtist": "artist-2", + "artistId": "ar-2", + "artist": "artist-1", + "artists": [{ "id": "ar-2", "name": "artist-1" }], + "displayArtist": "artist-1", + "title": "album-0", + "album": "album-0", + "coverArt": "al-7", + "name": "album-0", + "songCount": 3, + "duration": 300, + "year": 2021 + }, + { + "id": "al-4", + "created": "2019-11-30T00:00:00Z", + "artistId": "ar-1", + "artist": "artist-0", + "artists": [{ "id": "ar-1", "name": "artist-0" }], + "displayArtist": "artist-0", "title": "album-1", "album": "album-1", - "coverArt": "al-12", + "coverArt": "al-4", "name": "album-1", "songCount": 3, "duration": 300, "year": 2021 }, { - "id": "al-11", + "id": "al-12", "created": "2019-11-30T00:00:00Z", "artistId": "ar-3", "artist": "artist-2", "artists": [{ "id": "ar-3", "name": "artist-2" }], "displayArtist": "artist-2", - "title": "album-0", - "album": "album-0", - "coverArt": "al-11", - "name": "album-0", + "title": "album-1", + "album": "album-1", + "coverArt": "al-12", + "name": "album-1", "songCount": 3, "duration": 300, "year": 2021 }, { - "id": "al-13", + "id": "al-3", "created": "2019-11-30T00:00:00Z", - "artistId": "ar-3", - "artist": "artist-2", - "artists": [{ "id": "ar-3", "name": "artist-2" }], - "displayArtist": "artist-2", - "title": "album-2", - "album": "album-2", - "coverArt": "al-13", - "name": "album-2", + "artistId": "ar-1", + "artist": "artist-0", + "artists": [{ "id": "ar-1", "name": "artist-0" }], + "displayArtist": "artist-0", + "title": "album-0", + "album": "album-0", + "coverArt": "al-3", + "name": "album-0", "songCount": 3, "duration": 300, "year": 2021 }, { - "id": "al-9", + "id": "al-8", "created": "2019-11-30T00:00:00Z", "artistId": "ar-2", "artist": "artist-1", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "artist-1", - "title": "album-2", - "album": "album-2", - "coverArt": "al-9", - "name": "album-2", - "songCount": 3, - "duration": 300, - "year": 2021 - }, - { - "id": "al-4", - "created": "2019-11-30T00:00:00Z", - "artistId": "ar-1", - "artist": "artist-0", - "artists": [{ "id": "ar-1", "name": "artist-0" }], - "displayArtist": "artist-0", "title": "album-1", "album": "album-1", - "coverArt": "al-4", + "coverArt": "al-8", "name": "album-1", "songCount": 3, "duration": 300, "year": 2021 }, { - "id": "al-7", + "id": "al-9", "created": "2019-11-30T00:00:00Z", "artistId": "ar-2", "artist": "artist-1", "artists": [{ "id": "ar-2", "name": "artist-1" }], "displayArtist": "artist-1", - "title": "album-0", - "album": "album-0", - "coverArt": "al-7", - "name": "album-0", + "title": "album-2", + "album": "album-2", + "coverArt": "al-9", + "name": "album-2", "songCount": 3, "duration": 300, "year": 2021 @@ -113,31 +113,31 @@ "year": 2021 }, { - "id": "al-3", + "id": "al-13", "created": "2019-11-30T00:00:00Z", - "artistId": "ar-1", - "artist": "artist-0", - "artists": [{ "id": "ar-1", "name": "artist-0" }], - "displayArtist": "artist-0", - "title": "album-0", - "album": "album-0", - "coverArt": "al-3", - "name": "album-0", + "artistId": "ar-3", + "artist": "artist-2", + "artists": [{ "id": "ar-3", "name": "artist-2" }], + "displayArtist": "artist-2", + "title": "album-2", + "album": "album-2", + "coverArt": "al-13", + "name": "album-2", "songCount": 3, "duration": 300, "year": 2021 }, { - "id": "al-8", + "id": "al-11", "created": "2019-11-30T00:00:00Z", - "artistId": "ar-2", - "artist": "artist-1", - "artists": [{ "id": "ar-2", "name": "artist-1" }], - "displayArtist": "artist-1", - "title": "album-1", - "album": "album-1", - "coverArt": "al-8", - "name": "album-1", + "artistId": "ar-3", + "artist": "artist-2", + "artists": [{ "id": "ar-3", "name": "artist-2" }], + "displayArtist": "artist-2", + "title": "album-0", + "album": "album-0", + "coverArt": "al-11", + "name": "album-0", "songCount": 3, "duration": 300, "year": 2021 diff --git a/server/ctrlsubsonic/testdata/test_get_album_with_cover b/server/ctrlsubsonic/testdata/test_get_album_with_cover index 2e65ac75..f0185a3b 100644 --- a/server/ctrlsubsonic/testdata/test_get_album_with_cover +++ b/server/ctrlsubsonic/testdata/test_get_album_with_cover @@ -46,7 +46,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-2", @@ -72,7 +73,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-3", @@ -98,7 +100,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks b/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks index 745da5f5..44af1924 100644 --- a/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks +++ b/server/ctrlsubsonic/testdata/test_get_music_directory_with_tracks @@ -32,7 +32,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-2", @@ -56,7 +57,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-3", @@ -80,7 +82,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" } ] } diff --git a/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks b/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks index f794ed0f..68723297 100644 --- a/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks +++ b/server/ctrlsubsonic/testdata/test_get_music_directory_without_tracks @@ -22,7 +22,8 @@ "isDir": true, "isVideo": false, "parent": "al-2", - "title": "album-0" + "title": "album-0", + "musicBrainzId": "" }, { "id": "al-4", @@ -36,7 +37,8 @@ "isDir": true, "isVideo": false, "parent": "al-2", - "title": "album-1" + "title": "album-1", + "musicBrainzId": "" }, { "id": "al-5", @@ -50,7 +52,8 @@ "isDir": true, "isVideo": false, "parent": "al-2", - "title": "album-2" + "title": "album-2", + "musicBrainzId": "" } ] } diff --git a/server/ctrlsubsonic/testdata/test_search_three_q_tra b/server/ctrlsubsonic/testdata/test_search_three_q_tra index 6c50e104..4b1758dd 100644 --- a/server/ctrlsubsonic/testdata/test_search_three_q_tra +++ b/server/ctrlsubsonic/testdata/test_search_three_q_tra @@ -33,7 +33,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-2", @@ -61,7 +62,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-3", @@ -89,7 +91,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-4", @@ -117,7 +120,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-5", @@ -145,7 +149,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-6", @@ -173,7 +178,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-7", @@ -201,7 +207,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-8", @@ -229,7 +236,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-9", @@ -257,7 +265,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-10", @@ -285,7 +294,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-11", @@ -313,7 +323,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-12", @@ -341,7 +352,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-13", @@ -369,7 +381,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-14", @@ -397,7 +410,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-15", @@ -425,7 +439,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-16", @@ -453,7 +468,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-17", @@ -481,7 +497,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-18", @@ -509,7 +526,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-19", @@ -537,7 +555,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-20", @@ -565,7 +584,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" } ] } diff --git a/server/ctrlsubsonic/testdata/test_search_two_q_alb b/server/ctrlsubsonic/testdata/test_search_two_q_alb index 36766a4a..41c773eb 100644 --- a/server/ctrlsubsonic/testdata/test_search_two_q_alb +++ b/server/ctrlsubsonic/testdata/test_search_two_q_alb @@ -19,7 +19,8 @@ "isDir": true, "isVideo": false, "parent": "al-2", - "title": "album-0" + "title": "album-0", + "musicBrainzId": "" }, { "id": "al-4", @@ -33,7 +34,8 @@ "isDir": true, "isVideo": false, "parent": "al-2", - "title": "album-1" + "title": "album-1", + "musicBrainzId": "" }, { "id": "al-5", @@ -47,7 +49,8 @@ "isDir": true, "isVideo": false, "parent": "al-2", - "title": "album-2" + "title": "album-2", + "musicBrainzId": "" }, { "id": "al-7", @@ -61,7 +64,8 @@ "isDir": true, "isVideo": false, "parent": "al-6", - "title": "album-0" + "title": "album-0", + "musicBrainzId": "" }, { "id": "al-8", @@ -75,7 +79,8 @@ "isDir": true, "isVideo": false, "parent": "al-6", - "title": "album-1" + "title": "album-1", + "musicBrainzId": "" }, { "id": "al-9", @@ -89,7 +94,8 @@ "isDir": true, "isVideo": false, "parent": "al-6", - "title": "album-2" + "title": "album-2", + "musicBrainzId": "" }, { "id": "al-11", @@ -103,7 +109,8 @@ "isDir": true, "isVideo": false, "parent": "al-10", - "title": "album-0" + "title": "album-0", + "musicBrainzId": "" }, { "id": "al-12", @@ -117,7 +124,8 @@ "isDir": true, "isVideo": false, "parent": "al-10", - "title": "album-1" + "title": "album-1", + "musicBrainzId": "" }, { "id": "al-13", @@ -131,7 +139,8 @@ "isDir": true, "isVideo": false, "parent": "al-10", - "title": "album-2" + "title": "album-2", + "musicBrainzId": "" } ] } diff --git a/server/ctrlsubsonic/testdata/test_search_two_q_tra b/server/ctrlsubsonic/testdata/test_search_two_q_tra index 0d160624..a92993dd 100644 --- a/server/ctrlsubsonic/testdata/test_search_two_q_tra +++ b/server/ctrlsubsonic/testdata/test_search_two_q_tra @@ -29,7 +29,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-2", @@ -53,7 +54,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-3", @@ -77,7 +79,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-4", @@ -101,7 +104,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-5", @@ -125,7 +129,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-6", @@ -149,7 +154,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-7", @@ -173,7 +179,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-8", @@ -197,7 +204,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-9", @@ -221,7 +229,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-10", @@ -245,7 +254,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-11", @@ -269,7 +279,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-12", @@ -293,7 +304,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-13", @@ -317,7 +329,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-14", @@ -341,7 +354,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-15", @@ -365,7 +379,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-16", @@ -389,7 +404,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-17", @@ -413,7 +429,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-18", @@ -437,7 +454,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-19", @@ -461,7 +479,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" }, { "id": "tr-20", @@ -485,7 +504,8 @@ "track": 1, "discNumber": 1, "type": "music", - "year": 2021 + "year": 2021, + "musicBrainzId": "" } ] }