From f7fc17c0f7d286be1bc0421f42351fd3ffeab8fb Mon Sep 17 00:00:00 2001 From: Deluan Date: Fri, 26 Apr 2024 17:51:04 -0400 Subject: [PATCH] Add OpenSubsonic channelCount --- 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 | 3 ++- .../.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 | 2 +- 25 files changed, 39 insertions(+), 25 deletions(-) diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.go index 517416d5..189c07d4 100644 --- a/server/subsonic/helpers.go +++ b/server/subsonic/helpers.go @@ -183,6 +183,7 @@ func childFromMediaFile(ctx context.Context, mf model.MediaFile) responses.Child TrackPeak: mf.RgTrackPeak, AlbumPeak: mf.RgAlbumPeak, } + child.ChannelCount = int32(mf.Channels) 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 2d3bc3b7..6a2e1839 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 @@ -17,7 +17,8 @@ "mediaType": "", "musicBrainzId": "", "genres": [], - "replayGain": {} + "replayGain": {}, + "channelCount": 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 8787b423..bc453309 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 c5f1ea14..3c4ade73 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 @@ -85,7 +85,8 @@ "albumPeak": 4, "baseGain": 5, "fallbackGain": 6 - } + }, + "channelCount": 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 f7bcf1f1..6ef1897f 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 3edf0cfd..18ddd2ad 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 @@ -18,7 +18,8 @@ "mediaType": "", "musicBrainzId": "", "genres": [], - "replayGain": {} + "replayGain": {}, + "channelCount": 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 db7c6710..289d47a7 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 8abef4a6..3b972783 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 @@ -45,7 +45,8 @@ "albumPeak": 4, "baseGain": 5, "fallbackGain": 6 - } + }, + "channelCount": 2 } ], "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 fe858081..dce54006 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 57cf62d3..7b77a24c 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 @@ -16,7 +16,8 @@ "mediaType": "", "musicBrainzId": "", "genres": [], - "replayGain": {} + "replayGain": {}, + "channelCount": 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 aa163689..fa5f3b1d 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 6d16805c..cdd60075 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 @@ -17,7 +17,8 @@ "mediaType": "", "musicBrainzId": "", "genres": [], - "replayGain": {} + "replayGain": {}, + "channelCount": 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 11c9b381..79bdca64 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 42ea7de5..05c1761b 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 @@ -17,7 +17,8 @@ "mediaType": "", "musicBrainzId": "", "genres": [], - "replayGain": {} + "replayGain": {}, + "channelCount": 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 c37f6169..6120b859 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 34af86c2..71c154f2 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 @@ -22,7 +22,8 @@ "mediaType": "", "musicBrainzId": "", "genres": [], - "replayGain": {} + "replayGain": {}, + "channelCount": 0 }, { "id": "2", @@ -38,7 +39,8 @@ "mediaType": "", "musicBrainzId": "", "genres": [], - "replayGain": {} + "replayGain": {}, + "channelCount": 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 d8863b6d..527aa486 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 7a42f091..e743905b 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 @@ -17,7 +17,8 @@ "mediaType": "", "musicBrainzId": "", "genres": [], - "replayGain": {} + "replayGain": {}, + "channelCount": 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 78c41a77..2bf633e4 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 74b6c232..ac1659f6 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 @@ -17,7 +17,8 @@ "mediaType": "", "musicBrainzId": "", "genres": [], - "replayGain": {} + "replayGain": {}, + "channelCount": 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 bf98df70..683a4626 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 226b4ab1..c9038e13 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 @@ -17,7 +17,8 @@ "mediaType": "", "musicBrainzId": "", "genres": [], - "replayGain": {} + "replayGain": {}, + "channelCount": 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 3a597798..bbd2d5b4 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 3e6267c3..9e5587fb 100644 --- a/server/subsonic/responses/responses.go +++ b/server/subsonic/responses/responses.go @@ -163,6 +163,7 @@ type Child struct { MusicBrainzId string `xml:"musicBrainzId,attr" json:"musicBrainzId"` Genres ItemGenres `xml:"genres" json:"genres"` ReplayGain ReplayGain `xml:"replayGain" json:"replayGain"` + ChannelCount int32 `xml:"channelCount,attr" json:"channelCount"` } type Songs struct { diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.go index b4af4a0e..cdc61409 100644 --- a/server/subsonic/responses/responses_test.go +++ b/server/subsonic/responses/responses_test.go @@ -142,7 +142,7 @@ var _ = Describe("Responses", func() { Year: 1985, Genre: "Rock", CoverArt: "1", Size: 8421341, ContentType: "audio/flac", 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", + Comment: "a comment", Bpm: 127, MediaType: MediaTypeSong, MusicBrainzId: "4321", ChannelCount: 2, ReplayGain: ReplayGain{TrackGain: 1, AlbumGain: 2, TrackPeak: 3, AlbumPeak: 4, BaseGain: 5, FallbackGain: 6}, } response.Directory.Child = child