mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
Fixed: Readarr to Readarr import list adds random results
This commit is contained in:
@@ -11,6 +11,7 @@ using NzbDrone.Core.ImportLists.Exclusions;
|
|||||||
using NzbDrone.Core.IndexerSearch;
|
using NzbDrone.Core.IndexerSearch;
|
||||||
using NzbDrone.Core.Messaging.Commands;
|
using NzbDrone.Core.Messaging.Commands;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
|
using NzbDrone.Core.MetadataSource;
|
||||||
using NzbDrone.Core.MetadataSource.Goodreads;
|
using NzbDrone.Core.MetadataSource.Goodreads;
|
||||||
using NzbDrone.Core.Parser.Model;
|
using NzbDrone.Core.Parser.Model;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
private readonly IFetchAndParseImportList _listFetcherAndParser;
|
private readonly IFetchAndParseImportList _listFetcherAndParser;
|
||||||
private readonly IGoodreadsProxy _goodreadsProxy;
|
private readonly IGoodreadsProxy _goodreadsProxy;
|
||||||
private readonly IGoodreadsSearchProxy _goodreadsSearchProxy;
|
private readonly IGoodreadsSearchProxy _goodreadsSearchProxy;
|
||||||
|
private readonly IProvideBookInfo _bookInfoProxy;
|
||||||
private readonly IAuthorService _authorService;
|
private readonly IAuthorService _authorService;
|
||||||
private readonly IBookService _bookService;
|
private readonly IBookService _bookService;
|
||||||
private readonly IEditionService _editionService;
|
private readonly IEditionService _editionService;
|
||||||
@@ -37,6 +39,7 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
IFetchAndParseImportList listFetcherAndParser,
|
IFetchAndParseImportList listFetcherAndParser,
|
||||||
IGoodreadsProxy goodreadsProxy,
|
IGoodreadsProxy goodreadsProxy,
|
||||||
IGoodreadsSearchProxy goodreadsSearchProxy,
|
IGoodreadsSearchProxy goodreadsSearchProxy,
|
||||||
|
IProvideBookInfo bookInfoProxy,
|
||||||
IAuthorService authorService,
|
IAuthorService authorService,
|
||||||
IBookService bookService,
|
IBookService bookService,
|
||||||
IEditionService editionService,
|
IEditionService editionService,
|
||||||
@@ -51,6 +54,7 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
_listFetcherAndParser = listFetcherAndParser;
|
_listFetcherAndParser = listFetcherAndParser;
|
||||||
_goodreadsProxy = goodreadsProxy;
|
_goodreadsProxy = goodreadsProxy;
|
||||||
_goodreadsSearchProxy = goodreadsSearchProxy;
|
_goodreadsSearchProxy = goodreadsSearchProxy;
|
||||||
|
_bookInfoProxy = bookInfoProxy;
|
||||||
_authorService = authorService;
|
_authorService = authorService;
|
||||||
_bookService = bookService;
|
_bookService = bookService;
|
||||||
_editionService = editionService;
|
_editionService = editionService;
|
||||||
@@ -141,6 +145,11 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
|
|
||||||
private void MapBookReport(ImportListItemInfo report)
|
private void MapBookReport(ImportListItemInfo report)
|
||||||
{
|
{
|
||||||
|
if (report.AuthorGoodreadsId.IsNotNullOrWhiteSpace() && report.BookGoodreadsId.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (report.EditionGoodreadsId.IsNotNullOrWhiteSpace() && int.TryParse(report.EditionGoodreadsId, out var goodreadsId))
|
if (report.EditionGoodreadsId.IsNotNullOrWhiteSpace() && int.TryParse(report.EditionGoodreadsId, out var goodreadsId))
|
||||||
{
|
{
|
||||||
// check the local DB
|
// check the local DB
|
||||||
@@ -173,6 +182,14 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
report.EditionGoodreadsId = null;
|
report.EditionGoodreadsId = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (report.BookGoodreadsId.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
var mappedBook = _bookInfoProxy.GetBookInfo(report.BookGoodreadsId);
|
||||||
|
|
||||||
|
report.BookGoodreadsId = mappedBook.Item2.ForeignBookId;
|
||||||
|
report.Book = mappedBook.Item2.Title;
|
||||||
|
report.AuthorGoodreadsId = mappedBook.Item3.First().ForeignAuthorId;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var mappedBook = _goodreadsSearchProxy.Search($"{report.Book} {report.Author}").FirstOrDefault();
|
var mappedBook = _goodreadsSearchProxy.Search($"{report.Book} {report.Author}").FirstOrDefault();
|
||||||
@@ -195,12 +212,6 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
|
|
||||||
private void ProcessBookReport(ImportListDefinition importList, ImportListItemInfo report, List<ImportListExclusion> listExclusions, List<Book> booksToAdd, List<Author> authorsToAdd)
|
private void ProcessBookReport(ImportListDefinition importList, ImportListItemInfo report, List<ImportListExclusion> listExclusions, List<Book> booksToAdd, List<Author> authorsToAdd)
|
||||||
{
|
{
|
||||||
if (report.EditionGoodreadsId == null)
|
|
||||||
{
|
|
||||||
_logger.Trace("Skipping report [{0}] due to missing EditionGoodreadsId", report.Book);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check to see if book in DB
|
// Check to see if book in DB
|
||||||
var existingBook = _bookService.FindById(report.BookGoodreadsId);
|
var existingBook = _bookService.FindById(report.BookGoodreadsId);
|
||||||
|
|
||||||
@@ -297,14 +308,7 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
ForeignBookId = report.BookGoodreadsId,
|
ForeignBookId = report.BookGoodreadsId,
|
||||||
Monitored = monitored,
|
Monitored = monitored,
|
||||||
AnyEditionOk = true,
|
AnyEditionOk = true,
|
||||||
Editions = new List<Edition>
|
Editions = new List<Edition>(),
|
||||||
{
|
|
||||||
new Edition
|
|
||||||
{
|
|
||||||
ForeignEditionId = report.EditionGoodreadsId,
|
|
||||||
Monitored = true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Author = toAddAuthor,
|
Author = toAddAuthor,
|
||||||
AddOptions = new AddBookOptions
|
AddOptions = new AddBookOptions
|
||||||
{
|
{
|
||||||
@@ -314,6 +318,15 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (report.EditionGoodreadsId.IsNotNullOrWhiteSpace() && int.TryParse(report.EditionGoodreadsId, out var goodreadsId))
|
||||||
|
{
|
||||||
|
toAdd.Editions.Value.Add(new Edition
|
||||||
|
{
|
||||||
|
ForeignEditionId = report.EditionGoodreadsId,
|
||||||
|
Monitored = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (importList.ShouldMonitor == ImportListMonitorType.SpecificBook && toAddAuthor.AddOptions != null)
|
if (importList.ShouldMonitor == ImportListMonitorType.SpecificBook && toAddAuthor.AddOptions != null)
|
||||||
{
|
{
|
||||||
Debug.Assert(toAddAuthor.Id == 0, "new author added but ID is not 0");
|
Debug.Assert(toAddAuthor.Id == 0, "new author added but ID is not 0");
|
||||||
|
|||||||
Reference in New Issue
Block a user