From 0b5f6993834ff92ef7c84ec5e9bf61d9a8d1cbfa Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Thu, 23 Nov 2023 09:57:35 +0100 Subject: [PATCH] Subsonic: Partial support for some OpenSubsonic tags --- backends/subsonic/subsonic.go | 13 ++++++++++++- go.mod | 2 ++ go.sum | 2 ++ go.work.sum | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/backends/subsonic/subsonic.go b/backends/subsonic/subsonic.go index ba88146..56dc5fa 100644 --- a/backends/subsonic/subsonic.go +++ b/backends/subsonic/subsonic.go @@ -88,11 +88,22 @@ func SongAsLove(song subsonic.Child, username string) models.Love { ArtistNames: []string{song.Artist}, TrackNumber: song.Track, DiscNumber: song.DiscNumber, - Tags: []string{song.Genre}, + RecordingMbid: models.MBID(song.MusicBrainzId), + Tags: []string{}, AdditionalInfo: map[string]any{}, Duration: time.Duration(song.Duration * int(time.Second)), }, } + if len(song.Genres) > 0 { + genres := make([]string, 0, len(song.Genres)) + for _, genre := range song.Genres { + genres = append(genres, genre.Name) + } + love.Track.Tags = genres + } else if song.Genre != "" { + love.Track.Tags = []string{song.Genre} + } + return love } diff --git a/go.mod b/go.mod index 41da809..f15625f 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module go.uploadedlobster.com/scotty go 1.21.1 +replace github.com/delucks/go-subsonic => github.com/phw/go-subsonic v0.0.0-20231123083950-2a64076c2396 + require ( github.com/VividCortex/ewma v1.2.0 // indirect github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect diff --git a/go.sum b/go.sum index 2dcb0ae..af49d4a 100644 --- a/go.sum +++ b/go.sum @@ -177,6 +177,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/phw/go-subsonic v0.0.0-20231123084006-32e6ff0ea093 h1:Z95GJhfINktoEZVSSfScUoj1kV0a0d0qjiU66gndiaM= +github.com/phw/go-subsonic v0.0.0-20231123084006-32e6ff0ea093/go.mod h1:wwUjRas8jxNAHqW51B+S+kDtb7tIZPSGuUeLwyTxnMg= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/go.work.sum b/go.work.sum index f53dd90..6c31bdc 100644 --- a/go.work.sum +++ b/go.work.sum @@ -17,6 +17,8 @@ github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwU github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/phw/go-subsonic v0.0.0-20231123083950-2a64076c2396 h1:z/CgFZbRqcEhtz5ZLYfpWUARjuz++vuVRRsWwhTWf+w= +github.com/phw/go-subsonic v0.0.0-20231123083950-2a64076c2396/go.mod h1:vnbEuj6Z20PLcHB4rrLQAOXGMjtULfMGhRVSFPcSdUo= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=