mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-16 04:00:38 +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
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/navidrome/navidrome/core/playback"
|
||||
"github.com/navidrome/navidrome/log"
|
||||
"github.com/navidrome/navidrome/server/subsonic/responses"
|
||||
"github.com/navidrome/navidrome/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -38,7 +38,7 @@ func (api *Router) JukeboxControl(r *http.Request) (*responses.Subsonic, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Debug(fmt.Sprintf("processing action: %s", actionString))
|
||||
log.Info(ctx, "JukeboxControl request received", "action", actionString)
|
||||
|
||||
switch actionString {
|
||||
case ActionGet:
|
||||
@ -58,15 +58,8 @@ func (api *Router) JukeboxControl(r *http.Request) (*responses.Subsonic, error)
|
||||
case ActionStatus:
|
||||
return createResponse(pb.Status(ctx))
|
||||
case ActionSet:
|
||||
ids, err := requiredParamStrings(r, "id")
|
||||
if err != nil {
|
||||
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
|
||||
ids := utils.ParamStrings(r, "id")
|
||||
return createResponse(pb.Set(ctx, ids))
|
||||
case ActionStart:
|
||||
return createResponse(pb.Start(ctx))
|
||||
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)
|
||||
}
|
||||
|
||||
offset, err := requiredParamInt(r, "offset")
|
||||
offset := utils.ParamInt(r, "offset", 0)
|
||||
if err != nil {
|
||||
offset = 0
|
||||
}
|
||||
|
||||
return createResponse(pb.Skip(ctx, index, offset))
|
||||
case ActionAdd:
|
||||
ids, err := requiredParamStrings(r, "id")
|
||||
if err != nil {
|
||||
return nil, newError(responses.ErrorMissingParameter, "missing parameter id, err: %s", err)
|
||||
}
|
||||
|
||||
ids := utils.ParamStrings(r, "id")
|
||||
return createResponse(pb.Add(ctx, ids))
|
||||
case ActionClear:
|
||||
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)
|
||||
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)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user