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

fixes #1460
pull/2/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.Generic;
using System.Collections.Specialized;
@ -98,9 +98,9 @@ namespace NzbDrone.Common.Processes
var process = new Process
{
StartInfo = new ProcessStartInfo(url)
{
UseShellExecute = true
}
{
UseShellExecute = true
}
};
process.Start();
@ -129,16 +129,34 @@ namespace NzbDrone.Common.Processes
{
foreach (DictionaryEntry environmentVariable in environmentVariables)
{
startInfo.EnvironmentVariables.Add(environmentVariable.Key.ToString(), environmentVariable.Value.ToString());
try
{
_logger.Trace("Setting environment variable '{0}' to '{1}'", environmentVariable.Key, environmentVariable.Value);
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);
var process = new Process
{
StartInfo = startInfo
};
{
StartInfo = startInfo
};
process.OutputDataReceived += (sender, eventArgs) =>
{
@ -315,7 +333,7 @@ namespace NzbDrone.Common.Processes
var monoProcesses = Process.GetProcessesByName("mono")
.Union(Process.GetProcessesByName("mono-sgen"))
.Union(Process.GetProcessesByName("mono-sgen32"))
.Union(Process.GetProcessesByName("mono-sgen32"))
.Where(process =>
process.Modules.Cast<ProcessModule>()
.Any(module =>

@ -37,7 +37,7 @@ namespace NzbDrone.Core.Notifications.CustomScript
environmentVariables.Add("Radarr_EventType", "Grab");
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
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_Release_Title", remoteMovie.Release.Title);
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_Title", movie.Title);
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_MovieFile_Id", movieFile.Id.ToString());
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_Title", movie.Title);
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());
ExecuteScript(environmentVariables);

Loading…
Cancel
Save