🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
getIndexes returning list of artists and ignoredArticles
Deluan8e482bc494e1
diff --git a/api/get_indexes.go b/api/get_indexes.goindex c46831e3b..1a5b59c76 100644--- a/api/get_indexes.go+++ b/api/get_indexes.go@@ -23,10 +23,15 @@ func (c *GetIndexesController) Get() {beego.Error("Error retrieving Indexes:", err)c.CustomAbort(200, string(responses.NewError(responses.ERROR_GENERIC, "Internal Error")))}- res := &responses.ArtistIndex{}- res.Index = make([]responses.Index, len(indexes))+ res := &responses.ArtistIndex{IgnoredArticles: beego.AppConfig.String("ignoredArticles")}+ res.Index = make([]responses.IdxIndex, len(indexes))for i, idx := range indexes {res.Index[i].Name = idx.Id+ res.Index[i].Artists = make([]responses.IdxArtist, len(idx.Artists))+ for j, a := range idx.Artists {+ res.Index[i].Artists[j].Id = a.ArtistId+ res.Index[i].Artists[j].Name = a.Artist+ }}c.Ctx.Output.Body(responses.NewXML(res))diff --git a/api/get_indexes_test.go b/api/get_indexes_test.goindex 7e0c01f92..4693c6179 100644--- a/api/get_indexes_test.go+++ b/api/get_indexes_test.go@@ -43,15 +43,18 @@ func TestGetIndexes(t *testing.T) {So(err, ShouldBeNil)})Convey("Then it should return an empty collection", func() {- So(w.Body.String(), ShouldContainSubstring, "<indexes></indexes>")+ So(w.Body.String(), ShouldContainSubstring, `<indexes ignoredArticles="The El La Los Las Le Les Os As O A"></indexes>`)})})Convey("When the index is not empty", func() {- mockRepo.data = makeMockData(`[{"Id": "A","Artists": []}]`, 2)+ mockRepo.data = makeMockData(`[{"Id": "A","Artists": [+ {"ArtistId": "21", "Artist": "Afrolicious"}+ ]}]`, 2)_, w := Get(AddParams("/rest/getIndexes.view"), "TestGetIndexes")Convey("Then it should return the the items in the response", func() {- So(w.Body.String(), ShouldContainSubstring, `<index name="A"></index>`)+ So(w.Body.String(), ShouldContainSubstring,+ `<indexes ignoredArticles="The El La Los Las Le Les Os As O A"><index name="A"><artist id="21" name="Afrolicious"></artist></index></indexes>`)})})Reset(func() {diff --git a/api/responses/indexes.go b/api/responses/indexes.goindex 718cc9130..c8e793a1c 100644--- a/api/responses/indexes.go+++ b/api/responses/indexes.go@@ -2,13 +2,21 @@ package responsesimport "encoding/xml"-type Index struct {- XMLName xml.Name `xml:"index"`- Name string `xml:"name,attr"`+type IdxArtist struct {+ XMLName xml.Name `xml:"artist"`+ Id string `xml:"id,attr"`+ Name string `xml:"name,attr"`+}++type IdxIndex struct {+ XMLName xml.Name `xml:"index"`+ Name string `xml:"name,attr"`+ Artists []IdxArtist `xml:"index"`}type ArtistIndex struct {- XMLName xml.Name `xml:"indexes"`- Index []Index `xml:"indexes"`+ XMLName xml.Name `xml:"indexes"`+ Index []IdxIndex `xml:"indexes"`+ IgnoredArticles string `xml:"ignoredArticles,attr"`}