From cb857934c4d3af93cb6372a4bfd96c903bcd54b0 Mon Sep 17 00:00:00 2001 From: adnanklink <32601617+adnanklink@users.noreply.github.com> Date: Sun, 29 Oct 2017 13:19:30 -0500 Subject: [PATCH] Added: Download_Id to On Download/On Upgrade (#2229) --- .../MediaFiles/EpisodeImport/ImportApprovedMovie.cs | 4 ++-- .../MediaFiles/Events/MovieDownloadedEvent.cs | 12 +++++++++--- .../Notifications/CustomScript/CustomScript.cs | 1 + src/NzbDrone.Core/Notifications/DownloadMessage.cs | 3 ++- .../Notifications/NotificationService.cs | 3 ++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs index 5187f4017..733d17c13 100644 --- a/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs +++ b/src/NzbDrone.Core/MediaFiles/EpisodeImport/ImportApprovedMovie.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -131,7 +131,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport if (newDownload) { - _eventAggregator.PublishEvent(new MovieDownloadedEvent(localMovie, movieFile, oldFiles)); + _eventAggregator.PublishEvent(new MovieDownloadedEvent(localMovie, movieFile, oldFiles, downloadClientItem)); } } catch (Exception e) diff --git a/src/NzbDrone.Core/MediaFiles/Events/MovieDownloadedEvent.cs b/src/NzbDrone.Core/MediaFiles/Events/MovieDownloadedEvent.cs index 427996088..a9af4b8df 100644 --- a/src/NzbDrone.Core/MediaFiles/Events/MovieDownloadedEvent.cs +++ b/src/NzbDrone.Core/MediaFiles/Events/MovieDownloadedEvent.cs @@ -1,6 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Common.Messaging; using NzbDrone.Core.Parser.Model; +using NzbDrone.Core.Download; namespace NzbDrone.Core.MediaFiles.Events { @@ -9,12 +10,17 @@ namespace NzbDrone.Core.MediaFiles.Events public LocalMovie Movie { get; private set; } public MovieFile MovieFile { get; private set; } public List OldFiles { get; private set; } + public string DownloadId { get; private set; } - public MovieDownloadedEvent(LocalMovie episode, MovieFile episodeFile, List oldFiles) + public MovieDownloadedEvent(LocalMovie episode, MovieFile episodeFile, List oldFiles, DownloadClientItem downloadClientItem) { Movie = episode; MovieFile = episodeFile; OldFiles = oldFiles; + if (downloadClientItem != null) + { + DownloadId = downloadClientItem.DownloadId; + } } } -} \ No newline at end of file +} diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index d49414197..a7eb5b9cb 100755 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -72,6 +72,7 @@ namespace NzbDrone.Core.Notifications.CustomScript environmentVariables.Add("Radarr_MovieFile_SceneName", movieFile.SceneName ?? string.Empty); environmentVariables.Add("Radarr_MovieFile_SourcePath", sourcePath); environmentVariables.Add("Radarr_MovieFile_SourceFolder", Path.GetDirectoryName(sourcePath)); + environmentVariables.Add("Radarr_Download_Id", message.DownloadId ?? string.Empty); if (message.OldMovieFiles.Any()) { diff --git a/src/NzbDrone.Core/Notifications/DownloadMessage.cs b/src/NzbDrone.Core/Notifications/DownloadMessage.cs index dd9343eeb..cc3f06168 100644 --- a/src/NzbDrone.Core/Notifications/DownloadMessage.cs +++ b/src/NzbDrone.Core/Notifications/DownloadMessage.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Tv; @@ -14,6 +14,7 @@ namespace NzbDrone.Core.Notifications public MovieFile MovieFile { get; set; } public List OldMovieFiles { get; set; } public string SourcePath { get; set; } + public string DownloadId { get; set; } public override string ToString() { diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index 5cf6fc308..ae626242e 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using NLog; @@ -221,6 +221,7 @@ namespace NzbDrone.Core.Notifications downloadMessage.OldFiles = null; downloadMessage.OldMovieFiles = message.OldFiles; downloadMessage.SourcePath = message.Movie.Path; + downloadMessage.DownloadId = message.DownloadId; foreach (var notification in _notificationFactory.OnDownloadEnabled()) {