mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-26 22:46:37 -04:00
New: Less logging when no import lists are enabled
(cherry picked from commit 7be4840f028f24e3920bd395a4e15eb5e643e46f) Closes #2836
This commit is contained in:
@@ -67,41 +67,51 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
|
|
||||||
private List<Book> SyncAll()
|
private List<Book> SyncAll()
|
||||||
{
|
{
|
||||||
|
if (_importListFactory.AutomaticAddEnabled().Empty())
|
||||||
|
{
|
||||||
|
_logger.Debug("No import lists with automatic add enabled");
|
||||||
|
|
||||||
|
return new List<Book>();
|
||||||
|
}
|
||||||
|
|
||||||
_logger.ProgressInfo("Starting Import List Sync");
|
_logger.ProgressInfo("Starting Import List Sync");
|
||||||
|
|
||||||
var rssReleases = _listFetcherAndParser.Fetch();
|
var listItems = _listFetcherAndParser.Fetch().ToList();
|
||||||
|
|
||||||
var reports = rssReleases.ToList();
|
return ProcessListItems(listItems);
|
||||||
|
|
||||||
return ProcessReports(reports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Book> SyncList(ImportListDefinition definition)
|
private List<Book> SyncList(ImportListDefinition definition)
|
||||||
{
|
{
|
||||||
_logger.ProgressInfo(string.Format("Starting Import List Refresh for List {0}", definition.Name));
|
_logger.ProgressInfo($"Starting Import List Refresh for List {definition.Name}");
|
||||||
|
|
||||||
var rssReleases = _listFetcherAndParser.FetchSingleList(definition);
|
var listItems = _listFetcherAndParser.FetchSingleList(definition).ToList();
|
||||||
|
|
||||||
var reports = rssReleases.ToList();
|
return ProcessListItems(listItems);
|
||||||
|
|
||||||
return ProcessReports(reports);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Book> ProcessReports(List<ImportListItemInfo> reports)
|
private List<Book> ProcessListItems(List<ImportListItemInfo> items)
|
||||||
{
|
{
|
||||||
var processed = new List<Book>();
|
var processed = new List<Book>();
|
||||||
var authorsToAdd = new List<Author>();
|
var authorsToAdd = new List<Author>();
|
||||||
var booksToAdd = new List<Book>();
|
var booksToAdd = new List<Book>();
|
||||||
|
|
||||||
_logger.ProgressInfo("Processing {0} list items", reports.Count);
|
if (items.Count == 0)
|
||||||
|
{
|
||||||
|
_logger.ProgressInfo("No list items to process");
|
||||||
|
|
||||||
|
return new List<Book>();
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.ProgressInfo("Processing {0} list items", items.Count);
|
||||||
|
|
||||||
var reportNumber = 1;
|
var reportNumber = 1;
|
||||||
|
|
||||||
var listExclusions = _importListExclusionService.All();
|
var listExclusions = _importListExclusionService.All();
|
||||||
|
|
||||||
foreach (var report in reports)
|
foreach (var report in items)
|
||||||
{
|
{
|
||||||
_logger.ProgressTrace("Processing list item {0}/{1}", reportNumber, reports.Count);
|
_logger.ProgressTrace("Processing list item {0}/{1}", reportNumber, items.Count);
|
||||||
|
|
||||||
reportNumber++;
|
reportNumber++;
|
||||||
|
|
||||||
@@ -130,7 +140,7 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
var addedAuthors = _addAuthorService.AddAuthors(authorsToAdd, false);
|
var addedAuthors = _addAuthorService.AddAuthors(authorsToAdd, false);
|
||||||
var addedBooks = _addBookService.AddBooks(booksToAdd, false);
|
var addedBooks = _addBookService.AddBooks(booksToAdd, false);
|
||||||
|
|
||||||
var message = string.Format($"Import List Sync Completed. Items found: {reports.Count}, Authors added: {authorsToAdd.Count}, Books added: {booksToAdd.Count}");
|
var message = string.Format($"Import List Sync Completed. Items found: {items.Count}, Authors added: {authorsToAdd.Count}, Books added: {booksToAdd.Count}");
|
||||||
|
|
||||||
_logger.ProgressInfo(message);
|
_logger.ProgressInfo(message);
|
||||||
|
|
||||||
@@ -364,7 +374,7 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
var existingAuthor = _authorService.FindById(report.AuthorGoodreadsId);
|
var existingAuthor = _authorService.FindById(report.AuthorGoodreadsId);
|
||||||
|
|
||||||
// Check to see if author excluded
|
// Check to see if author excluded
|
||||||
var excludedAuthor = listExclusions.Where(s => s.ForeignId == report.AuthorGoodreadsId).SingleOrDefault();
|
var excludedAuthor = listExclusions.SingleOrDefault(s => s.ForeignId == report.AuthorGoodreadsId);
|
||||||
|
|
||||||
// Check to see if author in import
|
// Check to see if author in import
|
||||||
var existingImportAuthor = authorsToAdd.Find(i => i.ForeignAuthorId == report.AuthorGoodreadsId);
|
var existingImportAuthor = authorsToAdd.Find(i => i.ForeignAuthorId == report.AuthorGoodreadsId);
|
||||||
@@ -425,16 +435,7 @@ namespace NzbDrone.Core.ImportLists
|
|||||||
|
|
||||||
public void Execute(ImportListSyncCommand message)
|
public void Execute(ImportListSyncCommand message)
|
||||||
{
|
{
|
||||||
List<Book> processed;
|
var processed = message.DefinitionId.HasValue ? SyncList(_importListFactory.Get(message.DefinitionId.Value)) : SyncAll();
|
||||||
|
|
||||||
if (message.DefinitionId.HasValue)
|
|
||||||
{
|
|
||||||
processed = SyncList(_importListFactory.Get(message.DefinitionId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
processed = SyncAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
_eventAggregator.PublishEvent(new ImportListSyncCompleteEvent(processed));
|
_eventAggregator.PublishEvent(new ImportListSyncCompleteEvent(processed));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user