Skip to content

Commit

Permalink
feat(subsonic): add new getOpenSubsonicExtensions endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Sep 28, 2023
1 parent e0b1603 commit 59d78e0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions server/ctrlsubsonic/handlers_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ func (c *Controller) ServePing(_ *http.Request) *spec.Response {
return spec.NewResponse()
}

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

func (c *Controller) ServeScrobble(r *http.Request) *spec.Response {
user := r.Context().Value(CtxUser).(*db.User)
params := r.Context().Value(CtxParams).(params.Params)
Expand Down
4 changes: 3 additions & 1 deletion server/ctrlsubsonic/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ func AddRoutes(c *Controller, r *mux.Router) {

// common
r.Handle("/getLicense{_:(?:\\.view)?}", c.H(c.ServeGetLicence))
r.Handle("/ping{_:(?:\\.view)?}", c.H(c.ServePing))
r.Handle("/getOpenSubsonicExtensions{_:(?:\\.view)?}", c.H(c.ServeGetOpenSubsonicExtensions))

r.Handle("/getMusicFolders{_:(?:\\.view)?}", c.H(c.ServeGetMusicFolders))
r.Handle("/getScanStatus{_:(?:\\.view)?}", c.H(c.ServeGetScanStatus))
r.Handle("/ping{_:(?:\\.view)?}", c.H(c.ServePing))
r.Handle("/scrobble{_:(?:\\.view)?}", c.H(c.ServeScrobble))
r.Handle("/startScan{_:(?:\\.view)?}", c.H(c.ServeStartScan))
r.Handle("/getUser{_:(?:\\.view)?}", c.H(c.ServeGetUser))
Expand Down
8 changes: 6 additions & 2 deletions server/ctrlsubsonic/spec/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Error *Error `xml:"error" json:"error,omitempty"`
Albums *Albums `xml:"albumList" json:"albumList,omitempty"`
Expand Down Expand Up @@ -429,6 +431,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 ""
Expand Down

0 comments on commit 59d78e0

Please sign in to comment.