From e289c428c6926f763aeba2fd396546bc0a4c2e6c Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 20 Feb 2021 19:59:11 +0100 Subject: [PATCH] Fixed: Refresh scene naming exceptions on series add to help first-use scenario --- .../Scene/SceneMappingService.cs | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs index 4b8d29c6f..a87f5b374 100644 --- a/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs +++ b/src/NzbDrone.Core/DataAugmentation/Scene/SceneMappingService.cs @@ -1,14 +1,14 @@ using System; +using System.Collections.Generic; using System.Linq; +using System.Text.RegularExpressions; using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Parser; -using System.Collections.Generic; using NzbDrone.Core.Tv.Events; -using System.Text.RegularExpressions; namespace NzbDrone.Core.DataAugmentation.Scene { @@ -23,6 +23,8 @@ namespace NzbDrone.Core.DataAugmentation.Scene public class SceneMappingService : ISceneMappingService, IHandle, + IHandle, + IHandle, IExecute { private readonly ISceneMappingRepository _repository; @@ -31,6 +33,7 @@ namespace NzbDrone.Core.DataAugmentation.Scene private readonly Logger _logger; private readonly ICachedDictionary> _getTvdbIdCache; private readonly ICachedDictionary> _findByTvdbIdCache; + private bool _updatedAfterStartup; public SceneMappingService(ISceneMappingRepository repository, ICacheManager cacheManager, @@ -124,6 +127,8 @@ namespace NzbDrone.Core.DataAugmentation.Scene { _logger.Info("Updating Scene mappings"); + _updatedAfterStartup = true; + foreach (var sceneMappingProvider in _sceneMappingProviders) { try @@ -268,7 +273,23 @@ namespace NzbDrone.Core.DataAugmentation.Scene public void Handle(SeriesRefreshStartingEvent message) { - if (message.ManualTrigger && _findByTvdbIdCache.IsExpired(TimeSpan.FromMinutes(1))) + if (message.ManualTrigger && (_findByTvdbIdCache.IsExpired(TimeSpan.FromMinutes(1)) || !_updatedAfterStartup)) + { + UpdateMappings(); + } + } + + public void Handle(SeriesAddedEvent message) + { + if (!_updatedAfterStartup) + { + UpdateMappings(); + } + } + + public void Handle(SeriesImportedEvent message) + { + if (!_updatedAfterStartup) { UpdateMappings(); }