mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-10-30 15:32:31 +01:00
Use an event to update title mismatches
This commit is contained in:
parent
3c1df5693c
commit
907aa4a0ba
@ -27,6 +27,7 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
{
|
||||
private readonly ISceneMappingRepository _repository;
|
||||
private readonly IEnumerable<ISceneMappingProvider> _sceneMappingProviders;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly Logger _logger;
|
||||
private readonly ICached<SceneMapping> _getTvdbIdCache;
|
||||
private readonly ICached<List<SceneMapping>> _findByTvdbIdCache;
|
||||
@ -34,10 +35,12 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
public SceneMappingService(ISceneMappingRepository repository,
|
||||
ICacheManager cacheManager,
|
||||
IEnumerable<ISceneMappingProvider> sceneMappingProviders,
|
||||
IEventAggregator eventAggregator,
|
||||
Logger logger)
|
||||
{
|
||||
_repository = repository;
|
||||
_sceneMappingProviders = sceneMappingProviders;
|
||||
_eventAggregator = eventAggregator;
|
||||
|
||||
_getTvdbIdCache = cacheManager.GetCache<SceneMapping>(GetType(), "tvdb_id");
|
||||
_findByTvdbIdCache = cacheManager.GetCache<List<SceneMapping>>(GetType(), "find_tvdb_id");
|
||||
@ -129,6 +132,7 @@ namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
}
|
||||
|
||||
RefreshCache();
|
||||
_eventAggregator.PublishEvent(new SceneMappingsUpdatedEvent());
|
||||
}
|
||||
|
||||
private SceneMapping FindTvdbId(string title)
|
||||
|
@ -0,0 +1,8 @@
|
||||
using NzbDrone.Common.Messaging;
|
||||
|
||||
namespace NzbDrone.Core.DataAugmentation.Scene
|
||||
{
|
||||
public class SceneMappingsUpdatedEvent : IEvent
|
||||
{
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ using NLog;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Common.Cache;
|
||||
using NzbDrone.Core.Configuration;
|
||||
using NzbDrone.Core.DataAugmentation.Scene;
|
||||
using NzbDrone.Core.History;
|
||||
using NzbDrone.Core.Messaging.Commands;
|
||||
using NzbDrone.Core.Messaging.Events;
|
||||
@ -25,7 +26,8 @@ namespace NzbDrone.Core.Download
|
||||
public class DownloadTrackingService : IDownloadTrackingService,
|
||||
IExecute<CheckForFinishedDownloadCommand>,
|
||||
IHandleAsync<ApplicationStartedEvent>,
|
||||
IHandle<EpisodeGrabbedEvent>
|
||||
IHandle<EpisodeGrabbedEvent>,
|
||||
IHandle<SceneMappingsUpdatedEvent>
|
||||
{
|
||||
private readonly IProvideDownloadClient _downloadClientProvider;
|
||||
private readonly IHistoryService _historyService;
|
||||
@ -152,8 +154,7 @@ namespace NzbDrone.Core.Download
|
||||
|
||||
if (newTrackedDownloads.ContainsKey(trackingId)) continue;
|
||||
|
||||
//TODO: Rebuilding the tracked download when it is a warning is a total hack to deal with updated scene mappings
|
||||
if (!oldTrackedDownloads.TryGetValue(trackingId, out trackedDownload) || trackedDownload.Status == TrackedDownloadStatus.Warning)
|
||||
if (!oldTrackedDownloads.TryGetValue(trackingId, out trackedDownload))
|
||||
{
|
||||
trackedDownload = GetTrackedDownload(trackingId, downloadClient.Definition.Id, downloadItem, grabbedHistory);
|
||||
|
||||
@ -244,7 +245,6 @@ namespace NzbDrone.Core.Download
|
||||
Status = TrackedDownloadStatus.Ok,
|
||||
};
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
var historyItems = grabbedHistory.Where(h =>
|
||||
@ -298,5 +298,18 @@ namespace NzbDrone.Core.Download
|
||||
{
|
||||
ProcessTrackedDownloads();
|
||||
}
|
||||
|
||||
public void Handle(SceneMappingsUpdatedEvent message)
|
||||
{
|
||||
var grabbedHistory = _historyService.Grabbed();
|
||||
|
||||
foreach (var trackedDownload in GetTrackedDownloads().Where(t => t.Status == TrackedDownloadStatus.Warning))
|
||||
{
|
||||
var newTrackedDownload = GetTrackedDownload(trackedDownload.TrackingId, trackedDownload.DownloadClient, trackedDownload.DownloadItem, grabbedHistory);
|
||||
|
||||
trackedDownload.Status = newTrackedDownload.Status;
|
||||
trackedDownload.StatusMessages = newTrackedDownload.StatusMessages;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,6 +135,7 @@
|
||||
<Compile Include="DataAugmentation\Scene\SceneMappingProxy.cs" />
|
||||
<Compile Include="DataAugmentation\Scene\SceneMappingRepository.cs" />
|
||||
<Compile Include="DataAugmentation\Scene\SceneMappingService.cs" />
|
||||
<Compile Include="DataAugmentation\Scene\SceneMappingsUpdatedEvent.cs" />
|
||||
<Compile Include="DataAugmentation\Scene\ServicesProvider.cs" />
|
||||
<Compile Include="DataAugmentation\Scene\UpdateSceneMappingCommand.cs" />
|
||||
<Compile Include="DataAugmentation\Xem\Model\XemResult.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user