add routes

This commit is contained in:
sentriz
2019-04-14 15:28:23 +01:00
parent 76ad2ec4eb
commit 87efb3b3c5
11 changed files with 481 additions and 285 deletions

View File

@@ -1,101 +1,98 @@
package subsonic
import "encoding/xml"
import "time"
type Album struct {
XMLName xml.Name `xml:"album" json:"-"`
ID uint `xml:"id,attr" json:"id"`
Name string `xml:"name,attr" json:"name"`
ArtistID uint `xml:"artistId,attr" json:"artistId"`
ArtistName string `xml:"artist,attr" json:"artist"`
SongCount uint `xml:"songCount,attr" json:"songCount"`
Duration uint `xml:"duration,attr" json:"duration"`
CoverArt string `xml:"coverArt,attr" json:"coverArt"`
Created string `xml:"created,attr" json:"created"`
Songs *[]*Song `xml:"song" json:"song,omitempty"`
ID uint `xml:"id,attr" json:"id"`
Name string `xml:"name,attr" json:"name"`
ArtistID uint `xml:"artistId,attr" json:"artistId"`
Artist string `xml:"artist,attr" json:"artist"`
TrackCount uint `xml:"songCount,attr" json:"songCount"`
Duration uint `xml:"duration,attr" json:"duration"`
CoverID uint `xml:"coverArt,attr" json:"coverArt"`
Created time.Time `xml:"created,attr" json:"created"`
Tracks []*Track `xml:"song" json:"song,omitempty"`
}
type RandomSongs struct {
XMLName xml.Name `xml:"randomSongs" json:"-"`
Songs []*Song `xml:"song" json:"song"`
type RandomTracks struct {
Tracks []*Track `xml:"song" json:"song"`
}
type Song struct {
XMLName xml.Name `xml:"song" json:"-"`
ID uint `xml:"id,attr" json:"id"`
Parent uint `xml:"parent,attr" json:"parent"`
Title string `xml:"title,attr" json:"title"`
Album string `xml:"album,attr" json:"album"`
Artist string `xml:"artist,attr" json:"artist"`
IsDir bool `xml:"isDir,attr" json:"isDir"`
CoverArt string `xml:"coverArt,attr" json:"coverArt"`
Created string `xml:"created,attr" json:"created"`
Duration uint `xml:"duration,attr" json:"duration"`
Genre string `xml:"genre,attr" json:"genre"`
BitRate uint `xml:"bitRate,attr" json:"bitRate"`
Size uint `xml:"size,attr" json:"size"`
Suffix string `xml:"suffix,attr" json:"suffix"`
ContentType string `xml:"contentType,attr" json:"contentType"`
IsVideo bool `xml:"isVideo,attr" json:"isVideo"`
Path string `xml:"path,attr" json:"path"`
AlbumID uint `xml:"albumId,attr" json:"albumId"`
ArtistID uint `xml:"artistId,attr" json:"artistId"`
TrackNo uint `xml:"track,attr" json:"track"`
Type string `xml:"type,attr" json:"type"`
type Track struct {
ID uint `xml:"id,attr" json:"id"`
Parent uint `xml:"parent,attr" json:"parent"`
Title string `xml:"title,attr" json:"title"`
Album string `xml:"album,attr" json:"album"`
Artist string `xml:"artist,attr" json:"artist"`
IsDir bool `xml:"isDir,attr" json:"isDir"`
CoverID uint `xml:"coverArt,attr" json:"coverArt"`
Created time.Time `xml:"created,attr" json:"created"`
Duration uint `xml:"duration,attr" json:"duration"`
Genre string `xml:"genre,attr" json:"genre"`
BitRate uint `xml:"bitRate,attr" json:"bitRate"`
Size uint `xml:"size,attr" json:"size"`
Suffix string `xml:"suffix,attr" json:"suffix"`
ContentType string `xml:"contentType,attr" json:"contentType"`
IsVideo bool `xml:"isVideo,attr" json:"isVideo"`
Path string `xml:"path,attr" json:"path"`
AlbumID uint `xml:"albumId,attr" json:"albumId"`
ArtistID uint `xml:"artistId,attr" json:"artistId"`
TrackNo uint `xml:"track,attr" json:"track"`
Type string `xml:"type,attr" json:"type"`
}
type Artist struct {
XMLName xml.Name `xml:"artist" json:"-"`
ID uint `xml:"id,attr" json:"id"`
Name string `xml:"name,attr" json:"name"`
CoverArt string `xml:"coverArt,attr" json:"coverArt,omitempty"`
CoverID uint `xml:"coverArt,attr" json:"coverArt,omitempty"`
AlbumCount uint `xml:"albumCount,attr" json:"albumCount,omitempty"`
Albums []*Album `xml:"album,omitempty" json:"album,omitempty"`
}
type Indexes struct {
LastModified uint `xml:"lastModified,attr" json:"lastModified"`
Index *[]*Index `xml:"index" json:"index"`
LastModified uint `xml:"lastModified,attr" json:"lastModified"`
Index []*Index `xml:"index" json:"index"`
}
type Index struct {
XMLName xml.Name `xml:"index" json:"-"`
Name string `xml:"name,attr" json:"name"`
Artists []*Artist `xml:"artist" json:"artist"`
}
type Directory struct {
XMLName xml.Name `xml:"directory" json:"-"`
ID uint `xml:"id,attr" json:"id"`
Parent uint `xml:"parent,attr" json:"parent"`
Name string `xml:"name,attr" json:"name"`
Starred string `xml:"starred,attr,omitempty" json:"starred,omitempty"`
Children []Child `xml:"child" json:"child"`
ID uint `xml:"id,attr" json:"id"`
Parent uint `xml:"parent,attr" json:"parent"`
Name string `xml:"name,attr" json:"name"`
Starred string `xml:"starred,attr,omitempty" json:"starred,omitempty"`
Children []Child `xml:"child" json:"child"`
}
type Child struct {
XMLName xml.Name `xml:"child" json:"-"`
ID uint `xml:"id,attr" json:"id,omitempty"`
Parent uint `xml:"parent,attr" json:"parent,omitempty"`
Title string `xml:"title,attr" json:"title,omitempty"`
IsDir bool `xml:"isDir,attr" json:"isDir,omitempty"`
Album string `xml:"album,attr,omitempty" json:"album,omitempty"`
AlbumID uint `xml:"albumId,attr,omitempty" json:"albumId,omitempty"`
Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
ArtistID uint `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
Track uint `xml:"track,attr,omitempty" json:"track,omitempty"`
Year uint `xml:"year,attr,omitempty" json:"year,omitempty"`
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
CoverArt uint `xml:"coverart,attr" json:"coverArt,omitempty"`
Size uint `xml:"size,attr,omitempty" json:"size,omitempty"`
ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
Suffix string `xml:"suffix,attr,omitempty" json:"suffix,omitempty"`
Duration uint `xml:"duration,attr,omitempty" json:"duration"`
BitRate uint `xml:"bitRate,attr,omitempty" json:"bitrate,omitempty"`
Path string `xml:"path,attr,omitempty" json:"path,omitempty"`
ID uint `xml:"id,attr" json:"id,omitempty"`
Parent uint `xml:"parent,attr" json:"parent,omitempty"`
Title string `xml:"title,attr" json:"title,omitempty"`
IsDir bool `xml:"isDir,attr" json:"isDir,omitempty"`
Album string `xml:"album,attr,omitempty" json:"album,omitempty"`
AlbumID uint `xml:"albumId,attr,omitempty" json:"albumId,omitempty"`
Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
ArtistID uint `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
Track uint `xml:"track,attr,omitempty" json:"track,omitempty"`
Year uint `xml:"year,attr,omitempty" json:"year,omitempty"`
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
CoverID uint `xml:"coverArt,attr" json:"coverArt,omitempty"`
Size uint `xml:"size,attr,omitempty" json:"size,omitempty"`
ContentType string `xml:"contentType,attr,omitempty" json:"contentType,omitempty"`
Suffix string `xml:"suffix,attr,omitempty" json:"suffix,omitempty"`
Duration uint `xml:"duration,attr,omitempty" json:"duration"`
BitRate uint `xml:"bitRate,attr,omitempty" json:"bitrate,omitempty"`
Path string `xml:"path,attr,omitempty" json:"path,omitempty"`
}
type MusicFolder struct {
ID uint `xml:"id,attr" json:"id,omitempty"`
Name string `xml:"name,attr" json:"name,omitempty"`
}
type Licence struct {
XMLName xml.Name `xml:"license" json:"-"`
Valid bool `xml:"valid,attr,omitempty" json:"valid,omitempty"`
Valid bool `xml:"valid,attr,omitempty" json:"valid,omitempty"`
}

View File

@@ -2,36 +2,38 @@
package subsonic
import (
"encoding/xml"
)
import "encoding/xml"
var (
apiVersion = "1.9.0"
xmlns = "http://subsonic.org/restapi"
)
type MetaResponse struct {
XMLName xml.Name `xml:"subsonic-response" json:"-"`
*Response `json:"subsonic-response"`
}
type Response struct {
XMLName xml.Name `xml:"subsonic-response" json:"-"`
Status string `xml:"status,attr" json:"status"`
Version string `xml:"version,attr" json:"version"`
XMLNS string `xml:"xmlns,attr" json:"-"`
Error *Error `xml:"error" json:"error,omitempty"`
AlbumList2 *[]*Album `xml:"albumList2>album" json:"album,omitempty"`
Album *Album `xml:"album" json:"album,omitempty"`
Song *Song `xml:"song" json:"song,omitempty"`
Indexes *Indexes `xml:"indexes" json:"indexes,omitempty"`
Artists *[]*Index `xml:"artists>index" json:"artists,omitempty"`
Artist *Artist `xml:"artist" json:"artist,omitempty"`
MusicDirectory *Directory `xml:"directory" json:"directory,omitempty"`
RandomSongs *RandomSongs `xml:"randomSongs" json:"randomSongs,omitempty"`
Licence *Licence `xml:"license" json:"license,omitempty"`
Status string `xml:"status,attr" json:"status"`
Version string `xml:"version,attr" json:"version"`
XMLNS string `xml:"xmlns,attr" json:"-"`
Error *Error `xml:"error" json:"error,omitempty"`
Albums []*Album `xml:"albumList2>album" json:"albumList2,omitempty"`
Album *Album `xml:"album" json:"album,omitempty"`
Track *Track `xml:"song" json:"song,omitempty"`
Indexes *Indexes `xml:"indexes" json:"indexes,omitempty"`
Artists []*Index `xml:"artists>index" json:"artists,omitempty"`
Artist *Artist `xml:"artist" json:"artist,omitempty"`
Directory *Directory `xml:"directory" json:"directory,omitempty"`
RandomTracks *RandomTracks `xml:"randomSongs" json:"randomSongs,omitempty"`
MusicFolders []*MusicFolder `xml:"musicFolders>musicFolder" json:"musicFolders,omitempty"`
Licence *Licence `xml:"license" json:"license,omitempty"`
}
type Error struct {
XMLName xml.Name `xml:"error" json:"-"`
Code uint64 `xml:"code,attr" json:"code"`
Message string `xml:"message,attr" json:"message"`
Code uint64 `xml:"code,attr" json:"code"`
Message string `xml:"message,attr" json:"message"`
}
func NewResponse() *Response {