move scrobblers into their own package
This commit is contained in:
committed by
Senan Kelly
parent
b9998f7ee6
commit
4443d7d0f5
@@ -13,7 +13,7 @@ import (
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/params"
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
|
||||
"go.senan.xyz/gonic/server/jukebox"
|
||||
"go.senan.xyz/gonic/server/lastfm"
|
||||
"go.senan.xyz/gonic/server/scrobble"
|
||||
)
|
||||
|
||||
type CtxKey int
|
||||
@@ -29,7 +29,7 @@ type Controller struct {
|
||||
CachePath string
|
||||
CoverCachePath string
|
||||
Jukebox *jukebox.Jukebox
|
||||
Scrobblers []lastfm.Scrobbler
|
||||
Scrobblers []scrobble.Scrobbler
|
||||
}
|
||||
|
||||
type metaResponse struct {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
|
||||
"go.senan.xyz/gonic/server/db"
|
||||
"go.senan.xyz/gonic/server/lastfm"
|
||||
"go.senan.xyz/gonic/server/scrobble/lastfm"
|
||||
)
|
||||
|
||||
func (c *Controller) ServeGetArtists(r *http.Request) *spec.Response {
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/spec"
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/specid"
|
||||
"go.senan.xyz/gonic/server/db"
|
||||
"go.senan.xyz/gonic/server/lastfm"
|
||||
"go.senan.xyz/gonic/server/scanner"
|
||||
)
|
||||
|
||||
@@ -50,20 +49,13 @@ func (c *Controller) ServeScrobble(r *http.Request) *spec.Response {
|
||||
Preload("Album").
|
||||
Preload("Artist").
|
||||
First(track, id.Value)
|
||||
// scrobble with above info
|
||||
opts := lastfm.ScrobbleOptions{
|
||||
Track: track,
|
||||
// clients will provide time in miliseconds, so use that or
|
||||
// instead convert UnixNano to miliseconds
|
||||
StampMili: params.GetOrInt("time", int(time.Now().UnixNano()/1e6)),
|
||||
Submission: params.GetOrBool("submission", true),
|
||||
}
|
||||
// clients will provide time in miliseconds, so use that or
|
||||
// instead convert UnixNano to miliseconds
|
||||
optStampMili := params.GetOrInt("time", int(time.Now().UnixNano()/1e6))
|
||||
optSubmission := params.GetOrBool("submission", true)
|
||||
scrobbleErrs := []error{}
|
||||
for _, scrobbler := range c.Scrobblers {
|
||||
if !scrobbler.Enabled(user) {
|
||||
continue
|
||||
}
|
||||
err = scrobbler.Scrobble(user, opts)
|
||||
err = scrobbler.Scrobble(user, track, optStampMili, optSubmission)
|
||||
scrobbleErrs = append(scrobbleErrs, err)
|
||||
}
|
||||
if len(scrobbleErrs) != 0 {
|
||||
|
||||
Reference in New Issue
Block a user