use new opensubsonic extensions response format
This commit is contained in:
@@ -37,7 +37,7 @@ func (c *Controller) ServePing(_ *http.Request) *spec.Response {
|
|||||||
|
|
||||||
func (c *Controller) ServeGetOpenSubsonicExtensions(_ *http.Request) *spec.Response {
|
func (c *Controller) ServeGetOpenSubsonicExtensions(_ *http.Request) *spec.Response {
|
||||||
sub := spec.NewResponse()
|
sub := spec.NewResponse()
|
||||||
sub.OpenSubsonicExtensions = spec.OpenSubsonicExtensions{}
|
sub.OpenSubsonicExtensions = &spec.OpenSubsonicExtensions{}
|
||||||
return sub
|
return sub
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,10 @@ type Response struct {
|
|||||||
XMLNS string `xml:"xmlns,attr" json:"-"`
|
XMLNS string `xml:"xmlns,attr" json:"-"`
|
||||||
|
|
||||||
// https://opensubsonic.netlify.app/docs/responses/subsonic-response/
|
// https://opensubsonic.netlify.app/docs/responses/subsonic-response/
|
||||||
Type string `xml:"type,attr" json:"type"`
|
Type string `xml:"type,attr" json:"type"`
|
||||||
ServerVersion string `xml:"serverVersion,attr" json:"serverVersion"`
|
ServerVersion string `xml:"serverVersion,attr" json:"serverVersion"`
|
||||||
OpenSubsonic bool `xml:"openSubsonic,attr" json:"openSubsonic"`
|
OpenSubsonic bool `xml:"openSubsonic,attr" json:"openSubsonic"`
|
||||||
OpenSubsonicExtensions OpenSubsonicExtensions `xml:"openSubsonicExtensions" json:"openSubsonicExtensions,omitempty"`
|
OpenSubsonicExtensions *OpenSubsonicExtensions `xml:"openSubsonicExtensions" json:"openSubsonicExtensions,omitempty"`
|
||||||
|
|
||||||
Error *Error `xml:"error" json:"error,omitempty"`
|
Error *Error `xml:"error" json:"error,omitempty"`
|
||||||
Albums *Albums `xml:"albumList" json:"albumList,omitempty"`
|
Albums *Albums `xml:"albumList" json:"albumList,omitempty"`
|
||||||
@@ -97,17 +97,13 @@ type Error struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewError(code int, message string, a ...interface{}) *Response {
|
func NewError(code int, message string, a ...interface{}) *Response {
|
||||||
return &Response{
|
r := NewResponse()
|
||||||
Status: "failed",
|
r.Status = "failed"
|
||||||
XMLNS: xmlns,
|
r.Error = &Error{
|
||||||
Version: apiVersion,
|
Code: code,
|
||||||
Error: &Error{
|
Message: fmt.Sprintf(message, a...),
|
||||||
Code: code,
|
|
||||||
Message: fmt.Sprintf(message, a...),
|
|
||||||
},
|
|
||||||
Type: gonic.Name,
|
|
||||||
ServerVersion: gonic.Version,
|
|
||||||
}
|
}
|
||||||
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
type Albums struct {
|
type Albums struct {
|
||||||
@@ -432,7 +428,12 @@ type Lyrics struct {
|
|||||||
Title string `xml:"title,attr,omitempty" json:"title,omitempty"`
|
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 {
|
func formatRating(rating float64) string {
|
||||||
if rating == 0 {
|
if rating == 0 {
|
||||||
|
|||||||
Reference in New Issue
Block a user