From a5369df197f69dedde94b7d5dacc312f433c2042 Mon Sep 17 00:00:00 2001 From: Qstick Date: Tue, 24 Apr 2018 23:19:00 -0400 Subject: [PATCH] Fixed: Album reference causing nullRef on custom scripts (#325) --- .../Notifications/CustomScript/CustomScript.cs | 7 ++++++- src/NzbDrone.Core/Notifications/NotificationService.cs | 1 + src/NzbDrone.Core/Notifications/TrackDownloadMessage.cs | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index fb4e0b2fb..e91ee4b54 100644 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -58,6 +58,7 @@ namespace NzbDrone.Core.Notifications.CustomScript public override void OnDownload(TrackDownloadMessage message) { var artist = message.Artist; + var album = message.Album; var trackFile = message.TrackFile; var sourcePath = message.SourcePath; var environmentVariables = new StringDictionary(); @@ -69,12 +70,15 @@ namespace NzbDrone.Core.Notifications.CustomScript environmentVariables.Add("Lidarr_Artist_Path", artist.Path); environmentVariables.Add("Lidarr_Artist_MBId", artist.ForeignArtistId); environmentVariables.Add("Lidarr_Artist_Type", artist.ArtistType); + environmentVariables.Add("Lidarr_Album_Id", album.Id.ToString()); + environmentVariables.Add("Lidarr_Album_Title", album.Title); + environmentVariables.Add("Lidarr_Album_MBId", album.ForeignAlbumId); + environmentVariables.Add("Lidarr_Album_ReleaseDate", album.ReleaseDate.ToString()); environmentVariables.Add("Lidarr_TrackFile_Id", trackFile.Id.ToString()); environmentVariables.Add("Lidarr_TrackFile_TrackCount", trackFile.Tracks.Value.Count.ToString()); environmentVariables.Add("Lidarr_TrackFile_RelativePath", trackFile.RelativePath); environmentVariables.Add("Lidarr_TrackFile_Path", Path.Combine(artist.Path, trackFile.RelativePath)); environmentVariables.Add("Lidarr_TrackFile_TrackNumbers", string.Join(",", trackFile.Tracks.Value.Select(e => e.TrackNumber))); - environmentVariables.Add("Lidarr_TrackFile_TrackReleaseDates", string.Join(",", trackFile.Tracks.Value.Select(e => e.Album.ReleaseDate))); environmentVariables.Add("Lidarr_TrackFile_TrackTitles", string.Join("|", trackFile.Tracks.Value.Select(e => e.Title))); environmentVariables.Add("Lidarr_TrackFile_Quality", trackFile.Quality.Quality.Name); environmentVariables.Add("Lidarr_TrackFile_QualityVersion", trackFile.Quality.Revision.Version.ToString()); @@ -109,6 +113,7 @@ namespace NzbDrone.Core.Notifications.CustomScript environmentVariables.Add("Lidarr_Album_Id", album.Id.ToString()); environmentVariables.Add("Lidarr_Album_Title", album.Title); environmentVariables.Add("Lidarr_Album_MBId", album.ForeignAlbumId); + environmentVariables.Add("Lidarr_Album_ReleaseDate", album.ReleaseDate.ToString()); environmentVariables.Add("Lidarr_Download_Client", message.DownloadClient ?? string.Empty); environmentVariables.Add("Lidarr_Download_Id", message.DownloadId ?? string.Empty); diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index b6e3eb651..836d309f0 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -130,6 +130,7 @@ namespace NzbDrone.Core.Notifications { Message = GetTrackMessage(message.TrackInfo.Artist, message.TrackInfo.Tracks, message.TrackInfo.Quality), Artist = message.TrackInfo.Artist, + Album = message.TrackInfo.Album, TrackFile = message.ImportedTrack, OldFiles = message.OldFiles, SourcePath = message.TrackInfo.Path, diff --git a/src/NzbDrone.Core/Notifications/TrackDownloadMessage.cs b/src/NzbDrone.Core/Notifications/TrackDownloadMessage.cs index 228cadd43..dc442f288 100644 --- a/src/NzbDrone.Core/Notifications/TrackDownloadMessage.cs +++ b/src/NzbDrone.Core/Notifications/TrackDownloadMessage.cs @@ -8,6 +8,7 @@ namespace NzbDrone.Core.Notifications { public string Message { get; set; } public Artist Artist { get; set; } + public Album Album { get; set; } public TrackFile TrackFile { get; set; } public List OldFiles { get; set; } public string SourcePath { get; set; }