Get album info (when available) from Last.fm, add getAlbumInfo endpoint (#2061)
* lastfm album.getInfo, getAlbuminfo(2) endpoints * ... for description and reduce not found log level * address first comments * return all images * Update migration timestamp * Handle a few edge cases * Add CoverArtPriority option to retrieve albumart from external sources * Make agents methods more descriptive * Use Last.fm name consistently Co-authored-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -154,6 +154,7 @@ func (api *Router) GetArtist(r *http.Request) (*responses.Subsonic, error) {
|
||||
|
||||
func (api *Router) GetAlbum(r *http.Request) (*responses.Subsonic, error) {
|
||||
id := utils.ParamString(r, "id")
|
||||
|
||||
ctx := r.Context()
|
||||
|
||||
album, err := api.ds.Album(ctx).Get(id)
|
||||
@@ -177,6 +178,32 @@ func (api *Router) GetAlbum(r *http.Request) (*responses.Subsonic, error) {
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (api *Router) GetAlbumInfo(r *http.Request) (*responses.Subsonic, error) {
|
||||
id, err := requiredParamString(r, "id")
|
||||
ctx := r.Context()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
album, err := api.externalMetadata.UpdateAlbumInfo(ctx, id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response := newResponse()
|
||||
response.AlbumInfo = &responses.AlbumInfo{}
|
||||
response.AlbumInfo.Notes = album.Description
|
||||
response.AlbumInfo.SmallImageUrl = album.SmallImageUrl
|
||||
response.AlbumInfo.MediumImageUrl = album.MediumImageUrl
|
||||
response.AlbumInfo.LargeImageUrl = album.LargeImageUrl
|
||||
response.AlbumInfo.LastFmUrl = album.ExternalUrl
|
||||
response.AlbumInfo.MusicBrainzID = album.MbzAlbumID
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (api *Router) GetSong(r *http.Request) (*responses.Subsonic, error) {
|
||||
id := utils.ParamString(r, "id")
|
||||
ctx := r.Context()
|
||||
@@ -397,7 +424,6 @@ func (api *Router) buildAlbum(ctx context.Context, album *model.Album, mfs model
|
||||
if album.Starred {
|
||||
dir.Starred = &album.StarredAt
|
||||
}
|
||||
|
||||
dir.Song = childrenFromMediaFiles(ctx, mfs)
|
||||
return dir
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user