Implement Last.FM Desktop Auth flow endpoints

This commit is contained in:
Deluan
2021-06-18 18:27:15 -04:00
committed by Deluan Quintão
parent 8ee5c1f245
commit 502a719e96
8 changed files with 224 additions and 16 deletions
+3
View File
@@ -75,6 +75,9 @@ func startServer() (func() error, func(err error)) {
a := CreateServer(conf.Server.MusicFolder)
a.MountRouter("Subsonic API", consts.URLPathSubsonicAPI, CreateSubsonicAPIRouter())
a.MountRouter("Native API", consts.URLPathNativeAPI, CreateNativeAPIRouter())
if conf.Server.DevEnableScrobble {
a.MountRouter("LastFM Auth", consts.URLPathNativeAPI+"/lastfm", CreateLastFMRouter())
}
return a.Run(fmt.Sprintf("%s:%d", conf.Server.Address, conf.Server.Port))
}, func(err error) {
if err != nil {
+8 -1
View File
@@ -8,6 +8,7 @@ package cmd
import (
"github.com/google/wire"
"github.com/navidrome/navidrome/core"
"github.com/navidrome/navidrome/core/agents/lastfm"
"github.com/navidrome/navidrome/core/scrobbler"
"github.com/navidrome/navidrome/core/transcoder"
"github.com/navidrome/navidrome/persistence"
@@ -53,6 +54,12 @@ func CreateSubsonicAPIRouter() *subsonic.Router {
return router
}
func CreateLastFMRouter() *lastfm.Router {
dataStore := persistence.New()
router := lastfm.NewRouter(dataStore)
return router
}
func createScanner() scanner.Scanner {
dataStore := persistence.New()
artworkCache := core.GetImageCache()
@@ -75,7 +82,7 @@ func createScheduler() scheduler.Scheduler {
// wire_injectors.go:
var allProviders = wire.NewSet(core.Set, subsonic.New, nativeapi.New, persistence.New, GetBroker)
var allProviders = wire.NewSet(core.Set, subsonic.New, nativeapi.New, persistence.New, lastfm.NewRouter, GetBroker)
// Scanner must be a Singleton
var (
+8
View File
@@ -7,6 +7,7 @@ import (
"github.com/google/wire"
"github.com/navidrome/navidrome/core"
"github.com/navidrome/navidrome/core/agents/lastfm"
"github.com/navidrome/navidrome/persistence"
"github.com/navidrome/navidrome/scanner"
"github.com/navidrome/navidrome/scheduler"
@@ -21,6 +22,7 @@ var allProviders = wire.NewSet(
subsonic.New,
nativeapi.New,
persistence.New,
lastfm.NewRouter,
GetBroker,
)
@@ -44,6 +46,12 @@ func CreateSubsonicAPIRouter() *subsonic.Router {
))
}
func CreateLastFMRouter() *lastfm.Router {
panic(wire.Build(
allProviders,
))
}
// Scanner must be a Singleton
var (
onceScanner sync.Once