Fixed: Error parsing books with no contributors

Fixes #1454
This commit is contained in:
ta264
2022-01-16 22:09:21 +00:00
parent 759c132797
commit b4b14a5359

View File

@@ -590,7 +590,7 @@ namespace NzbDrone.Core.MetadataSource.BookInfo
}
var book = MapBook(resource);
var authorId = resource.Books.OrderByDescending(x => x.AverageRating * x.RatingCount).First().Contributors.First().ForeignId.ToString();
var authorId = GetAuthorId(resource).ToString();
var metadata = resource.Authors.Select(MapAuthorMetadata).ToList();
var series = resource.Series.Select(MapSeries).ToList();
@@ -818,7 +818,7 @@ namespace NzbDrone.Core.MetadataSource.BookInfo
private static int GetAuthorId(WorkResource b)
{
return b.Books.OrderByDescending(x => x.RatingCount * x.AverageRating).First().Contributors.FirstOrDefault()?.ForeignId ?? 0;
return b.Books.OrderByDescending(x => x.RatingCount * x.AverageRating).FirstOrDefault(x => x.Contributors.Any())?.Contributors.First().ForeignId ?? 0;
}
}
}