A person can mark songs, albums and artists as favourites. They are theirs
alone: never shown to a friend, never sent anywhere. Only what can be played is
listed.
- migration 0035 favorites, internal/favorites, storage.FavoritesRepo
- PUT/DELETE /me/favorites/{kind}/{id}, GET /me/favorites/{kind} and
GET /me/favorites/ids, in the OpenAPI spec
- catalog.Filter IDs now also reads artists by id
- OpenSubsonic: star, unstar, getStarred2, the starred date on songs, albums and
artists, and getAlbumList2 of type starred
241 lines
10 KiB
Go
241 lines
10 KiB
Go
package opensubsonic
|
|
|
|
import "encoding/xml"
|
|
|
|
// The answer of every call is one Response, written as JSON or as XML: the same tree has the tags of both. In XML
|
|
// the plain values are attributes and the lists are child elements; in JSON everything is a field and the lists are
|
|
// arrays. A field that is not set is left out of both.
|
|
|
|
// APIVersion is the Subsonic API that is spoken.
|
|
const APIVersion = "1.16.1"
|
|
|
|
// Response is the envelope of an answer.
|
|
type Response struct {
|
|
XMLName xml.Name `xml:"subsonic-response" json:"-"`
|
|
Xmlns string `xml:"xmlns,attr" json:"-"`
|
|
Status string `xml:"status,attr" json:"status"`
|
|
Version string `xml:"version,attr" json:"version"`
|
|
Type string `xml:"type,attr" json:"type"`
|
|
ServerVersion string `xml:"serverVersion,attr" json:"serverVersion"`
|
|
OpenSubsonic bool `xml:"openSubsonic,attr" json:"openSubsonic"`
|
|
|
|
Error *Error `xml:"error" json:"error,omitempty"`
|
|
License *License `xml:"license" json:"license,omitempty"`
|
|
OpenSubsonicExtensions []Extension `xml:"openSubsonicExtensions" json:"openSubsonicExtensions,omitempty"`
|
|
TokenInfo *TokenInfo `xml:"tokenInfo" json:"tokenInfo,omitempty"`
|
|
MusicFolders *MusicFolders `xml:"musicFolders" json:"musicFolders,omitempty"`
|
|
Artists *ArtistsID3 `xml:"artists" json:"artists,omitempty"`
|
|
Artist *ArtistWithAlbums `xml:"artist" json:"artist,omitempty"`
|
|
Album *AlbumWithSongs `xml:"album" json:"album,omitempty"`
|
|
Song *Child `xml:"song" json:"song,omitempty"`
|
|
Genres *Genres `xml:"genres" json:"genres,omitempty"`
|
|
AlbumList2 *AlbumList2 `xml:"albumList2" json:"albumList2,omitempty"`
|
|
RandomSongs *SongList `xml:"randomSongs" json:"randomSongs,omitempty"`
|
|
SongsByGenre *SongList `xml:"songsByGenre" json:"songsByGenre,omitempty"`
|
|
SearchResult3 *SearchResult `xml:"searchResult3" json:"searchResult3,omitempty"`
|
|
Starred2 *SearchResult `xml:"starred2" json:"starred2,omitempty"`
|
|
Playlists *PlaylistList `xml:"playlists" json:"playlists,omitempty"`
|
|
Playlist *Playlist `xml:"playlist" json:"playlist,omitempty"`
|
|
NowPlaying *NowPlaying `xml:"nowPlaying" json:"nowPlaying,omitempty"`
|
|
}
|
|
|
|
// PlaylistList are the playlists of a person.
|
|
type PlaylistList struct {
|
|
Playlist []Playlist `xml:"playlist" json:"playlist,omitempty"`
|
|
}
|
|
|
|
// Playlist is a playlist; Entry holds its songs when it is opened.
|
|
type Playlist struct {
|
|
ID string `xml:"id,attr" json:"id"`
|
|
Name string `xml:"name,attr" json:"name"`
|
|
Comment string `xml:"comment,attr,omitempty" json:"comment,omitempty"`
|
|
Owner string `xml:"owner,attr,omitempty" json:"owner,omitempty"`
|
|
Public bool `xml:"public,attr" json:"public"`
|
|
SongCount int `xml:"songCount,attr" json:"songCount"`
|
|
Duration int `xml:"duration,attr" json:"duration"`
|
|
Created string `xml:"created,attr" json:"created"`
|
|
Changed string `xml:"changed,attr" json:"changed"`
|
|
CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
|
|
Entry []Child `xml:"entry" json:"entry,omitempty"`
|
|
}
|
|
|
|
// NowPlaying is what is being played now. Sonda tells nobody what a person plays, so it is always empty.
|
|
type NowPlaying struct {
|
|
Entry []Child `xml:"entry" json:"entry,omitempty"`
|
|
}
|
|
|
|
// AlbumList2 is a list of albums.
|
|
type AlbumList2 struct {
|
|
Album []AlbumID3 `xml:"album" json:"album,omitempty"`
|
|
}
|
|
|
|
// SongList is a list of songs.
|
|
type SongList struct {
|
|
Song []Child `xml:"song" json:"song,omitempty"`
|
|
}
|
|
|
|
// SearchResult is what a search found: artists, albums and songs. The starred things have the same shape.
|
|
type SearchResult struct {
|
|
Artist []ArtistID3 `xml:"artist" json:"artist,omitempty"`
|
|
Album []AlbumID3 `xml:"album" json:"album,omitempty"`
|
|
Song []Child `xml:"song" json:"song,omitempty"`
|
|
}
|
|
|
|
// Error codes of the Subsonic API.
|
|
const (
|
|
ErrGeneric = 0
|
|
ErrMissingParam = 10
|
|
ErrWrongLogin = 40
|
|
ErrAuthConflict = 43
|
|
ErrBadAPIKey = 44
|
|
ErrNotAuthorized = 50
|
|
ErrNotFound = 70
|
|
errUnsupportedAuth = 42
|
|
)
|
|
|
|
// Error is the reason a call failed.
|
|
type Error struct {
|
|
Code int `xml:"code,attr" json:"code"`
|
|
Message string `xml:"message,attr,omitempty" json:"message,omitempty"`
|
|
}
|
|
|
|
// License says the server is licensed: it always is.
|
|
type License struct {
|
|
Valid bool `xml:"valid,attr" json:"valid"`
|
|
}
|
|
|
|
// Extension is an OpenSubsonic extension that the server speaks.
|
|
type Extension struct {
|
|
Name string `xml:"name,attr" json:"name"`
|
|
Versions []int `xml:"versions" json:"versions"`
|
|
}
|
|
|
|
// TokenInfo says whose the login of the call is.
|
|
type TokenInfo struct {
|
|
Username string `xml:"username,attr" json:"username"`
|
|
}
|
|
|
|
// MusicFolders are the libraries.
|
|
type MusicFolders struct {
|
|
MusicFolder []MusicFolder `xml:"musicFolder" json:"musicFolder"`
|
|
}
|
|
|
|
// MusicFolder is one library.
|
|
type MusicFolder struct {
|
|
ID int64 `xml:"id,attr" json:"id"`
|
|
Name string `xml:"name,attr" json:"name"`
|
|
}
|
|
|
|
// ArtistsID3 are the artists, in groups by their first letter.
|
|
type ArtistsID3 struct {
|
|
IgnoredArticles string `xml:"ignoredArticles,attr" json:"ignoredArticles"`
|
|
Index []Index `xml:"index" json:"index"`
|
|
}
|
|
|
|
// Index is the artists whose name starts with one letter.
|
|
type Index struct {
|
|
Name string `xml:"name,attr" json:"name"`
|
|
Artist []ArtistID3 `xml:"artist" json:"artist"`
|
|
}
|
|
|
|
// ArtistID3 is an artist.
|
|
type ArtistID3 struct {
|
|
ID string `xml:"id,attr" json:"id"`
|
|
Name string `xml:"name,attr" json:"name"`
|
|
AlbumCount int `xml:"albumCount,attr" json:"albumCount"`
|
|
CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
|
|
Starred string `xml:"starred,attr,omitempty" json:"starred,omitempty"`
|
|
}
|
|
|
|
// ArtistWithAlbums is an artist and its albums.
|
|
type ArtistWithAlbums struct {
|
|
ArtistID3
|
|
Album []AlbumID3 `xml:"album" json:"album,omitempty"`
|
|
}
|
|
|
|
// ArtistRef is an artist credited on a song or an album, in the OpenSubsonic fields.
|
|
type ArtistRef struct {
|
|
ID string `xml:"id,attr" json:"id"`
|
|
Name string `xml:"name,attr" json:"name"`
|
|
}
|
|
|
|
// ItemGenre is a genre of a song or an album, in the OpenSubsonic fields.
|
|
type ItemGenre struct {
|
|
Name string `xml:"name,attr" json:"name"`
|
|
}
|
|
|
|
// AlbumID3 is an album.
|
|
type AlbumID3 struct {
|
|
ID string `xml:"id,attr" json:"id"`
|
|
Name string `xml:"name,attr" json:"name"`
|
|
Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
|
|
ArtistID string `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
|
|
CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
|
|
SongCount int `xml:"songCount,attr" json:"songCount"`
|
|
Duration int `xml:"duration,attr" json:"duration"`
|
|
Created string `xml:"created,attr" json:"created"`
|
|
Starred string `xml:"starred,attr,omitempty" json:"starred,omitempty"`
|
|
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
|
|
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
|
|
DisplayArtist string `xml:"displayArtist,attr,omitempty" json:"displayArtist,omitempty"`
|
|
Artists []ArtistRef `xml:"artists" json:"artists,omitempty"`
|
|
Genres []ItemGenre `xml:"genres" json:"genres,omitempty"`
|
|
}
|
|
|
|
// AlbumWithSongs is an album and its songs.
|
|
type AlbumWithSongs struct {
|
|
AlbumID3
|
|
Song []Child `xml:"song" json:"song,omitempty"`
|
|
}
|
|
|
|
// ReplayGain is how loud a song is, as its file says.
|
|
type ReplayGain struct {
|
|
TrackGain *float64 `xml:"trackGain,attr,omitempty" json:"trackGain,omitempty"`
|
|
AlbumGain *float64 `xml:"albumGain,attr,omitempty" json:"albumGain,omitempty"`
|
|
TrackPeak *float64 `xml:"trackPeak,attr,omitempty" json:"trackPeak,omitempty"`
|
|
AlbumPeak *float64 `xml:"albumPeak,attr,omitempty" json:"albumPeak,omitempty"`
|
|
}
|
|
|
|
// Child is a song.
|
|
type Child struct {
|
|
ID string `xml:"id,attr" json:"id"`
|
|
Parent string `xml:"parent,attr,omitempty" json:"parent,omitempty"`
|
|
IsDir bool `xml:"isDir,attr" json:"isDir"`
|
|
Title string `xml:"title,attr" json:"title"`
|
|
Album string `xml:"album,attr,omitempty" json:"album,omitempty"`
|
|
Artist string `xml:"artist,attr,omitempty" json:"artist,omitempty"`
|
|
Track int `xml:"track,attr,omitempty" json:"track,omitempty"`
|
|
Year int `xml:"year,attr,omitempty" json:"year,omitempty"`
|
|
Genre string `xml:"genre,attr,omitempty" json:"genre,omitempty"`
|
|
CoverArt string `xml:"coverArt,attr,omitempty" json:"coverArt,omitempty"`
|
|
Size int64 `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 int `xml:"duration,attr,omitempty" json:"duration,omitempty"`
|
|
BitRate int `xml:"bitRate,attr,omitempty" json:"bitRate,omitempty"`
|
|
Path string `xml:"path,attr,omitempty" json:"path,omitempty"`
|
|
DiscNumber int `xml:"discNumber,attr,omitempty" json:"discNumber,omitempty"`
|
|
Created string `xml:"created,attr,omitempty" json:"created,omitempty"`
|
|
Starred string `xml:"starred,attr,omitempty" json:"starred,omitempty"`
|
|
AlbumID string `xml:"albumId,attr,omitempty" json:"albumId,omitempty"`
|
|
ArtistID string `xml:"artistId,attr,omitempty" json:"artistId,omitempty"`
|
|
Type string `xml:"type,attr,omitempty" json:"type,omitempty"`
|
|
MediaType string `xml:"mediaType,attr,omitempty" json:"mediaType,omitempty"`
|
|
IsVideo bool `xml:"isVideo,attr" json:"isVideo"`
|
|
DisplayArtist string `xml:"displayArtist,attr,omitempty" json:"displayArtist,omitempty"`
|
|
Artists []ArtistRef `xml:"artists" json:"artists,omitempty"`
|
|
Genres []ItemGenre `xml:"genres" json:"genres,omitempty"`
|
|
ReplayGain *ReplayGain `xml:"replayGain" json:"replayGain,omitempty"`
|
|
}
|
|
|
|
// Genres are the genres of the music.
|
|
type Genres struct {
|
|
Genre []GenreEntry `xml:"genre" json:"genre"`
|
|
}
|
|
|
|
// GenreEntry is a genre, with how many songs and albums have it.
|
|
type GenreEntry struct {
|
|
Value string `xml:",chardata" json:"value"`
|
|
SongCount int `xml:"songCount,attr" json:"songCount"`
|
|
AlbumCount int `xml:"albumCount,attr" json:"albumCount"`
|
|
}
|