|
|
@ -137,10 +137,21 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
|
|
|
|
if (existingAuthor != null)
|
|
|
|
if (existingAuthor != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var existingEditions = _editionService.GetEditionsByAuthor(existingAuthor.Id);
|
|
|
|
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()}");
|
|
|
|
_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);
|
|
|
|
var bookDict = books.ToDictionary(x => x.ForeignBookId);
|
|
|
|
foreach (var edition in extraEditions)
|
|
|
|
foreach (var edition in extraEditions)
|
|
|
@ -313,6 +324,21 @@ namespace NzbDrone.Core.MetadataSource.Goodreads
|
|
|
|
return null;
|
|
|
|
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)
|
|
|
|
public Tuple<string, Book, List<AuthorMetadata>> GetBookInfo(string foreignEditionId, bool useCache = true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_logger.Debug("Getting Book with GoodreadsId of {0}", foreignEditionId);
|
|
|
|
_logger.Debug("Getting Book with GoodreadsId of {0}", foreignEditionId);
|
|
|
|