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:
Kendall Garner
2023-01-18 01:22:54 +00:00
committed by GitHub
parent 5564f00838
commit 93adda66d9
33 changed files with 797 additions and 188 deletions
+27 -1
View File
@@ -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
}