Skip to content

Commit

Permalink
use new opensubsonic extensions response format
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Sep 30, 2023
1 parent b6e01fa commit adceff1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion server/ctrlsubsonic/handlers_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (c *Controller) ServePing(_ *http.Request) *spec.Response {

func (c *Controller) ServeGetOpenSubsonicExtensions(_ *http.Request) *spec.Response {
sub := spec.NewResponse()
sub.OpenSubsonicExtensions = spec.OpenSubsonicExtensions{}
sub.OpenSubsonicExtensions = &spec.OpenSubsonicExtensions{}
return sub
}

Expand Down
31 changes: 16 additions & 15 deletions server/ctrlsubsonic/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ type Response struct {
XMLNS string `xml:"xmlns,attr" json:"-"`

// https://opensubsonic.netlify.app/docs/responses/subsonic-response/
Type string `xml:"type,attr" json:"type"`
ServerVersion string `xml:"serverVersion,attr" json:"serverVersion"`
OpenSubsonic bool `xml:"openSubsonic,attr" json:"openSubsonic"`
OpenSubsonicExtensions OpenSubsonicExtensions `xml:"openSubsonicExtensions" json:"openSubsonicExtensions,omitempty"`
Type string `xml:"type,attr" json:"type"`
ServerVersion string `xml:"serverVersion,attr" json:"serverVersion"`
OpenSubsonic bool `xml:"openSubsonic,attr" json:"openSubsonic"`
OpenSubsonicExtensions *OpenSubsonicExtensions `xml:"openSubsonicExtensions" json:"openSubsonicExtensions,omitempty"`

Error *Error `xml:"error" json:"error,omitempty"`
Albums *Albums `xml:"albumList" json:"albumList,omitempty"`
Expand Down Expand Up @@ -97,17 +97,13 @@ type Error struct {
}

func NewError(code int, message string, a ...interface{}) *Response {
return &Response{
Status: "failed",
XMLNS: xmlns,
Version: apiVersion,
Error: &Error{
Code: code,
Message: fmt.Sprintf(message, a...),
},
Type: gonic.Name,
ServerVersion: gonic.Version,
r := NewResponse()
r.Status = "failed"
r.Error = &Error{
Code: code,
Message: fmt.Sprintf(message, a...),
}
return r
}

type Albums struct {
Expand Down Expand Up @@ -432,7 +428,12 @@ type Lyrics struct {
Title string `xml:"title,attr,omitempty" json:"title,omitempty"`
}

type OpenSubsonicExtensions map[string][]int
type OpenSubsonicExtension struct {
Name string `xml:"name,attr" json:"name"`
Versions []int `xml:"versions" json:"versions"`
}

type OpenSubsonicExtensions []OpenSubsonicExtension

func formatRating(rating float64) string {
if rating == 0 {
Expand Down

0 comments on commit adceff1

Please sign in to comment.