🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Adding paths to the responses
Deluan21460308c9b2
diff --git a/api/base_api_controller.go b/api/base_api_controller.goindex 85eb8827d..d870a62e6 100644--- a/api/base_api_controller.go+++ b/api/base_api_controller.go@@ -127,36 +127,34 @@ func (c *BaseAPIController) ToChildren(entries engine.Entries) []responses.Child}func (c *BaseAPIController) ToChild(entry engine.Entry) responses.Child {- n := responses.Child{}- n.Id = entry.Id- n.Title = entry.Title- n.IsDir = entry.IsDir- n.Parent = entry.Parent- n.Album = entry.Album- n.Year = entry.Year- n.Artist = entry.Artist- n.Genre = entry.Genre- n.CoverArt = entry.CoverArt- n.Track = entry.Track- n.Duration = entry.Duration- n.Size = entry.Size- n.Suffix = entry.Suffix- n.BitRate = entry.BitRate- n.ContentType = entry.ContentType+ child := responses.Child{}+ child.Id = entry.Id+ child.Title = entry.Title+ child.IsDir = entry.IsDir+ child.Parent = entry.Parent+ child.Album = entry.Album+ child.Year = entry.Year+ child.Artist = entry.Artist+ child.Genre = entry.Genre+ child.CoverArt = entry.CoverArt+ child.Track = entry.Track+ child.Duration = entry.Duration+ child.Size = entry.Size+ child.Suffix = entry.Suffix+ child.BitRate = entry.BitRate+ child.ContentType = entry.ContentTypeif !entry.Starred.IsZero() {- n.Starred = &entry.Starred+ child.Starred = &entry.Starred}- //TODO Disabled for now, as DSub was using it for offline browsing. Will re-enable it when browsing by ID3 is working- //n.Path = entry.Path-- n.PlayCount = entry.PlayCount- n.DiscNumber = entry.DiscNumber+ child.Path = entry.Path+ child.PlayCount = entry.PlayCount+ child.DiscNumber = entry.DiscNumberif !entry.Created.IsZero() {- n.Created = &entry.Created+ child.Created = &entry.Created}- n.AlbumId = entry.AlbumId- n.ArtistId = entry.ArtistId- n.Type = entry.Type- n.UserRating = entry.UserRating- return n+ child.AlbumId = entry.AlbumId+ child.ArtistId = entry.ArtistId+ child.Type = entry.Type+ child.UserRating = entry.UserRating+ return child}diff --git a/engine/common.go b/engine/common.goindex 0de72812a..3c747e5bf 100644--- a/engine/common.go+++ b/engine/common.go@@ -1,6 +1,7 @@package engineimport (+ "fmt""time""github.com/deluan/gosonic/domain"@@ -81,7 +82,10 @@ func FromMediaFile(mf *domain.MediaFile) Entry {e.CoverArt = mf.Id}e.ContentType = mf.ContentType()- e.Path = mf.Path+ // Creates a "pseudo" path, to avoid sending absolute paths to the client+ if mf.Path != "" {+ e.Path = fmt.Sprintf("%s/%s/%s.%s", realArtistName(mf), mf.Album, mf.Title, mf.Suffix)+ }e.PlayCount = int32(mf.PlayCount)e.DiscNumber = mf.DiscNumbere.Created = mf.CreatedAt@@ -92,6 +96,17 @@ func FromMediaFile(mf *domain.MediaFile) Entry {return e}+func realArtistName(mf *domain.MediaFile) string {+ switch {+ case mf.Compilation:+ return "Various Artists"+ case mf.AlbumArtist != "":+ return mf.AlbumArtist+ }++ return mf.Artist+}+func FromAlbums(albums domain.Albums) Entries {entries := make(Entries, len(albums))for i, al := range albums {