🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
Fix `getMusicFolders` and `getIndexes` API compliance. Fix #286
Deluan1ed6d130b135
diff --git a/Makefile b/Makefileindex dfd66efcb..fa0268f75 100644--- a/Makefile+++ b/Makefile@@ -27,13 +27,16 @@ watch: check_go_envtest: check_go_envgo test ./... -v-# @(cd ./ui && npm test -- --watchAll=false).PHONY: testtestall: check_go_env test@(cd ./ui && npm test -- --watchAll=false).PHONY: testall+update-snapshots: check_go_env+ UPDATE_SNAPSHOTS=true ginkgo ./server/subsonic/...+.PHONY: update-snapshots+setup:@which go-bindata || (echo "Installing BinData" && GO111MODULE=off go get -u github.com/go-bindata/go-bindata/...)go mod downloaddiff --git a/model/mediafolder.go b/model/mediafolder.goindex 39a178366..3a3b28abc 100644--- a/model/mediafolder.go+++ b/model/mediafolder.go@@ -1,6 +1,7 @@package modeltype MediaFolder struct {+ // TODO Change to intID stringName stringPath stringdiff --git a/server/subsonic/browsing.go b/server/subsonic/browsing.goindex 6e4ec138f..a1110d82d 100644--- a/server/subsonic/browsing.go+++ b/server/subsonic/browsing.go@@ -2,8 +2,8 @@ package subsonicimport ("context"- "fmt""net/http"+ "strconv""time""github.com/deluan/navidrome/conf"@@ -26,7 +26,9 @@ func (c *BrowsingController) GetMusicFolders(w http.ResponseWriter, r *http.RequmediaFolderList, _ := c.browser.MediaFolders(r.Context())folders := make([]responses.MusicFolder, len(mediaFolderList))for i, f := range mediaFolderList {- folders[i].Id = f.ID+ // TODO Change model.MediaFolder.ID to int+ id, _ := strconv.ParseInt(f.ID, 10, 32)+ folders[i].Id = int32(id)folders[i].Name = f.Name}response := NewResponse()@@ -43,7 +45,7 @@ func (c *BrowsingController) getArtistIndex(r *http.Request, musicFolderId strinres := &responses.Indexes{IgnoredArticles: conf.Server.IgnoredArticles,- LastModified: fmt.Sprint(utils.ToMillis(lastModified)),+ LastModified: utils.ToMillis(lastModified),}res.Index = make([]responses.Index, len(indexes))@@ -230,7 +232,7 @@ func (c *BrowsingController) buildAlbum(ctx context.Context, d *engine.Directorydir.CoverArt = d.CoverArtdir.SongCount = d.SongCountdir.Duration = d.Duration- dir.PlayCount = d.PlayCount+ dir.PlayCount = int64(d.PlayCount)dir.Year = d.Yeardir.Genre = d.Genreif !d.Created.IsZero() {diff --git a/server/subsonic/helpers.go b/server/subsonic/helpers.goindex 9639b1be3..4b0489a0f 100644--- a/server/subsonic/helpers.go+++ b/server/subsonic/helpers.go@@ -126,7 +126,7 @@ func ToChild(ctx context.Context, entry engine.Entry) responses.Child {child.Starred = &entry.Starred}child.Path = entry.Path- child.PlayCount = entry.PlayCount+ child.PlayCount = int64(entry.PlayCount)child.DiscNumber = entry.DiscNumberif !entry.Created.IsZero() {child.Created = &entry.Createddiff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSONindex 93b3a275f..800283f4d 100644--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSON+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes with data should match .JSON@@ -1 +1 @@-{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","indexes":{"index":[{"name":"A","artist":[{"id":"111","name":"aaa","starred":"2016-03-02T20:30:00Z"}]}],"lastModified":"1","ignoredArticles":"A"}}+{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","indexes":{"index":[{"name":"A","artist":[{"id":"111","name":"aaa","starred":"2016-03-02T20:30:00Z"}]}],"lastModified":1,"ignoredArticles":"A"}}diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .JSONindex cb318f453..5e9ffa25e 100644--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .JSON+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses Indexes without data should match .JSON@@ -1 +1 @@-{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","indexes":{"lastModified":"1","ignoredArticles":"A"}}+{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","indexes":{"lastModified":1,"ignoredArticles":"A"}}diff --git a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .JSON b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .JSONindex 0b659d362..634549ea6 100644--- a/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .JSON+++ b/server/subsonic/responses/.snapshots/responses-snapshotMatcher-Match-Responses MusicFolders with data should match .JSON@@ -1 +1 @@-{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","musicFolders":{"musicFolder":[{"id":"111","name":"aaa"},{"id":"222","name":"bbb"}]}}+{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","musicFolders":{"musicFolder":[{"id":111,"name":"aaa"},{"id":222,"name":"bbb"}]}}diff --git a/server/subsonic/responses/responses.go b/server/subsonic/responses/responses.goindex c7fcec656..c7118966e 100644--- a/server/subsonic/responses/responses.go+++ b/server/subsonic/responses/responses.go@@ -54,7 +54,7 @@ type License struct {}type MusicFolder struct {- Id string `xml:"id,attr" json:"id"`+ Id int32 `xml:"id,attr" json:"id"`Name string `xml:"name,attr" json:"name"`}@@ -80,7 +80,7 @@ type Index struct {type Indexes struct {Index []Index `xml:"index" json:"index,omitempty"`- LastModified string `xml:"lastModified,attr" json:"lastModified"`+ LastModified int64 `xml:"lastModified,attr" json:"lastModified"`IgnoredArticles string `xml:"ignoredArticles,attr" json:"ignoredArticles"`}@@ -105,7 +105,7 @@ type Child struct {Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`BitRate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`Path string `xml:"path,attr,omitempty" json:"path,omitempty"`- PlayCount int32 `xml:"playCount,attr,omitempty" json:"playcount,omitempty"`+ PlayCount int64 `xml:"playCount,attr,omitempty" json:"playcount,omitempty"`DiscNumber int `xml:"discNumber,attr,omitempty" json:"discNumber,omitempty"`Created *time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`AlbumId string `xml:"albumId,attr,omitempty" json:"albumId,omitempty"`@@ -167,7 +167,7 @@ type AlbumID3 struct {CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`SongCount int `xml:"songCount,attr,omitempty" json:"songCount,omitempty"`Duration int `xml:"duration,attr,omitempty" json:"duration,omitempty"`- PlayCount int32 `xml:"playCount,attr,omitempty" json:"playcount,omitempty"`+ PlayCount int64 `xml:"playCount,attr,omitempty" json:"playcount,omitempty"`Created *time.Time `xml:"created,attr,omitempty" json:"created,omitempty"`Starred *time.Time `xml:"starred,attr,omitempty" json:"starred,omitempty"`Year int `xml:"year,attr,omitempty" json:"year,omitempty"`diff --git a/server/subsonic/responses/responses_test.go b/server/subsonic/responses/responses_test.goindex cb5239212..d55d3901f 100644--- a/server/subsonic/responses/responses_test.go+++ b/server/subsonic/responses/responses_test.go@@ -60,8 +60,8 @@ var _ = Describe("Responses", func() {Context("with data", func() {BeforeEach(func() {folders := make([]MusicFolder, 2)- folders[0] = MusicFolder{Id: "111", Name: "aaa"}- folders[1] = MusicFolder{Id: "222", Name: "bbb"}+ folders[0] = MusicFolder{Id: 111, Name: "aaa"}+ folders[1] = MusicFolder{Id: 222, Name: "bbb"}response.MusicFolders.Folders = folders})@@ -76,7 +76,7 @@ var _ = Describe("Responses", func() {Describe("Indexes", func() {BeforeEach(func() {- response.Indexes = &Indexes{LastModified: "1", IgnoredArticles: "A"}+ response.Indexes = &Indexes{LastModified: 1, IgnoredArticles: "A"}})Context("without data", func() {