feat(subsonic): add getOpenSubsonicExtensions endpoint and openSubsonic response key

This commit is contained in:
sentriz
2023-09-28 21:11:15 +01:00
parent e0b1603c00
commit 2caee441ca
30 changed files with 158 additions and 118 deletions

View File

@@ -26,8 +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"`
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"`
@@ -73,6 +75,7 @@ func NewResponse() *Response {
Version: apiVersion,
Type: gonic.Name,
ServerVersion: gonic.Version,
OpenSubsonic: true,
}
}
@@ -429,6 +432,8 @@ type Lyrics struct {
Title string `xml:"title,attr,omitempty" json:"title,omitempty"`
}
type OpenSubsonicExtensions map[string][]int
func formatRating(rating float64) string {
if rating == 0 {
return ""