feat: add subsonic token auth and starred endpoints
This commit is contained in:
@@ -12,18 +12,20 @@ type Envelope struct {
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version"`
|
||||
Type string `json:"type"`
|
||||
Server string `json:"serverVersion"`
|
||||
OpenAPI bool `json:"openSubsonic"`
|
||||
Artists []ArtistRef `json:"artists,omitempty"`
|
||||
Artist *ArtistFull `json:"artist,omitempty"`
|
||||
Album *AlbumFull `json:"album,omitempty"`
|
||||
Song *SongFull `json:"song,omitempty"`
|
||||
RandomSong []SongRef `json:"randomSongs,omitempty"`
|
||||
ScanStatus *ScanStatus `json:"scanStatus,omitempty"`
|
||||
Error *ErrorRef `json:"error,omitempty"`
|
||||
Status string `json:"status"`
|
||||
Version string `json:"version"`
|
||||
Type string `json:"type"`
|
||||
Server string `json:"serverVersion"`
|
||||
OpenAPI bool `json:"openSubsonic"`
|
||||
Artists []ArtistRef `json:"artists,omitempty"`
|
||||
Artist *ArtistFull `json:"artist,omitempty"`
|
||||
Album *AlbumFull `json:"album,omitempty"`
|
||||
Song *SongFull `json:"song,omitempty"`
|
||||
RandomSong []SongRef `json:"randomSongs,omitempty"`
|
||||
SearchResult3 *SearchResult3 `json:"searchResult3,omitempty"`
|
||||
Starred2 *Starred2 `json:"starred2,omitempty"`
|
||||
ScanStatus *ScanStatus `json:"scanStatus,omitempty"`
|
||||
Error *ErrorRef `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type ArtistRef struct {
|
||||
@@ -32,10 +34,13 @@ type ArtistRef struct {
|
||||
}
|
||||
|
||||
type SongRef struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Album string `json:"album"`
|
||||
Artist string `json:"artist"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Album string `json:"album"`
|
||||
Artist string `json:"artist"`
|
||||
AlbumID string `json:"albumId,omitempty"`
|
||||
ArtistID string `json:"artistId,omitempty"`
|
||||
CoverArt string `json:"coverArt,omitempty"`
|
||||
}
|
||||
|
||||
type ArtistFull struct {
|
||||
@@ -78,12 +83,24 @@ type SongFull struct {
|
||||
}
|
||||
|
||||
type ScanStatus struct {
|
||||
Scanning bool `json:"scanning"`
|
||||
Count int `json:"count"`
|
||||
FolderCount int `json:"folderCount"`
|
||||
LastError string `json:"lastError,omitempty"`
|
||||
StartedAt string `json:"startedAt,omitempty"`
|
||||
FinishedAt string `json:"finishedAt,omitempty"`
|
||||
Scanning bool `json:"scanning"`
|
||||
Count int `json:"count"`
|
||||
FolderCount int `json:"folderCount"`
|
||||
LastError string `json:"lastError,omitempty"`
|
||||
StartedAt string `json:"startedAt,omitempty"`
|
||||
FinishedAt string `json:"finishedAt,omitempty"`
|
||||
}
|
||||
|
||||
type SearchResult3 struct {
|
||||
Artist []ArtistRef `json:"artist,omitempty"`
|
||||
Album []AlbumRef `json:"album,omitempty"`
|
||||
Song []SongRef `json:"song,omitempty"`
|
||||
}
|
||||
|
||||
type Starred2 struct {
|
||||
Artist []ArtistRef `json:"artist,omitempty"`
|
||||
Album []AlbumRef `json:"album,omitempty"`
|
||||
Song []SongRef `json:"song,omitempty"`
|
||||
}
|
||||
|
||||
type ErrorRef struct {
|
||||
@@ -118,10 +135,13 @@ func RandomSongsResponse(tracks []library.Track) Envelope {
|
||||
response := PingResponse()
|
||||
for _, track := range tracks {
|
||||
response.SubsonicResponse.RandomSong = append(response.SubsonicResponse.RandomSong, SongRef{
|
||||
ID: track.ID,
|
||||
Title: track.Title,
|
||||
Album: track.AlbumTitle,
|
||||
Artist: track.ArtistName,
|
||||
ID: track.ID,
|
||||
Title: track.Title,
|
||||
Album: track.AlbumTitle,
|
||||
Artist: track.ArtistName,
|
||||
AlbumID: track.AlbumID,
|
||||
ArtistID: track.ArtistID,
|
||||
CoverArt: track.CoverArtID,
|
||||
})
|
||||
}
|
||||
return response
|
||||
@@ -149,6 +169,74 @@ func ArtistResponse(artist library.ArtistDetail) Envelope {
|
||||
return response
|
||||
}
|
||||
|
||||
func Search3Response(results library.SearchResults) Envelope {
|
||||
response := PingResponse()
|
||||
payload := &SearchResult3{}
|
||||
for _, artist := range results.Artists {
|
||||
payload.Artist = append(payload.Artist, ArtistRef{
|
||||
ID: artist.ID,
|
||||
Name: artist.Name,
|
||||
})
|
||||
}
|
||||
for _, album := range results.Albums {
|
||||
payload.Album = append(payload.Album, AlbumRef{
|
||||
ID: album.ID,
|
||||
Name: album.Title,
|
||||
Artist: album.ArtistName,
|
||||
ArtistID: album.ArtistID,
|
||||
Year: album.Year,
|
||||
CoverArt: album.CoverArtID,
|
||||
})
|
||||
}
|
||||
for _, track := range results.Tracks {
|
||||
payload.Song = append(payload.Song, SongRef{
|
||||
ID: track.ID,
|
||||
Title: track.Title,
|
||||
Album: track.AlbumTitle,
|
||||
Artist: track.ArtistName,
|
||||
AlbumID: track.AlbumID,
|
||||
ArtistID: track.ArtistID,
|
||||
CoverArt: track.CoverArtID,
|
||||
})
|
||||
}
|
||||
response.SubsonicResponse.SearchResult3 = payload
|
||||
return response
|
||||
}
|
||||
|
||||
func Starred2Response(results library.StarredResults) Envelope {
|
||||
response := PingResponse()
|
||||
payload := &Starred2{}
|
||||
for _, artist := range results.Artists {
|
||||
payload.Artist = append(payload.Artist, ArtistRef{
|
||||
ID: artist.ID,
|
||||
Name: artist.Name,
|
||||
})
|
||||
}
|
||||
for _, album := range results.Albums {
|
||||
payload.Album = append(payload.Album, AlbumRef{
|
||||
ID: album.ID,
|
||||
Name: album.Title,
|
||||
Artist: album.ArtistName,
|
||||
ArtistID: album.ArtistID,
|
||||
Year: album.Year,
|
||||
CoverArt: album.CoverArtID,
|
||||
})
|
||||
}
|
||||
for _, track := range results.Tracks {
|
||||
payload.Song = append(payload.Song, SongRef{
|
||||
ID: track.ID,
|
||||
Title: track.Title,
|
||||
Album: track.AlbumTitle,
|
||||
Artist: track.ArtistName,
|
||||
AlbumID: track.AlbumID,
|
||||
ArtistID: track.ArtistID,
|
||||
CoverArt: track.CoverArtID,
|
||||
})
|
||||
}
|
||||
response.SubsonicResponse.Starred2 = payload
|
||||
return response
|
||||
}
|
||||
|
||||
func AlbumResponse(album library.AlbumDetail) Envelope {
|
||||
response := PingResponse()
|
||||
item := &AlbumFull{
|
||||
|
||||
Reference in New Issue
Block a user