Fixed: Unable to execute custom scripts if IMDB ID is null (#2543)

fixes #1460
pull/2498/head
Qstick 7 years ago committed by Leonardo Galli
parent ae88645180
commit d0406ced40

@ -1,4 +1,4 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
@ -129,8 +129,26 @@ namespace NzbDrone.Common.Processes
{ {
foreach (DictionaryEntry environmentVariable in environmentVariables) foreach (DictionaryEntry environmentVariable in environmentVariables)
{ {
try
{
_logger.Trace("Setting environment variable '{0}' to '{1}'", environmentVariable.Key, environmentVariable.Value);
startInfo.EnvironmentVariables.Add(environmentVariable.Key.ToString(), environmentVariable.Value.ToString()); startInfo.EnvironmentVariables.Add(environmentVariable.Key.ToString(), environmentVariable.Value.ToString());
} }
catch (Exception e)
{
if (environmentVariable.Value == null)
{
_logger.Error(e, "Unable to set environment variable '{0}', value is null", environmentVariable.Key);
}
else
{
_logger.Error(e, "Unable to set environment variable '{0}'", environmentVariable.Key);
}
throw;
}
}
} }
logger.Debug("Starting {0} {1}", path, args); logger.Debug("Starting {0} {1}", path, args);

@ -37,7 +37,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
environmentVariables.Add("Radarr_EventType", "Grab"); environmentVariables.Add("Radarr_EventType", "Grab");
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString()); environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.Title); environmentVariables.Add("Radarr_Movie_Title", movie.Title);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId); environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.TmdbId.ToString()); environmentVariables.Add("Radarr_Movie_TmdbId", movie.TmdbId.ToString());
environmentVariables.Add("Radarr_Release_Title", remoteMovie.Release.Title); environmentVariables.Add("Radarr_Release_Title", remoteMovie.Release.Title);
environmentVariables.Add("Radarr_Release_Indexer", remoteMovie.Release.Indexer); environmentVariables.Add("Radarr_Release_Indexer", remoteMovie.Release.Indexer);
@ -61,7 +61,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString()); environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.Title); environmentVariables.Add("Radarr_Movie_Title", movie.Title);
environmentVariables.Add("Radarr_Movie_Path", movie.Path); environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId); environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.TmdbId.ToString()); environmentVariables.Add("Radarr_Movie_TmdbId", movie.TmdbId.ToString());
environmentVariables.Add("Radarr_MovieFile_Id", movieFile.Id.ToString()); environmentVariables.Add("Radarr_MovieFile_Id", movieFile.Id.ToString());
environmentVariables.Add("Radarr_MovieFile_RelativePath", movieFile.RelativePath); environmentVariables.Add("Radarr_MovieFile_RelativePath", movieFile.RelativePath);
@ -90,7 +90,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString()); environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.Title); environmentVariables.Add("Radarr_Movie_Title", movie.Title);
environmentVariables.Add("Radarr_Movie_Path", movie.Path); environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId); environmentVariables.Add("Radarr_Movie_ImdbId", movie.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.TmdbId.ToString()); environmentVariables.Add("Radarr_Movie_TmdbId", movie.TmdbId.ToString());
ExecuteScript(environmentVariables); ExecuteScript(environmentVariables);

Loading…
Cancel
Save