private Author GetSkyhookData(Book book) { var foreignId = book.Editions.Value.First().ForeignEditionId; try { var tuple = _bookInfo.GetBookInfo(foreignId, false); var author = _authorInfo.GetAuthorInfo(tuple.Item1, false); var newbook = tuple.Item2; newbook.Author = author; newbook.AuthorMetadata = author.Metadata.Value; newbook.AuthorMetadataId = book.AuthorMetadataId; newbook.AuthorMetadata.Value.Id = book.AuthorMetadataId; author.Books = new List <Book> { newbook }; return(author); } catch (BookNotFoundException) { _logger.Error($"Could not find book with id {foreignId}"); } return(null); }
private Author GetSkyhookData(Book book) { var foreignId = book.Editions.Value.First().ForeignEditionId; try { var tuple = _bookInfo.GetBookInfo(foreignId, false); var author = _authorInfo.GetAuthorInfo(tuple.Item1, false); var newbook = tuple.Item2; newbook.Author = author; newbook.AuthorMetadata = author.Metadata.Value; newbook.AuthorMetadataId = book.AuthorMetadataId; newbook.AuthorMetadata.Value.Id = book.AuthorMetadataId; // make sure to grab editions data for any other existing editions foreach (var edition in book.Editions.Value.Skip(1)) { tuple = _bookInfo.GetBookInfo(edition.ForeignEditionId, false); newbook.Editions.Value.AddRange(tuple.Item2.Editions.Value); } author.Books = new List <Book> { newbook }; return(author); } catch (BookNotFoundException) { _logger.Error($"Could not find book with id {foreignId}"); } return(null); }
private Author GetSkyhookData(string foreignId) { try { return(_authorInfo.GetAuthorInfo(foreignId)); } catch (AuthorNotFoundException) { _logger.Error($"Could not find author with id {foreignId}"); } return(null); }
private Author AddSkyhookData(Author newAuthor) { Author author; try { author = _authorInfo.GetAuthorInfo(newAuthor.Metadata.Value.ForeignAuthorId); } catch (AuthorNotFoundException) { _logger.Error("ReadarrId {0} was not found, it may have been removed from Goodreads.", newAuthor.Metadata.Value.ForeignAuthorId); throw new ValidationException(new List <ValidationFailure> { new ValidationFailure("MusicbrainzId", "An author with this ID was not found", newAuthor.Metadata.Value.ForeignAuthorId) }); } author.ApplyChanges(newAuthor); return(author); }