Fixed: Album reference causing nullRef on custom scripts (#325)

pull/342/head
Qstick 7 years ago committed by GitHub
parent 8f0897f70c
commit a5369df197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);

@ -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,

@ -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<TrackFile> OldFiles { get; set; }
public string SourcePath { get; set; }

Loading…
Cancel
Save