create scrobbleopts

This commit is contained in:
sentriz
2020-02-09 17:09:00 +00:00
parent 754067d64a
commit 36829c69e3
2 changed files with 49 additions and 41 deletions

View File

@@ -55,15 +55,18 @@ func (c *Controller) ServeScrobble(r *http.Request) *spec.Response {
Preload("Artist").
First(track, id)
// scrobble with above info
opts := lastfm.ScrobbleOpts{
Track: track,
// clients will provide time in miliseconds, so use that or
// instead convert UnixNano to miliseconds
StampMili: params.GetIntOr("time", int(time.Now().UnixNano()/1e6)),
Submission: params.GetOr("submission", "true") != "false",
}
err = lastfm.Scrobble(
c.DB.GetSetting("lastfm_api_key"),
c.DB.GetSetting("lastfm_secret"),
user.LastFMSession,
track,
// clients will provide time in miliseconds, so use that or
// instead convert UnixNano to miliseconds
params.GetIntOr("time", int(time.Now().UnixNano()/1e6)),
params.GetOr("submission", "true") != "false",
opts,
)
if err != nil {
return spec.NewError(0, "error when submitting: %v", err)