mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-18 21:07:44 +03:00
Add GetTopSongs
placeholder, to make AVSub work
This commit is contained in:
parent
a541afbfba
commit
8e4b2e1c06
@ -82,6 +82,7 @@ func (api *Router) routes() http.Handler {
|
|||||||
H(withPlayer, "getSong", c.GetSong)
|
H(withPlayer, "getSong", c.GetSong)
|
||||||
H(withPlayer, "getArtistInfo", c.GetArtistInfo)
|
H(withPlayer, "getArtistInfo", c.GetArtistInfo)
|
||||||
H(withPlayer, "getArtistInfo2", c.GetArtistInfo2)
|
H(withPlayer, "getArtistInfo2", c.GetArtistInfo2)
|
||||||
|
H(withPlayer, "GetTopSongs", c.GetArtistInfo2)
|
||||||
})
|
})
|
||||||
r.Group(func(r chi.Router) {
|
r.Group(func(r chi.Router) {
|
||||||
c := initAlbumListController(api)
|
c := initAlbumListController(api)
|
||||||
|
@ -191,6 +191,13 @@ func (c *BrowsingController) GetArtistInfo2(w http.ResponseWriter, r *http.Reque
|
|||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Integrate with Last.FM
|
||||||
|
func (c *BrowsingController) GetTopSongs(w http.ResponseWriter, r *http.Request) (*responses.Subsonic, error) {
|
||||||
|
response := NewResponse()
|
||||||
|
response.TopSongs = &responses.TopSongs{}
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *BrowsingController) buildDirectory(ctx context.Context, d *engine.DirectoryInfo) *responses.Directory {
|
func (c *BrowsingController) buildDirectory(ctx context.Context, d *engine.DirectoryInfo) *responses.Directory {
|
||||||
dir := &responses.Directory{
|
dir := &responses.Directory{
|
||||||
Id: d.Id,
|
Id: d.Id,
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","topSongs":{"song":[{"id":"1","isDir":false,"title":"title","isVideo":false}]}}
|
@ -0,0 +1 @@
|
|||||||
|
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><topSongs><song id="1" isDir="false" title="title" isVideo="false"></song></topSongs></subsonic-response>
|
@ -0,0 +1 @@
|
|||||||
|
{"status":"ok","version":"1.8.0","type":"navidrome","serverVersion":"v0.0.0","topSongs":{}}
|
@ -0,0 +1 @@
|
|||||||
|
<subsonic-response xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0" type="navidrome" serverVersion="v0.0.0"><topSongs></topSongs></subsonic-response>
|
@ -38,6 +38,7 @@ type Subsonic struct {
|
|||||||
|
|
||||||
ArtistInfo *ArtistInfo `xml:"artistInfo,omitempty" json:"artistInfo,omitempty"`
|
ArtistInfo *ArtistInfo `xml:"artistInfo,omitempty" json:"artistInfo,omitempty"`
|
||||||
ArtistInfo2 *ArtistInfo2 `xml:"artistInfo2,omitempty" json:"artistInfo2,omitempty"`
|
ArtistInfo2 *ArtistInfo2 `xml:"artistInfo2,omitempty" json:"artistInfo2,omitempty"`
|
||||||
|
TopSongs *TopSongs `xml:"topSongs,omitempty" json:"topSongs,omitempty"`
|
||||||
|
|
||||||
PlayQueue *PlayQueue `xml:"playQueue,omitempty" json:"playQueue,omitempty"`
|
PlayQueue *PlayQueue `xml:"playQueue,omitempty" json:"playQueue,omitempty"`
|
||||||
Bookmarks *Bookmarks `xml:"bookmarks,omitempty" json:"bookmarks,omitempty"`
|
Bookmarks *Bookmarks `xml:"bookmarks,omitempty" json:"bookmarks,omitempty"`
|
||||||
@ -297,6 +298,10 @@ type ArtistInfo2 struct {
|
|||||||
SimilarArtist []ArtistID3 `xml:"similarArtist,omitempty" json:"similarArtist,omitempty"`
|
SimilarArtist []ArtistID3 `xml:"similarArtist,omitempty" json:"similarArtist,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TopSongs struct {
|
||||||
|
Song []Child `xml:"song,omitempty" json:"song,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type PlayQueue struct {
|
type PlayQueue struct {
|
||||||
Entry []Child `xml:"entry,omitempty" json:"entry,omitempty"`
|
Entry []Child `xml:"entry,omitempty" json:"entry,omitempty"`
|
||||||
Current string `xml:"current,attr,omitempty" json:"current,omitempty"`
|
Current string `xml:"current,attr,omitempty" json:"current,omitempty"`
|
||||||
|
@ -332,6 +332,35 @@ var _ = Describe("Responses", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Describe("TopSongs", func() {
|
||||||
|
BeforeEach(func() {
|
||||||
|
response.TopSongs = &TopSongs{}
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("without data", func() {
|
||||||
|
It("should match .XML", func() {
|
||||||
|
Expect(xml.Marshal(response)).To(MatchSnapshot())
|
||||||
|
})
|
||||||
|
It("should match .JSON", func() {
|
||||||
|
Expect(json.Marshal(response)).To(MatchSnapshot())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Context("with data", func() {
|
||||||
|
BeforeEach(func() {
|
||||||
|
child := make([]Child, 1)
|
||||||
|
child[0] = Child{Id: "1", Title: "title", IsDir: false}
|
||||||
|
response.TopSongs.Song = child
|
||||||
|
})
|
||||||
|
It("should match .XML", func() {
|
||||||
|
Expect(xml.Marshal(response)).To(MatchSnapshot())
|
||||||
|
})
|
||||||
|
It("should match .JSON", func() {
|
||||||
|
Expect(json.Marshal(response)).To(MatchSnapshot())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
Describe("PlayQueue", func() {
|
Describe("PlayQueue", func() {
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
response.PlayQueue = &PlayQueue{}
|
response.PlayQueue = &PlayQueue{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user