|
|
@ -35,6 +35,7 @@ namespace NzbDrone.Core.Profiles.Metadata
|
|
|
|
private readonly IMetadataProfileRepository _profileRepository;
|
|
|
|
private readonly IMetadataProfileRepository _profileRepository;
|
|
|
|
private readonly IAuthorService _authorService;
|
|
|
|
private readonly IAuthorService _authorService;
|
|
|
|
private readonly IBookService _bookService;
|
|
|
|
private readonly IBookService _bookService;
|
|
|
|
|
|
|
|
private readonly IEditionService _editionService;
|
|
|
|
private readonly IMediaFileService _mediaFileService;
|
|
|
|
private readonly IMediaFileService _mediaFileService;
|
|
|
|
private readonly IImportListFactory _importListFactory;
|
|
|
|
private readonly IImportListFactory _importListFactory;
|
|
|
|
private readonly IRootFolderService _rootFolderService;
|
|
|
|
private readonly IRootFolderService _rootFolderService;
|
|
|
@ -44,6 +45,7 @@ namespace NzbDrone.Core.Profiles.Metadata
|
|
|
|
public MetadataProfileService(IMetadataProfileRepository profileRepository,
|
|
|
|
public MetadataProfileService(IMetadataProfileRepository profileRepository,
|
|
|
|
IAuthorService authorService,
|
|
|
|
IAuthorService authorService,
|
|
|
|
IBookService bookService,
|
|
|
|
IBookService bookService,
|
|
|
|
|
|
|
|
IEditionService editionService,
|
|
|
|
IMediaFileService mediaFileService,
|
|
|
|
IMediaFileService mediaFileService,
|
|
|
|
IImportListFactory importListFactory,
|
|
|
|
IImportListFactory importListFactory,
|
|
|
|
IRootFolderService rootFolderService,
|
|
|
|
IRootFolderService rootFolderService,
|
|
|
@ -53,6 +55,7 @@ namespace NzbDrone.Core.Profiles.Metadata
|
|
|
|
_profileRepository = profileRepository;
|
|
|
|
_profileRepository = profileRepository;
|
|
|
|
_authorService = authorService;
|
|
|
|
_authorService = authorService;
|
|
|
|
_bookService = bookService;
|
|
|
|
_bookService = bookService;
|
|
|
|
|
|
|
|
_editionService = editionService;
|
|
|
|
_mediaFileService = mediaFileService;
|
|
|
|
_mediaFileService = mediaFileService;
|
|
|
|
_importListFactory = importListFactory;
|
|
|
|
_importListFactory = importListFactory;
|
|
|
|
_rootFolderService = rootFolderService;
|
|
|
|
_rootFolderService = rootFolderService;
|
|
|
@ -112,7 +115,26 @@ namespace NzbDrone.Core.Profiles.Metadata
|
|
|
|
.ToDictionary(x => x.Key, y => y.ToList());
|
|
|
|
.ToDictionary(x => x.Key, y => y.ToList());
|
|
|
|
|
|
|
|
|
|
|
|
var dbAuthor = _authorService.FindById(input.ForeignAuthorId);
|
|
|
|
var dbAuthor = _authorService.FindById(input.ForeignAuthorId);
|
|
|
|
var localBooks = dbAuthor?.Books.Value ?? new List<Book>();
|
|
|
|
|
|
|
|
|
|
|
|
var localBooks = new List<Book>();
|
|
|
|
|
|
|
|
if (dbAuthor != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
localBooks = _bookService.GetBooksByAuthorMetadataId(dbAuthor.AuthorMetadataId);
|
|
|
|
|
|
|
|
var editions = _editionService.GetEditionsByAuthor(dbAuthor.Id).GroupBy(x => x.BookId).ToDictionary(x => x.Key, y => y.ToList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var book in localBooks)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (editions.TryGetValue(book.Id, out var bookEditions))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
book.Editions = bookEditions;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
book.Editions = new List<Edition>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var localFiles = _mediaFileService.GetFilesByAuthor(dbAuthor?.Id ?? 0);
|
|
|
|
var localFiles = _mediaFileService.GetFilesByAuthor(dbAuthor?.Id ?? 0);
|
|
|
|
|
|
|
|
|
|
|
|
return FilterBooks(input.Books.Value, localBooks, localFiles, seriesLinks, profileId);
|
|
|
|
return FilterBooks(input.Books.Value, localBooks, localFiles, seriesLinks, profileId);
|
|
|
|