Halfway of getNowPlaying implementation
This commit is contained in:
@@ -88,3 +88,10 @@ func (c *AlbumListController) GetStarred() {
|
||||
|
||||
c.SendResponse(response)
|
||||
}
|
||||
|
||||
func (c *AlbumListController) GetNowPlaying() {
|
||||
response := c.NewEmpty()
|
||||
response.NowPlaying = &responses.NowPlaying{}
|
||||
//response.NowPlaying.Entry = make([]responses.NowPlayingEntry, 1)
|
||||
c.SendResponse(response)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"github.com/deluan/gosonic/engine"
|
||||
"github.com/deluan/gosonic/persistence"
|
||||
. "github.com/deluan/gosonic/tests"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
@@ -19,6 +20,11 @@ func TestGetAlbumList(t *testing.T) {
|
||||
return mockAlbumRepo
|
||||
})
|
||||
|
||||
mockNowPlayingRepo := engine.CreateMockNowPlayingRepo()
|
||||
utils.DefineSingleton(new(engine.NowPlayingRepository), func() engine.NowPlayingRepository {
|
||||
return mockNowPlayingRepo
|
||||
})
|
||||
|
||||
Convey("Subject: GetAlbumList Endpoint", t, func() {
|
||||
mockAlbumRepo.SetData(`[
|
||||
{"Id":"A","Name":"Vagarosa","ArtistId":"2"},
|
||||
|
||||
@@ -23,6 +23,10 @@ func (c *MediaAnnotationController) Scrobble() {
|
||||
id := c.RequiredParamString("id", "Required id parameter is missing")
|
||||
time := c.ParamTime("time", time.Now())
|
||||
submission := c.ParamBool("submission", false)
|
||||
|
||||
playerName := c.Data["c"].(string)
|
||||
username := c.Data["u"].(string)
|
||||
|
||||
if submission {
|
||||
mf, err := c.scrobbler.Register(id, time)
|
||||
if err != nil {
|
||||
@@ -31,7 +35,7 @@ func (c *MediaAnnotationController) Scrobble() {
|
||||
}
|
||||
beego.Info(fmt.Sprintf(`Scrobbled (%s) "%s" at %v`, id, mf.Title, time))
|
||||
} else {
|
||||
mf, err := c.scrobbler.NowPlaying(id)
|
||||
mf, err := c.scrobbler.NowPlaying(id, username, playerName)
|
||||
if err != nil {
|
||||
beego.Error("Error setting", id, "as current song:", err)
|
||||
c.SendError(responses.ERROR_GENERIC, "Internal error")
|
||||
|
||||
@@ -18,8 +18,9 @@ type Subsonic struct {
|
||||
AlbumList *AlbumList `xml:"albumList,omitempty" json:"albumList,omitempty"`
|
||||
Playlists *Playlists `xml:"playlists,omitempty" json:"playlists,omitempty"`
|
||||
Playlist *PlaylistWithSongs `xml:"playlist,omitempty" json:"playlist,omitempty"`
|
||||
SearchResult2 *SearchResult2 `xml:"searchResult2,omitempty" json:"searchResult2,omitempty"`
|
||||
Starred *Starred `xml:"starred,omitempty" json:"starred,omitempty"`
|
||||
SearchResult2 *SearchResult2 `xml:"searchResult2,omitempty" json:"searchResult2,omitempty"`
|
||||
Starred *Starred `xml:"starred,omitempty" json:"starred,omitempty"`
|
||||
NowPlaying *NowPlaying `xml:"nowPlaying,omitempty" json:"nowPlaying,omitempty"`
|
||||
}
|
||||
|
||||
type JsonWrapper struct {
|
||||
@@ -138,6 +139,18 @@ type Starred struct {
|
||||
Song []Child `xml:"song" json:"song,omitempty"`
|
||||
}
|
||||
|
||||
type NowPlayingEntry struct {
|
||||
Child
|
||||
UserName string `xml:"username" json:"username,omitempty"`
|
||||
MinutesAgo int `xml:"minutesAgo" json:"minutesAgo,omitempty"`
|
||||
PlayerId int `xml:"playerId" json:"playerId,omitempty"`
|
||||
PlayerName string `xml:"playerName" json:"playerName,omitempty"`
|
||||
}
|
||||
|
||||
type NowPlaying struct {
|
||||
Entry []NowPlayingEntry `xml:"entry" json:"entry,omitempty"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Username string `xml:"username,attr" json:"username"`
|
||||
Email string `xml:"email,attr,omitempty" json:"email,omitempty"`
|
||||
|
||||
@@ -32,6 +32,7 @@ func checkParameters(c BaseAPIController) {
|
||||
logWarn(c, fmt.Sprintf(`Missing required parameter "%s"`, p))
|
||||
abortRequest(c, responses.ERROR_MISSING_PARAMETER)
|
||||
}
|
||||
c.Data[p] = c.GetString(p)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user