Fixed: Album lookup API endpoint updated for new DB schema (#693)

pull/700/head
ta264 5 years ago committed by GitHub
parent 6e4b1ba1fe
commit dbb08c15d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -57,7 +57,7 @@ namespace Lidarr.Api.V1.Albums
{ {
if (model == null) return null; if (model == null) return null;
var selectedRelease = model.AlbumReleases.Value.Where(x => x.Monitored).SingleOrDefault(); var selectedRelease = model.AlbumReleases?.Value.Where(x => x.Monitored).SingleOrDefault();
return new AlbumResource return new AlbumResource
{ {
@ -75,12 +75,12 @@ namespace Lidarr.Api.V1.Albums
Images = model.Images, Images = model.Images,
Links = model.Links, Links = model.Links,
Ratings = model.Ratings, Ratings = model.Ratings,
Duration = selectedRelease.Duration, Duration = selectedRelease?.Duration ?? 0,
AlbumType = model.AlbumType, AlbumType = model.AlbumType,
SecondaryTypes = model.SecondaryTypes.Select(s => s.Name).ToList(), SecondaryTypes = model.SecondaryTypes.Select(s => s.Name).ToList(),
Releases = model.AlbumReleases.Value.ToResource(), Releases = model.AlbumReleases?.Value.ToResource() ?? new List<AlbumReleaseResource>(),
Media = selectedRelease.Media.ToResource(), Media = selectedRelease?.Media.ToResource() ?? new List<MediumResource>(),
Artist = model.Artist.Value.ToResource() Artist = model.Artist?.Value.ToResource()
}; };
} }

@ -280,10 +280,13 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
{ {
var album = _albumService.FindById(resource.Id) ?? MapAlbum(resource, null); var album = _albumService.FindById(resource.Id) ?? MapAlbum(resource, null);
if (album.Artist == null) var artist = _artistService.FindById(resource.ArtistId);
if (artist == null)
{ {
album.Artist = _artistService.GetArtist(album.ArtistId); artist = new Artist();
artist.Metadata = MapArtistMetadata(resource.Artists.Single(x => x.Id == resource.ArtistId));
} }
album.Artist = artist;
return album; return album;
} }

Loading…
Cancel
Save