Fixed: Error refreshing author if manually added book edition has been removed from Goodreads

Fixes Sentry READARR-Z6
pull/1151/head
ta264 3 years ago
parent 2a05112d7d
commit 474699b67d

@ -137,10 +137,21 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
if (existingAuthor != null)
{
var existingEditions = _editionService.GetEditionsByAuthor(existingAuthor.Id);
var extraEditionIds = existingEditions.Select(x => x.ForeignEditionId).Except(books.Select(x => x.Editions.Value.First().ForeignEditionId));
var extraEditionIds = existingEditions
.Select(x => x.ForeignEditionId)
.Except(books.Select(x => x.Editions.Value.First().ForeignEditionId))
.ToList();
_logger.Debug($"Getting data for extra editions {extraEditionIds.ConcatToString()}");
var extraEditions = extraEditionIds.Select(x => GetBookInfo(x));
var extraEditions = new List<Tuple<string, Book, List<AuthorMetadata>>>();
foreach (var id in extraEditionIds)
{
if (TryGetBookInfo(id, true, out var result))
{
extraEditions.Add(result);
}
}
var bookDict = books.ToDictionary(x => x.ForeignBookId);
foreach (var edition in extraEditions)
@ -313,6 +324,21 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
return null;
}
private bool TryGetBookInfo(string foreignEditionId, bool useCache, out Tuple<string, Book, List<AuthorMetadata>> result)
{
try
{
result = GetBookInfo(foreignEditionId, useCache);
return true;
}
catch (BookNotFoundException e)
{
result = null;
_logger.Warn(e, "Book not found");
return false;
}
}
public Tuple<string, Book, List<AuthorMetadata>> GetBookInfo(string foreignEditionId, bool useCache = true)
{
_logger.Debug("Getting Book with GoodreadsId of {0}", foreignEditionId);

Loading…
Cancel
Save