2018-02-06 23:08:36 +00:00
|
|
|
using System.Collections.Generic;
|
2022-07-18 21:31:49 +00:00
|
|
|
using System.Diagnostics;
|
2018-02-06 23:08:36 +00:00
|
|
|
using System.Linq;
|
|
|
|
using NLog;
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
using NzbDrone.Common.Instrumentation.Extensions;
|
2019-03-01 22:26:36 +00:00
|
|
|
using NzbDrone.Core.ImportLists.Exclusions;
|
2022-07-18 22:40:27 +00:00
|
|
|
using NzbDrone.Core.IndexerSearch;
|
2018-02-06 23:08:36 +00:00
|
|
|
using NzbDrone.Core.Messaging.Commands;
|
|
|
|
using NzbDrone.Core.Messaging.Events;
|
|
|
|
using NzbDrone.Core.MetadataSource;
|
|
|
|
using NzbDrone.Core.Music;
|
2020-08-13 20:31:09 +00:00
|
|
|
using NzbDrone.Core.Music.Commands;
|
2018-05-10 23:06:02 +00:00
|
|
|
using NzbDrone.Core.Parser.Model;
|
2018-02-06 23:08:36 +00:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.ImportLists
|
|
|
|
{
|
|
|
|
public class ImportListSyncService : IExecute<ImportListSyncCommand>
|
|
|
|
{
|
|
|
|
private readonly IImportListFactory _importListFactory;
|
2019-03-01 22:26:36 +00:00
|
|
|
private readonly IImportListExclusionService _importListExclusionService;
|
2018-02-06 23:08:36 +00:00
|
|
|
private readonly IFetchAndParseImportList _listFetcherAndParser;
|
|
|
|
private readonly ISearchForNewAlbum _albumSearchService;
|
|
|
|
private readonly ISearchForNewArtist _artistSearchService;
|
|
|
|
private readonly IArtistService _artistService;
|
2019-12-16 21:21:32 +00:00
|
|
|
private readonly IAlbumService _albumService;
|
2018-02-06 23:08:36 +00:00
|
|
|
private readonly IAddArtistService _addArtistService;
|
2019-12-16 21:21:32 +00:00
|
|
|
private readonly IAddAlbumService _addAlbumService;
|
2018-02-06 23:08:36 +00:00
|
|
|
private readonly IEventAggregator _eventAggregator;
|
2020-08-13 20:31:09 +00:00
|
|
|
private readonly IManageCommandQueue _commandQueueManager;
|
2018-02-06 23:08:36 +00:00
|
|
|
private readonly Logger _logger;
|
|
|
|
|
2019-09-22 21:50:14 +00:00
|
|
|
public ImportListSyncService(IImportListFactory importListFactory,
|
2019-12-16 21:21:32 +00:00
|
|
|
IImportListExclusionService importListExclusionService,
|
|
|
|
IFetchAndParseImportList listFetcherAndParser,
|
|
|
|
ISearchForNewAlbum albumSearchService,
|
|
|
|
ISearchForNewArtist artistSearchService,
|
|
|
|
IArtistService artistService,
|
|
|
|
IAlbumService albumService,
|
|
|
|
IAddArtistService addArtistService,
|
|
|
|
IAddAlbumService addAlbumService,
|
|
|
|
IEventAggregator eventAggregator,
|
2020-08-13 20:31:09 +00:00
|
|
|
IManageCommandQueue commandQueueManager,
|
2019-12-16 21:21:32 +00:00
|
|
|
Logger logger)
|
2018-02-06 23:08:36 +00:00
|
|
|
{
|
|
|
|
_importListFactory = importListFactory;
|
2019-03-01 22:26:36 +00:00
|
|
|
_importListExclusionService = importListExclusionService;
|
2018-02-06 23:08:36 +00:00
|
|
|
_listFetcherAndParser = listFetcherAndParser;
|
|
|
|
_albumSearchService = albumSearchService;
|
|
|
|
_artistSearchService = artistSearchService;
|
|
|
|
_artistService = artistService;
|
2019-12-16 21:21:32 +00:00
|
|
|
_albumService = albumService;
|
2018-02-06 23:08:36 +00:00
|
|
|
_addArtistService = addArtistService;
|
2019-12-16 21:21:32 +00:00
|
|
|
_addAlbumService = addAlbumService;
|
2018-02-06 23:08:36 +00:00
|
|
|
_eventAggregator = eventAggregator;
|
2020-08-13 20:31:09 +00:00
|
|
|
_commandQueueManager = commandQueueManager;
|
2018-02-06 23:08:36 +00:00
|
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
|
2018-05-10 23:06:02 +00:00
|
|
|
private List<Album> SyncAll()
|
2018-02-06 23:08:36 +00:00
|
|
|
{
|
2023-08-19 06:47:19 +00:00
|
|
|
if (_importListFactory.AutomaticAddEnabled().Empty())
|
|
|
|
{
|
|
|
|
_logger.Debug("No import lists with automatic add enabled");
|
2018-02-06 23:08:36 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
return new List<Album>();
|
|
|
|
}
|
|
|
|
|
|
|
|
_logger.ProgressInfo("Starting Import List Sync");
|
2018-02-06 23:08:36 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
var listItems = _listFetcherAndParser.Fetch().ToList();
|
2018-05-10 23:06:02 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
return ProcessListItems(listItems);
|
2018-05-10 23:06:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private List<Album> SyncList(ImportListDefinition definition)
|
|
|
|
{
|
2023-08-19 06:47:19 +00:00
|
|
|
_logger.ProgressInfo($"Starting Import List Refresh for List {definition.Name}");
|
2018-05-10 23:06:02 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
var listItems = _listFetcherAndParser.FetchSingleList(definition).ToList();
|
2018-05-10 23:06:02 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
return ProcessListItems(listItems);
|
2018-05-10 23:06:02 +00:00
|
|
|
}
|
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
private List<Album> ProcessListItems(List<ImportListItemInfo> items)
|
2018-05-10 23:06:02 +00:00
|
|
|
{
|
2018-02-06 23:08:36 +00:00
|
|
|
var processed = new List<Album>();
|
|
|
|
var artistsToAdd = new List<Artist>();
|
2019-12-16 21:21:32 +00:00
|
|
|
var albumsToAdd = new List<Album>();
|
2018-02-06 23:08:36 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
if (items.Count == 0)
|
|
|
|
{
|
|
|
|
_logger.ProgressInfo("No list items to process");
|
|
|
|
|
|
|
|
return new List<Album>();
|
|
|
|
}
|
|
|
|
|
|
|
|
_logger.ProgressInfo("Processing {0} list items", items.Count);
|
2018-02-06 23:08:36 +00:00
|
|
|
|
|
|
|
var reportNumber = 1;
|
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
var listExclusions = _importListExclusionService.All().ToDictionary(x => x.ForeignId);
|
2023-08-19 09:45:56 +00:00
|
|
|
var importLists = _importListFactory.All();
|
2019-03-01 22:26:36 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
foreach (var item in items)
|
2018-02-06 23:08:36 +00:00
|
|
|
{
|
2023-08-19 06:47:19 +00:00
|
|
|
_logger.ProgressTrace("Processing list item {0}/{1}", reportNumber++, items.Count);
|
2018-02-06 23:08:36 +00:00
|
|
|
|
2023-08-19 09:45:56 +00:00
|
|
|
var importList = importLists.Single(x => x.Id == item.ImportListId);
|
2018-02-06 23:08:36 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
if (item.Album.IsNotNullOrWhiteSpace() || item.AlbumMusicBrainzId.IsNotNullOrWhiteSpace())
|
2018-02-06 23:08:36 +00:00
|
|
|
{
|
2023-08-19 06:47:19 +00:00
|
|
|
if (item.AlbumMusicBrainzId.IsNullOrWhiteSpace() || item.ArtistMusicBrainzId.IsNullOrWhiteSpace())
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
2023-08-19 06:47:19 +00:00
|
|
|
MapAlbumReport(item);
|
2019-12-16 21:21:32 +00:00
|
|
|
}
|
2018-02-06 23:08:36 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
ProcessAlbumReport(importList, item, listExclusions, albumsToAdd, artistsToAdd);
|
2019-12-16 21:21:32 +00:00
|
|
|
}
|
2023-08-19 06:47:19 +00:00
|
|
|
else if (item.Artist.IsNotNullOrWhiteSpace() || item.ArtistMusicBrainzId.IsNotNullOrWhiteSpace())
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
2023-08-19 06:47:19 +00:00
|
|
|
if (item.ArtistMusicBrainzId.IsNullOrWhiteSpace())
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
2023-08-19 06:47:19 +00:00
|
|
|
MapArtistReport(item);
|
2019-12-16 21:21:32 +00:00
|
|
|
}
|
2018-02-06 23:08:36 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
ProcessArtistReport(importList, item, listExclusions, artistsToAdd);
|
2018-02-06 23:08:36 +00:00
|
|
|
}
|
2019-12-16 21:21:32 +00:00
|
|
|
}
|
2018-02-06 23:08:36 +00:00
|
|
|
|
2021-04-02 02:47:15 +00:00
|
|
|
var addedArtists = _addArtistService.AddArtists(artistsToAdd, false, true);
|
|
|
|
var addedAlbums = _addAlbumService.AddAlbums(albumsToAdd, false, true);
|
2019-10-16 20:04:03 +00:00
|
|
|
|
2023-08-19 06:47:19 +00:00
|
|
|
var message = string.Format($"Import List Sync Completed. Items found: {items.Count}, Artists added: {addedArtists.Count}, Albums added: {addedAlbums.Count}");
|
2019-10-16 20:04:03 +00:00
|
|
|
|
2019-12-16 21:21:32 +00:00
|
|
|
_logger.ProgressInfo(message);
|
2019-10-16 20:04:03 +00:00
|
|
|
|
2020-08-13 20:31:09 +00:00
|
|
|
var toRefresh = addedArtists.Select(x => x.Id).Concat(addedAlbums.Select(x => x.Artist.Value.Id)).Distinct().ToList();
|
|
|
|
if (toRefresh.Any())
|
|
|
|
{
|
|
|
|
_commandQueueManager.Push(new BulkRefreshArtistCommand(toRefresh, true));
|
|
|
|
}
|
|
|
|
|
2019-12-16 21:21:32 +00:00
|
|
|
return processed;
|
|
|
|
}
|
2018-02-06 23:08:36 +00:00
|
|
|
|
2019-12-16 21:21:32 +00:00
|
|
|
private void MapAlbumReport(ImportListItemInfo report)
|
|
|
|
{
|
|
|
|
var albumQuery = report.AlbumMusicBrainzId.IsNotNullOrWhiteSpace() ? $"lidarr:{report.AlbumMusicBrainzId}" : report.Album;
|
2023-08-19 06:47:19 +00:00
|
|
|
var mappedAlbum = _albumSearchService.SearchForNewAlbum(albumQuery, report.Artist).FirstOrDefault();
|
2019-09-22 21:50:14 +00:00
|
|
|
|
2019-12-16 21:21:32 +00:00
|
|
|
// Break if we are looking for an album and cant find it. This will avoid us from adding the artist and possibly getting it wrong.
|
|
|
|
if (mappedAlbum == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-09-22 21:50:14 +00:00
|
|
|
|
2019-12-16 21:21:32 +00:00
|
|
|
report.AlbumMusicBrainzId = mappedAlbum.ForeignAlbumId;
|
|
|
|
report.Album = mappedAlbum.Title;
|
2022-07-18 21:25:48 +00:00
|
|
|
report.Artist ??= mappedAlbum.ArtistMetadata?.Value?.Name;
|
|
|
|
report.ArtistMusicBrainzId ??= mappedAlbum.ArtistMetadata?.Value?.ForeignArtistId;
|
2019-12-16 21:21:32 +00:00
|
|
|
}
|
2019-03-01 22:26:36 +00:00
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
private void ProcessAlbumReport(ImportListDefinition importList, ImportListItemInfo report, Dictionary<string, ImportListExclusion> listExclusions, List<Album> albumsToAdd, List<Artist> artistsToAdd)
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
2023-12-05 14:30:38 +00:00
|
|
|
if (report.AlbumMusicBrainzId.IsNullOrWhiteSpace() || report.ArtistMusicBrainzId.IsNullOrWhiteSpace())
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2018-02-06 23:08:36 +00:00
|
|
|
|
2019-12-16 21:21:32 +00:00
|
|
|
// Check to see if album excluded
|
2022-07-18 22:56:19 +00:00
|
|
|
if (listExclusions.ContainsKey(report.AlbumMusicBrainzId))
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
2022-07-18 21:25:48 +00:00
|
|
|
_logger.Debug("{0} [{1}] Rejected due to list exclusion", report.AlbumMusicBrainzId, report.Album);
|
2019-12-16 21:21:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
// Check to see if artist excluded
|
|
|
|
if (listExclusions.ContainsKey(report.ArtistMusicBrainzId))
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
2022-07-18 21:25:48 +00:00
|
|
|
_logger.Debug("{0} [{1}] Rejected due to list exclusion for parent artist", report.AlbumMusicBrainzId, report.Album);
|
2019-12-16 21:21:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
// Check to see if album in DB
|
|
|
|
var existingAlbum = _albumService.FindById(report.AlbumMusicBrainzId);
|
2022-07-18 20:46:18 +00:00
|
|
|
if (existingAlbum != null)
|
|
|
|
{
|
|
|
|
_logger.Debug("{0} [{1}] Rejected, Album Exists in DB. Ensuring Album and Artist monitored.", report.AlbumMusicBrainzId, report.Album);
|
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
ProcessAlbumReportForExistingAlbum(importList, existingAlbum);
|
2022-07-18 20:46:18 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-12-16 21:21:32 +00:00
|
|
|
// Append Album if not already in DB or already on add list
|
|
|
|
if (albumsToAdd.All(s => s.ForeignAlbumId != report.AlbumMusicBrainzId))
|
|
|
|
{
|
|
|
|
var monitored = importList.ShouldMonitor != ImportListMonitorType.None;
|
2019-09-22 21:50:14 +00:00
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
var toAddArtist = ProcessArtistReport(importList, report, listExclusions, artistsToAdd);
|
2022-07-18 21:25:48 +00:00
|
|
|
|
2020-02-28 20:40:12 +00:00
|
|
|
var toAdd = new Album
|
2020-01-03 12:49:24 +00:00
|
|
|
{
|
|
|
|
ForeignAlbumId = report.AlbumMusicBrainzId,
|
|
|
|
Monitored = monitored,
|
2020-02-28 21:19:20 +00:00
|
|
|
AnyReleaseOk = true,
|
2022-07-18 21:25:48 +00:00
|
|
|
Artist = toAddArtist,
|
2020-08-25 20:16:44 +00:00
|
|
|
AddOptions = new AddAlbumOptions
|
|
|
|
{
|
2022-07-18 22:40:27 +00:00
|
|
|
SearchForNewAlbum = importList.ShouldSearch && toAddArtist.Id > 0
|
2020-08-25 20:16:44 +00:00
|
|
|
}
|
2020-02-28 20:40:12 +00:00
|
|
|
};
|
|
|
|
|
2022-07-18 21:31:49 +00:00
|
|
|
if (importList.ShouldMonitor == ImportListMonitorType.SpecificAlbum && toAddArtist.AddOptions != null)
|
2020-02-28 20:40:12 +00:00
|
|
|
{
|
2022-07-18 21:31:49 +00:00
|
|
|
Debug.Assert(toAddArtist.Id == 0, "new artist added but ID is not 0");
|
2022-07-18 21:25:48 +00:00
|
|
|
toAddArtist.AddOptions.AlbumsToMonitor.Add(toAdd.ForeignAlbumId);
|
2020-02-28 20:40:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
albumsToAdd.Add(toAdd);
|
2019-12-16 21:21:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
private void ProcessAlbumReportForExistingAlbum(ImportListDefinition importList, Album existingAlbum)
|
|
|
|
{
|
|
|
|
if (importList.ShouldMonitorExisting && importList.ShouldMonitor != ImportListMonitorType.None)
|
|
|
|
{
|
|
|
|
Command searchCommand = null;
|
|
|
|
var existingArtist = existingAlbum.Artist.Value;
|
|
|
|
|
|
|
|
if (!existingArtist.Monitored || !existingAlbum.Monitored)
|
|
|
|
{
|
|
|
|
searchCommand = importList.ShouldMonitor == ImportListMonitorType.EntireArtist ? new MissingAlbumSearchCommand(existingArtist.Id) : new AlbumSearchCommand(new List<int> { existingAlbum.Id });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!existingAlbum.Monitored)
|
|
|
|
{
|
|
|
|
_albumService.SetAlbumMonitored(existingAlbum.Id, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!existingArtist.Monitored)
|
|
|
|
{
|
|
|
|
existingArtist.Monitored = true;
|
|
|
|
_artistService.UpdateArtist(existingArtist);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure all artist albums are monitored if required
|
|
|
|
if (importList.ShouldMonitor == ImportListMonitorType.EntireArtist && existingArtist.Albums.Value.Any(x => !x.Monitored))
|
|
|
|
{
|
|
|
|
_albumService.SetMonitored(existingArtist.Albums.Value.Select(x => x.Id), true);
|
|
|
|
searchCommand = new MissingAlbumSearchCommand(existingArtist.Id);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (importList.ShouldSearch && searchCommand != null)
|
|
|
|
{
|
|
|
|
_commandQueueManager.Push(searchCommand);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-16 21:21:32 +00:00
|
|
|
private void MapArtistReport(ImportListItemInfo report)
|
|
|
|
{
|
2023-08-19 06:47:19 +00:00
|
|
|
var mappedArtist = _artistSearchService.SearchForNewArtist(report.Artist).FirstOrDefault();
|
2019-12-16 21:21:32 +00:00
|
|
|
report.ArtistMusicBrainzId = mappedArtist?.Metadata.Value?.ForeignArtistId;
|
|
|
|
report.Artist = mappedArtist?.Metadata.Value?.Name;
|
|
|
|
}
|
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
private Artist ProcessArtistReport(ImportListDefinition importList, ImportListItemInfo report, Dictionary<string, ImportListExclusion> listExclusions, List<Artist> artistsToAdd)
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
2023-12-05 14:30:38 +00:00
|
|
|
if (report.ArtistMusicBrainzId.IsNullOrWhiteSpace())
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
2022-07-18 21:25:48 +00:00
|
|
|
return null;
|
2019-12-16 21:21:32 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
if (listExclusions.ContainsKey(report.ArtistMusicBrainzId))
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
2022-07-18 21:25:48 +00:00
|
|
|
_logger.Debug("{0} [{1}] Rejected due to list exclusion", report.ArtistMusicBrainzId, report.Artist);
|
|
|
|
return null;
|
2019-12-16 21:21:32 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
// Check to see if artist in import
|
|
|
|
var existingImportArtist = artistsToAdd.Find(i => i.ForeignArtistId == report.ArtistMusicBrainzId);
|
|
|
|
if (existingImportArtist != null)
|
2022-07-18 20:46:18 +00:00
|
|
|
{
|
2022-07-18 22:56:19 +00:00
|
|
|
_logger.Debug("{0} [{1}] Rejected, artist exists in Import.", report.ArtistMusicBrainzId, report.Artist);
|
2022-07-18 20:46:18 +00:00
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
return existingImportArtist;
|
2022-07-18 20:46:18 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
// Check to see if artist in DB
|
|
|
|
var existingArtist = _artistService.FindById(report.ArtistMusicBrainzId);
|
|
|
|
if (existingArtist != null)
|
2019-12-16 21:21:32 +00:00
|
|
|
{
|
2022-07-18 22:56:19 +00:00
|
|
|
_logger.Debug("{0} [{1}] Rejected, artist exists in DB. Ensuring artist monitored", report.ArtistMusicBrainzId, report.Artist);
|
2022-07-18 21:25:48 +00:00
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
ProcessArtistReportForExistingArtist(importList, existingArtist);
|
|
|
|
return existingArtist;
|
2022-07-18 21:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var monitored = importList.ShouldMonitor != ImportListMonitorType.None;
|
2019-12-16 21:21:32 +00:00
|
|
|
|
2022-07-18 21:25:48 +00:00
|
|
|
var toAdd = new Artist
|
|
|
|
{
|
|
|
|
Metadata = new ArtistMetadata
|
2020-01-03 12:49:24 +00:00
|
|
|
{
|
2022-07-18 21:25:48 +00:00
|
|
|
ForeignArtistId = report.ArtistMusicBrainzId,
|
|
|
|
Name = report.Artist
|
|
|
|
},
|
|
|
|
Monitored = monitored,
|
|
|
|
MonitorNewItems = importList.MonitorNewItems,
|
|
|
|
RootFolderPath = importList.RootFolderPath,
|
|
|
|
QualityProfileId = importList.ProfileId,
|
|
|
|
MetadataProfileId = importList.MetadataProfileId,
|
|
|
|
Tags = importList.Tags,
|
|
|
|
AddOptions = new AddArtistOptions
|
|
|
|
{
|
2022-07-18 21:51:52 +00:00
|
|
|
SearchForMissingAlbums = importList.ShouldSearch,
|
2020-01-03 12:49:24 +00:00
|
|
|
Monitored = monitored,
|
2022-07-18 21:25:48 +00:00
|
|
|
Monitor = monitored ? MonitorTypes.All : MonitorTypes.None
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
artistsToAdd.Add(toAdd);
|
|
|
|
|
|
|
|
return toAdd;
|
2018-02-06 23:08:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-18 22:56:19 +00:00
|
|
|
private void ProcessArtistReportForExistingArtist(ImportListDefinition importList, Artist existingArtist)
|
2018-02-06 23:08:36 +00:00
|
|
|
{
|
2022-07-18 22:56:19 +00:00
|
|
|
if (importList.ShouldMonitorExisting && !existingArtist.Monitored)
|
2018-05-10 23:06:02 +00:00
|
|
|
{
|
2022-07-18 22:56:19 +00:00
|
|
|
existingArtist.Monitored = true;
|
|
|
|
_artistService.UpdateArtist(existingArtist);
|
|
|
|
|
|
|
|
if (importList.ShouldSearch)
|
|
|
|
{
|
|
|
|
_commandQueueManager.Push(new MissingAlbumSearchCommand(existingArtist.Id));
|
|
|
|
}
|
2018-05-10 23:06:02 +00:00
|
|
|
}
|
2022-07-18 22:56:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Execute(ImportListSyncCommand message)
|
|
|
|
{
|
|
|
|
var processed = message.DefinitionId.HasValue ? SyncList(_importListFactory.Get(message.DefinitionId.Value)) : SyncAll();
|
2018-02-06 23:08:36 +00:00
|
|
|
|
|
|
|
_eventAggregator.PublishEvent(new ImportListSyncCompleteEvent(processed));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|