lastfm: rename scrobbleopts scrobbleoptions

This commit is contained in:
sentriz
2020-05-01 02:15:12 +01:00
parent 24212af42e
commit a541f97cd8
8 changed files with 18 additions and 12 deletions

View File

@@ -12,8 +12,8 @@ import (
"github.com/oklog/run" "github.com/oklog/run"
"github.com/peterbourgon/ff" "github.com/peterbourgon/ff"
"go.senan.xyz/gonic/server/db"
"go.senan.xyz/gonic/server" "go.senan.xyz/gonic/server"
"go.senan.xyz/gonic/server/db"
"go.senan.xyz/gonic/version" "go.senan.xyz/gonic/version"
) )

View File

@@ -145,8 +145,10 @@ type Response struct {
err string err string
} }
type handlerAdmin func(r *http.Request) *Response type (
type handlerAdminRaw func(w http.ResponseWriter, r *http.Request) handlerAdmin func(r *http.Request) *Response
handlerAdminRaw func(w http.ResponseWriter, r *http.Request)
)
//nolint:gocognit //nolint:gocognit
func (c *Controller) H(h handlerAdmin) http.Handler { func (c *Controller) H(h handlerAdmin) http.Handler {

View File

@@ -81,8 +81,10 @@ func writeResp(w http.ResponseWriter, r *http.Request, resp *spec.Response) erro
return ew.err return ew.err
} }
type handlerSubsonic func(r *http.Request) *spec.Response type (
type handlerSubsonicRaw func(w http.ResponseWriter, r *http.Request) *spec.Response handlerSubsonic func(r *http.Request) *spec.Response
handlerSubsonicRaw func(w http.ResponseWriter, r *http.Request) *spec.Response
)
func (c *Controller) H(h handlerSubsonic) http.Handler { func (c *Controller) H(h handlerSubsonic) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

View File

@@ -13,9 +13,9 @@ import (
jd "github.com/josephburnett/jd/lib" jd "github.com/josephburnett/jd/lib"
"go.senan.xyz/gonic/server/db"
"go.senan.xyz/gonic/server/ctrlbase" "go.senan.xyz/gonic/server/ctrlbase"
"go.senan.xyz/gonic/server/ctrlsubsonic/params" "go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/db"
) )
var ( var (

View File

@@ -55,7 +55,7 @@ func (c *Controller) ServeScrobble(r *http.Request) *spec.Response {
Preload("Artist"). Preload("Artist").
First(track, id) First(track, id)
// scrobble with above info // scrobble with above info
opts := lastfm.ScrobbleOpts{ opts := lastfm.ScrobbleOptions{
Track: track, Track: track,
// clients will provide time in miliseconds, so use that or // clients will provide time in miliseconds, so use that or
// instead convert UnixNano to miliseconds // instead convert UnixNano to miliseconds

View File

@@ -9,9 +9,9 @@ import (
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"go.senan.xyz/gonic/server/db"
"go.senan.xyz/gonic/server/ctrlsubsonic/params" "go.senan.xyz/gonic/server/ctrlsubsonic/params"
"go.senan.xyz/gonic/server/ctrlsubsonic/spec" "go.senan.xyz/gonic/server/ctrlsubsonic/spec"
"go.senan.xyz/gonic/server/db"
"go.senan.xyz/gonic/server/encode" "go.senan.xyz/gonic/server/encode"
) )

View File

@@ -74,13 +74,13 @@ func GetSession(apiKey, secret, token string) (string, error) {
return resp.Session.Key, nil return resp.Session.Key, nil
} }
type ScrobbleOpts struct { type ScrobbleOptions struct {
Track *db.Track Track *db.Track
StampMili int StampMili int
Submission bool Submission bool
} }
func Scrobble(apiKey, secret, session string, opts ScrobbleOpts) error { func Scrobble(apiKey, secret, session string, opts ScrobbleOptions) error {
params := url.Values{} params := url.Values{}
if opts.Submission { if opts.Submission {
params.Add("method", "track.Scrobble") params.Add("method", "track.Scrobble")

View File

@@ -178,8 +178,10 @@ func setupSubsonic(r *mux.Router, ctrl *ctrlsubsonic.Controller) {
r.NotFoundHandler = notFoundRoute.GetHandler() r.NotFoundHandler = notFoundRoute.GetHandler()
} }
type funcExecute func() error type (
type funcInterrupt func(error) funcExecute func() error
funcInterrupt func(error)
)
func (s *Server) StartHTTP(listenAddr string) (funcExecute, funcInterrupt) { func (s *Server) StartHTTP(listenAddr string) (funcExecute, funcInterrupt) {
list := &http.Server{ list := &http.Server{