From e8abe0877004aafd62fe5168743fab5d817311bc Mon Sep 17 00:00:00 2001 From: sentriz Date: Sun, 9 Feb 2020 15:17:02 +0000 Subject: [PATCH] add some unimplemented routes --- server/ctrlsubsonic/handlers_common.go | 8 +++++ server/ctrlsubsonic/handlers_unimplemented.go | 28 ++++++++++++++++++ server/ctrlsubsonic/spec/spec.go | 29 ++++++++++++++++++- server/server.go | 27 +++++++++-------- 4 files changed, 77 insertions(+), 15 deletions(-) create mode 100644 server/ctrlsubsonic/handlers_unimplemented.go diff --git a/server/ctrlsubsonic/handlers_common.go b/server/ctrlsubsonic/handlers_common.go index 7534ca5..c34f6e7 100644 --- a/server/ctrlsubsonic/handlers_common.go +++ b/server/ctrlsubsonic/handlers_common.go @@ -211,3 +211,11 @@ func (c *Controller) ServeDeletePlaylist(r *http.Request) *spec.Response { Delete(&model.Playlist{}) return spec.NewResponse() } + +func (c *Controller) ServeGetPlayQueue(r *http.Request) *spec.Response { + return spec.NewResponse() +} + +func (c *Controller) ServeSavePlayQueue(r *http.Request) *spec.Response { + return spec.NewResponse() +} diff --git a/server/ctrlsubsonic/handlers_unimplemented.go b/server/ctrlsubsonic/handlers_unimplemented.go new file mode 100644 index 0000000..93c5f80 --- /dev/null +++ b/server/ctrlsubsonic/handlers_unimplemented.go @@ -0,0 +1,28 @@ +package ctrlsubsonic + +import ( + "net/http" + + "senan.xyz/g/gonic/server/ctrlsubsonic/spec" +) + +// NOTE: when these are implemented, they should be moved to their +// respective _by_folder or _by_tag file + +func (c *Controller) ServeGetArtistInfo(r *http.Request) *spec.Response { + sub := spec.NewResponse() + sub.ArtistInfo = &spec.ArtistInfo{} + return sub +} + +func (c *Controller) ServeGetArtistInfoTwo(r *http.Request) *spec.Response { + sub := spec.NewResponse() + sub.ArtistInfoTwo = &spec.ArtistInfo{} + return sub +} + +func (c *Controller) ServeGetGenres(r *http.Request) *spec.Response { + sub := spec.NewResponse() + sub.Genres = &spec.Genres{} + return sub +} diff --git a/server/ctrlsubsonic/spec/spec.go b/server/ctrlsubsonic/spec/spec.go index 77e834b..da7afa4 100644 --- a/server/ctrlsubsonic/spec/spec.go +++ b/server/ctrlsubsonic/spec/spec.go @@ -36,6 +36,9 @@ type Response struct { User *User `xml:"user" json:"user,omitempty"` Playlists *Playlists `xml:"playlists" json:"playlists,omitempty"` Playlist *Playlist `xml:"playlist" json:"playlist,omitempty"` + ArtistInfo *ArtistInfo `xml:"artistInfo" json:"artistInfo,omitempty"` + ArtistInfoTwo *ArtistInfo `xml:"artistInfo2" json:"artistInfo2,omitempty"` + Genres *Genres `xml:"genres" json:"genres,omitempty"` } func NewResponse() *Response { @@ -102,7 +105,7 @@ type Album struct { } type RandomTracks struct { - Tracks []*TrackChild `xml:"song" json:"song"` + Tracks []*TrackChild `xml:"song" json:"song"` } type TrackChild struct { @@ -222,3 +225,27 @@ type Playlist struct { Public bool `xml:"public,attr" json:"public,omitempty"` List []*TrackChild `xml:"entry" json:"entry,omitempty"` } + +type SimilarArtist struct { + ID string `xml:"id,attr" json:"id"` + Name string `xml:"name,attr" json:"name"` +} + +type ArtistInfo struct { + Biography string `xml:"biography" json:"biography"` + MusicBrainzID string `xml:"musicBrainzId" json:"musicBrainzId"` + LastFMURL string `xml:"lastFmUrl" json:"lastFmUrl"` + SmallImageURL string `xml:"smallImageUrl" json:"smallImageUrl"` + MediumImageURL string `xml:"mediumImageUrl" json:"mediumImageUrl"` + LargeImageURL string `xml:"largeImageUrl" json:"largeImageUrl"` + SimilarArtist []*SimilarArtist `xml:"similarArtist" json:"similarArtist"` +} + +type Genre struct { + SongCount string `xml:"songCount,attr"` + AlbumCount string `xml:"albumCount,attr"` +} + +type Genres struct { + Genre []*Genres `xml:"genre" json:"genre"` +} diff --git a/server/server.go b/server/server.go index abdcea8..ad4ac20 100644 --- a/server/server.go +++ b/server/server.go @@ -74,8 +74,7 @@ func New(opts Options) *Server { func (s *Server) SetupAdmin() error { ctrl := ctrladmin.New(s.base) - // - // begin public routes (creates session) + // ** begin public routes (creates session) routPublic := s.router.PathPrefix("/admin").Subrouter() routPublic.Use(ctrl.WithSession) routPublic.Handle("/login", ctrl.H(ctrl.ServeLogin)) @@ -88,8 +87,7 @@ func (s *Server) SetupAdmin() error { http.ServeContent(w, r, name, asset.ModTime, reader) }) }) - // - // begin user routes (if session is valid) + // ** begin user routes (if session is valid) routUser := routPublic.NewRoute().Subrouter() routUser.Use(ctrl.WithUserSession) routUser.HandleFunc("/logout", ctrl.ServeLogout) // "raw" handler, updates session @@ -99,8 +97,7 @@ func (s *Server) SetupAdmin() error { routUser.Handle("/link_lastfm_do", ctrl.H(ctrl.ServeLinkLastFMDo)) routUser.Handle("/unlink_lastfm_do", ctrl.H(ctrl.ServeUnlinkLastFMDo)) routUser.Handle("/upload_playlist_do", ctrl.H(ctrl.ServeUploadPlaylistDo)) - // - // begin admin routes (if session is valid, and is admin) + // ** begin admin routes (if session is valid, and is admin) routAdmin := routUser.NewRoute().Subrouter() routAdmin.Use(ctrl.WithAdminSession) routAdmin.Handle("/change_password", ctrl.H(ctrl.ServeChangePassword)) @@ -126,8 +123,7 @@ func (s *Server) SetupSubsonic() error { rout.Use(ctrl.WithParams) rout.Use(ctrl.WithRequiredParams) rout.Use(ctrl.WithUser) - // - // begin common + // ** begin common rout.Handle("/getLicense{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetLicence)) rout.Handle("/getMusicFolders{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetMusicFolders)) rout.Handle("/getScanStatus{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetScanStatus)) @@ -140,24 +136,27 @@ func (s *Server) SetupSubsonic() error { rout.Handle("/createPlaylist{_:(?:\\.view)?}", ctrl.H(ctrl.ServeUpdatePlaylist)) rout.Handle("/updatePlaylist{_:(?:\\.view)?}", ctrl.H(ctrl.ServeUpdatePlaylist)) rout.Handle("/deletePlaylist{_:(?:\\.view)?}", ctrl.H(ctrl.ServeDeletePlaylist)) - // - // begin raw + rout.Handle("/savePlayQueue{_:(?:\\.view)?}", ctrl.H(ctrl.ServeSavePlayQueue)) + rout.Handle("/getPlayQueue{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetPlayQueue)) + // ** begin raw rout.Handle("/download{_:(?:\\.view)?}", ctrl.HR(ctrl.ServeStream)) rout.Handle("/getCoverArt{_:(?:\\.view)?}", ctrl.HR(ctrl.ServeGetCoverArt)) rout.Handle("/stream{_:(?:\\.view)?}", ctrl.HR(ctrl.ServeStream)) - // - // begin browse by tag + // ** begin browse by tag rout.Handle("/getAlbum{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetAlbum)) rout.Handle("/getAlbumList2{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetAlbumListTwo)) rout.Handle("/getArtist{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetArtist)) rout.Handle("/getArtists{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetArtists)) rout.Handle("/search3{_:(?:\\.view)?}", ctrl.H(ctrl.ServeSearchThree)) - // - // begin browse by folder + // ** begin browse by folder rout.Handle("/getIndexes{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetIndexes)) rout.Handle("/getMusicDirectory{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetMusicDirectory)) rout.Handle("/getAlbumList{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetAlbumList)) rout.Handle("/search2{_:(?:\\.view)?}", ctrl.H(ctrl.ServeSearchTwo)) + // ** begin unimplemented + rout.Handle("/getArtistInfo{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetArtistInfo)) + rout.Handle("/getArtistInfo2{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetArtistInfoTwo)) + rout.Handle("/getGenres{_:(?:\\.view)?}", ctrl.H(ctrl.ServeGetGenres)) // middlewares should be run for not found handler // https://github.com/gorilla/mux/issues/416 notFoundHandler := ctrl.H(ctrl.ServeNotFound)