mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-19 00:04:15 +03:00
Change required fields in Subsonic Jukebox endpoint
See discussion here: https://gitlab.com/ultrasonic/ultrasonic/-/issues/1266#note_1621953651
This commit is contained in:
parent
0e3175ea17
commit
932152eb7e
@ -1,13 +1,13 @@
|
|||||||
package subsonic
|
package subsonic
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/navidrome/navidrome/core/playback"
|
"github.com/navidrome/navidrome/core/playback"
|
||||||
"github.com/navidrome/navidrome/log"
|
"github.com/navidrome/navidrome/log"
|
||||||
"github.com/navidrome/navidrome/server/subsonic/responses"
|
"github.com/navidrome/navidrome/server/subsonic/responses"
|
||||||
|
"github.com/navidrome/navidrome/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -38,7 +38,7 @@ func (api *Router) JukeboxControl(r *http.Request) (*responses.Subsonic, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Debug(fmt.Sprintf("processing action: %s", actionString))
|
log.Info(ctx, "JukeboxControl request received", "action", actionString)
|
||||||
|
|
||||||
switch actionString {
|
switch actionString {
|
||||||
case ActionGet:
|
case ActionGet:
|
||||||
@ -58,15 +58,8 @@ func (api *Router) JukeboxControl(r *http.Request) (*responses.Subsonic, error)
|
|||||||
case ActionStatus:
|
case ActionStatus:
|
||||||
return createResponse(pb.Status(ctx))
|
return createResponse(pb.Status(ctx))
|
||||||
case ActionSet:
|
case ActionSet:
|
||||||
ids, err := requiredParamStrings(r, "id")
|
ids := utils.ParamStrings(r, "id")
|
||||||
if err != nil {
|
return createResponse(pb.Set(ctx, ids))
|
||||||
return nil, newError(responses.ErrorMissingParameter, "missing parameter id, err: %s", err)
|
|
||||||
}
|
|
||||||
status, err := pb.Set(ctx, ids)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return statusResponse(status), nil
|
|
||||||
case ActionStart:
|
case ActionStart:
|
||||||
return createResponse(pb.Start(ctx))
|
return createResponse(pb.Start(ctx))
|
||||||
case ActionStop:
|
case ActionStop:
|
||||||
@ -77,18 +70,14 @@ func (api *Router) JukeboxControl(r *http.Request) (*responses.Subsonic, error)
|
|||||||
return nil, newError(responses.ErrorMissingParameter, "missing parameter index, err: %s", err)
|
return nil, newError(responses.ErrorMissingParameter, "missing parameter index, err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
offset, err := requiredParamInt(r, "offset")
|
offset := utils.ParamInt(r, "offset", 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
offset = 0
|
offset = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return createResponse(pb.Skip(ctx, index, offset))
|
return createResponse(pb.Skip(ctx, index, offset))
|
||||||
case ActionAdd:
|
case ActionAdd:
|
||||||
ids, err := requiredParamStrings(r, "id")
|
ids := utils.ParamStrings(r, "id")
|
||||||
if err != nil {
|
|
||||||
return nil, newError(responses.ErrorMissingParameter, "missing parameter id, err: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return createResponse(pb.Add(ctx, ids))
|
return createResponse(pb.Add(ctx, ids))
|
||||||
case ActionClear:
|
case ActionClear:
|
||||||
return createResponse(pb.Clear(ctx))
|
return createResponse(pb.Clear(ctx))
|
||||||
@ -109,7 +98,7 @@ func (api *Router) JukeboxControl(r *http.Request) (*responses.Subsonic, error)
|
|||||||
|
|
||||||
gain, err := strconv.ParseFloat(gainStr, 32)
|
gain, err := strconv.ParseFloat(gainStr, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, newError(responses.ErrorMissingParameter, "error parsing gain integer value, err: %s", err)
|
return nil, newError(responses.ErrorMissingParameter, "error parsing gain float value, err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return createResponse(pb.SetGain(ctx, float32(gain)))
|
return createResponse(pb.SetGain(ctx, float32(gain)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user