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

This commit is contained in:
ta264 2019-03-23 19:01:34 +00:00 committed by GitHub
parent 6e4b1ba1fe
commit dbb08c15d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -57,7 +57,7 @@ namespace Lidarr.Api.V1.Albums
{
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
{
@ -75,12 +75,12 @@ namespace Lidarr.Api.V1.Albums
Images = model.Images,
Links = model.Links,
Ratings = model.Ratings,
Duration = selectedRelease.Duration,
Duration = selectedRelease?.Duration ?? 0,
AlbumType = model.AlbumType,
SecondaryTypes = model.SecondaryTypes.Select(s => s.Name).ToList(),
Releases = model.AlbumReleases.Value.ToResource(),
Media = selectedRelease.Media.ToResource(),
Artist = model.Artist.Value.ToResource()
Releases = model.AlbumReleases?.Value.ToResource() ?? new List<AlbumReleaseResource>(),
Media = selectedRelease?.Media.ToResource() ?? new List<MediumResource>(),
Artist = model.Artist?.Value.ToResource()
};
}

View File

@ -280,10 +280,13 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
{
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;
}