diff --git a/src/NzbDrone.Core/Download/CompletedDownloadService.cs b/src/NzbDrone.Core/Download/CompletedDownloadService.cs index 172db7183..a0877bbc8 100644 --- a/src/NzbDrone.Core/Download/CompletedDownloadService.cs +++ b/src/NzbDrone.Core/Download/CompletedDownloadService.cs @@ -141,7 +141,7 @@ namespace NzbDrone.Core.Download if (allEpisodesImported) { trackedDownload.State = TrackedDownloadState.Imported; - _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); + _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, trackedDownload.RemoteEpisode.Series.Id)); return true; } @@ -165,7 +165,7 @@ namespace NzbDrone.Core.Download if (allEpisodesImportedInHistory) { trackedDownload.State = TrackedDownloadState.Imported; - _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); + _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, trackedDownload.RemoteEpisode.Series.Id)); return true; } } diff --git a/src/NzbDrone.Core/Download/DownloadCompletedEvent.cs b/src/NzbDrone.Core/Download/DownloadCompletedEvent.cs index 2cad558f0..56ba2c842 100644 --- a/src/NzbDrone.Core/Download/DownloadCompletedEvent.cs +++ b/src/NzbDrone.Core/Download/DownloadCompletedEvent.cs @@ -6,10 +6,12 @@ namespace NzbDrone.Core.Download public class DownloadCompletedEvent : IEvent { public TrackedDownload TrackedDownload { get; private set; } + public int SeriesId { get; set; } - public DownloadCompletedEvent(TrackedDownload trackedDownload) + public DownloadCompletedEvent(TrackedDownload trackedDownload, int seriesId) { TrackedDownload = trackedDownload; + SeriesId = seriesId; } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Download/DownloadProcessingService.cs b/src/NzbDrone.Core/Download/DownloadProcessingService.cs index 3b3cd1b82..21aec3216 100644 --- a/src/NzbDrone.Core/Download/DownloadProcessingService.cs +++ b/src/NzbDrone.Core/Download/DownloadProcessingService.cs @@ -41,7 +41,8 @@ namespace NzbDrone.Core.Download foreach (var trackedDownload in trackedDownloads) { - _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); + _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, + trackedDownload.RemoteEpisode.Series.Id)); } } diff --git a/src/NzbDrone.Core/Download/History/DownloadHistoryService.cs b/src/NzbDrone.Core/Download/History/DownloadHistoryService.cs index 519631ea0..666970da8 100644 --- a/src/NzbDrone.Core/Download/History/DownloadHistoryService.cs +++ b/src/NzbDrone.Core/Download/History/DownloadHistoryService.cs @@ -88,6 +88,12 @@ namespace NzbDrone.Core.Download.History public void Handle(EpisodeGrabbedEvent message) { + // Don't store grabbed events for clients that don't download IDs + if (message.DownloadId.IsNullOrWhiteSpace()) + { + return; + } + var history = new DownloadHistory { EventType = DownloadHistoryEventType.DownloadGrabbed, @@ -155,7 +161,7 @@ namespace NzbDrone.Core.Download.History var history = new DownloadHistory { EventType = DownloadHistoryEventType.DownloadImported, - SeriesId = message.TrackedDownload.RemoteEpisode.Series.Id, + SeriesId = message.SeriesId, DownloadId = message.TrackedDownload.DownloadItem.DownloadId, SourceTitle = message.TrackedDownload.DownloadItem.OutputPath.ToString(), Date = DateTime.UtcNow, diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs index 464d7e9a1..7bcc55af2 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/Manual/ManualImportService.cs @@ -372,7 +372,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport.Manual if (allEpisodesImported) { trackedDownload.State = TrackedDownloadState.Imported; - _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload)); + _eventAggregator.PublishEvent(new DownloadCompletedEvent(trackedDownload, imported.First().ImportDecision.LocalEpisode.Series.Id)); } } }