From 3a2a5e961ba3533482760817845b6c8d1c2d9332 Mon Sep 17 00:00:00 2001 From: Deluan Date: Sat, 11 May 2024 17:44:24 -0400 Subject: [PATCH] Add samplingRate to OpenSubsonic responses --- server/subsonic/helpers.go | 1 + .../Responses AlbumList with data should match .JSON | 3 ++- .../Responses AlbumList with data should match .XML | 2 +- ...Responses AlbumWithSongsID3 with data should match .JSON | 3 ++- .../Responses AlbumWithSongsID3 with data should match .XML | 2 +- .../Responses Bookmarks with data should match .JSON | 3 ++- .../Responses Bookmarks with data should match .XML | 2 +- .../.snapshots/Responses Child with data should match .JSON | 5 +++-- .../.snapshots/Responses Child with data should match .XML | 2 +- .../Responses Child without data should match .JSON | 3 ++- .../Responses Child without data should match .XML | 2 +- .../Responses Directory with data should match .JSON | 3 ++- .../Responses Directory with data should match .XML | 2 +- .../Responses PlayQueue with data should match .JSON | 3 ++- .../Responses PlayQueue with data should match .XML | 2 +- .../Responses Shares with data should match .JSON | 6 ++++-- .../.snapshots/Responses Shares with data should match .XML | 4 ++-- .../Responses SimilarSongs with data should match .JSON | 3 ++- .../Responses SimilarSongs with data should match .XML | 2 +- .../Responses SimilarSongs2 with data should match .JSON | 3 ++- .../Responses SimilarSongs2 with data should match .XML | 2 +- .../Responses TopSongs with data should match .JSON | 3 ++- .../Responses TopSongs with data should match .XML | 2 +- server/subsonic/responses/responses.go | 1 + server/subsonic/responses/responses_test.go | 1 + 25 files changed, 40 insertions(+), 25 deletions(-) diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.go index 54baecb9..c5417d52 100644 --- a/server/subsonic/helpers.go +++ b/server/subsonic/helpers.go @@ -184,6 +184,7 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child AlbumPeak: mf.RgAlbumPeak, } child.ChannelCount = int32(mf.Channels) + child.SamplingRate = int32(mf.SampleRate) return child } diff --git a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON index 6a2e1839..063fd84c 100644 --- a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .JSON @@ -18,7 +18,8 @@ "musicBrainzId": "", "genres": [], "replayGain": {}, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 } ] } diff --git a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML index bc453309..df208a48 100644 --- a/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses AlbumList with data should match .XML @@ -1,6 +1,6 @@ - + diff --git a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON index 3c4ade73..7c6ae548 100644 --- a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .JSON @@ -86,7 +86,8 @@ "baseGain": 5, "fallbackGain": 6 }, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 } ] } diff --git a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML index 6ef1897f..1c3674cd 100644 --- a/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses AlbumWithSongsID3 with data should match .XML @@ -7,7 +7,7 @@ - + diff --git a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON index 18ddd2ad..062226b0 100644 --- a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .JSON @@ -19,7 +19,8 @@ "musicBrainzId": "", "genres": [], "replayGain": {}, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 }, "position": 123, "username": "user2", diff --git a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML index 289d47a7..3c82825d 100644 --- a/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses Bookmarks with data should match .XML @@ -1,7 +1,7 @@ - + diff --git a/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON index 3b972783..05c523fa 100644 --- a/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses Child with data should match .JSON @@ -27,7 +27,7 @@ "isVideo": false, "bpm": 127, "comment": "a comment", - "sortName": "", + "sortName": "sorted title", "mediaType": "song", "musicBrainzId": "4321", "genres": [ @@ -46,7 +46,8 @@ "baseGain": 5, "fallbackGain": 6 }, - "channelCount": 2 + "channelCount": 2, + "samplingRate": 44100 } ], "id": "1", diff --git a/server/subsonic/responses/.snapshots/Responses Child with data should match .XML b/server/subsonic/responses/.snapshots/Responses Child with data should match .XML index dce54006..fb07823b 100644 --- a/server/subsonic/responses/.snapshots/Responses Child with data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses Child with data should match .XML @@ -1,6 +1,6 @@ - + diff --git a/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON b/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON index 7b77a24c..c57dc283 100644 --- a/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses Child without data should match .JSON @@ -17,7 +17,8 @@ "musicBrainzId": "", "genres": [], "replayGain": {}, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 } ], "id": "", diff --git a/server/subsonic/responses/.snapshots/Responses Child without data should match .XML b/server/subsonic/responses/.snapshots/Responses Child without data should match .XML index fa5f3b1d..15f3bbbe 100644 --- a/server/subsonic/responses/.snapshots/Responses Child without data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses Child without data should match .XML @@ -1,6 +1,6 @@ - + diff --git a/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON index cdd60075..b8512c21 100644 --- a/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses Directory with data should match .JSON @@ -18,7 +18,8 @@ "musicBrainzId": "", "genres": [], "replayGain": {}, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 } ], "id": "1", diff --git a/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML b/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML index 79bdca64..e04769e8 100644 --- a/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses Directory with data should match .XML @@ -1,6 +1,6 @@ - + diff --git a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON index 05c1761b..db30fe2c 100644 --- a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .JSON @@ -18,7 +18,8 @@ "musicBrainzId": "", "genres": [], "replayGain": {}, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 } ], "current": "111", diff --git a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML index 6120b859..db0d2e64 100644 --- a/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses PlayQueue with data should match .XML @@ -1,6 +1,6 @@ - + diff --git a/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON b/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON index 71c154f2..21e603d9 100644 --- a/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses Shares with data should match .JSON @@ -23,7 +23,8 @@ "musicBrainzId": "", "genres": [], "replayGain": {}, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 }, { "id": "2", @@ -40,7 +41,8 @@ "musicBrainzId": "", "genres": [], "replayGain": {}, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 } ], "id": "ABC123", diff --git a/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML b/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML index 527aa486..a53e7411 100644 --- a/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses Shares with data should match .XML @@ -1,10 +1,10 @@ - + - + diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON index e743905b..e41223d4 100644 --- a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .JSON @@ -18,7 +18,8 @@ "musicBrainzId": "", "genres": [], "replayGain": {}, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 } ] } diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML index 2bf633e4..7a3dffde 100644 --- a/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs with data should match .XML @@ -1,6 +1,6 @@ - + diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON index ac1659f6..20f18360 100644 --- a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .JSON @@ -18,7 +18,8 @@ "musicBrainzId": "", "genres": [], "replayGain": {}, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 } ] } diff --git a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML index 683a4626..12aebc6a 100644 --- a/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses SimilarSongs2 with data should match .XML @@ -1,6 +1,6 @@ - + diff --git a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON index c9038e13..7ce7049d 100644 --- a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON +++ b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .JSON @@ -18,7 +18,8 @@ "musicBrainzId": "", "genres": [], "replayGain": {}, - "channelCount": 0 + "channelCount": 0, + "samplingRate": 0 } ] } diff --git a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML index bbd2d5b4..75b47f4f 100644 --- a/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML +++ b/server/subsonic/responses/.snapshots/Responses TopSongs with data should match .XML @@ -1,6 +1,6 @@ - + diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.go index a5ebc5a3..fb577cad 100644 --- a/server/subsonic/responses/responses.go +++ b/server/subsonic/responses/responses.go @@ -164,6 +164,7 @@ type Child struct { Genres ItemGenres `xml:"genres" json:"genres"` ReplayGain ReplayGain `xml:"replayGain" json:"replayGain"` ChannelCount int32 `xml:"channelCount,attr" json:"channelCount"` + SamplingRate int32 `xml:"samplingRate,attr" json:"samplingRate"` } type Songs struct { diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.go index cdc61409..88fb7405 100644 --- a/server/subsonic/responses/responses_test.go +++ b/server/subsonic/responses/responses_test.go @@ -143,6 +143,7 @@ var _ = Describe("Responses", func() { Suffix: "flac", TranscodedContentType: "audio/mpeg", TranscodedSuffix: "mp3", Duration: 146, BitRate: 320, Starred: &t, Genres: []ItemGenre{{Name: "rock"}, {Name: "progressive"}}, Comment: "a comment", Bpm: 127, MediaType: MediaTypeSong, MusicBrainzId: "4321", ChannelCount: 2, + SamplingRate: 44100, SortName: "sorted title", ReplayGain: ReplayGain{TrackGain: 1, AlbumGain: 2, TrackPeak: 3, AlbumPeak: 4, BaseGain: 5, FallbackGain: 6}, } response.Directory.Child = child