Add support for the jukebox endpoint

This supports most of jukeboxControl.view as far as i can tell. Things
seem to be playing ok without freaking out

I've also only tested it a little bit with ultrasonic but it does
appear to be working pretty well
This commit is contained in:
Alex McGrath
2020-04-17 13:53:45 +01:00
parent f262c66c76
commit 64d0aee8dc
7 changed files with 292 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/gorilla/mux"
"go.senan.xyz/gonic/db"
"go.senan.xyz/gonic/jukebox"
"go.senan.xyz/gonic/scanner"
"go.senan.xyz/gonic/server/assets"
"go.senan.xyz/gonic/server/ctrladmin"
@@ -46,7 +47,9 @@ func New(opts Options) *Server {
MusicPath: opts.MusicPath,
ProxyPrefix: opts.ProxyPrefix,
Scanner: scanner,
Jukebox: &jukebox.Jukebox{},
}
base.Jukebox.Init(opts.MusicPath)
// router with common wares for admin / subsonic
r := mux.NewRouter()
r.Use(base.WithLogging)
@@ -154,6 +157,7 @@ func setupSubsonic(r *mux.Router, ctrl *ctrlsubsonic.Controller) {
r.Handle("/getSong{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetSong))
r.Handle("/getRandomSongs{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetRandomSongs))
r.Handle("/getSongsByGenre{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetSongsByGenre))
r.Handle("/jukeboxControl{_:(?:\\.view)?}", ctrl.H(ctrl.ServeJukebox))
// ** begin raw
r.Handle("/download{_:(?:\\.view)?}", ctrl.HR(ctrl.ServeDownload))
r.Handle("/getCoverArt{_:(?:\\.view)?}", ctrl.HR(ctrl.ServeGetCoverArt))