diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index ae274263a..cd07c4155 100644 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -8,6 +8,7 @@ using NLog; using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Common.Processes; +using NzbDrone.Core.Configuration; using NzbDrone.Core.HealthCheck; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles.MediaInfo; @@ -20,12 +21,20 @@ namespace NzbDrone.Core.Notifications.CustomScript { public class CustomScript : NotificationBase { + private readonly IConfigFileProvider _configFileProvider; + private readonly IConfigService _configService; private readonly IDiskProvider _diskProvider; private readonly IProcessProvider _processProvider; private readonly Logger _logger; - public CustomScript(IDiskProvider diskProvider, IProcessProvider processProvider, Logger logger) + public CustomScript(IConfigFileProvider configFileProvider, + IConfigService configService, + IDiskProvider diskProvider, + IProcessProvider processProvider, + Logger logger) { + _configFileProvider = configFileProvider; + _configService = configService; _diskProvider = diskProvider; _processProvider = processProvider; _logger = logger; @@ -45,8 +54,11 @@ namespace NzbDrone.Core.Notifications.CustomScript var environmentVariables = new StringDictionary(); environmentVariables.Add("Sonarr_EventType", "Grab"); + environmentVariables.Add("Sonarr_InstanceName", _configFileProvider.InstanceName); + environmentVariables.Add("Sonarr_ApplicationUrl", _configService.ApplicationUrl); environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString()); environmentVariables.Add("Sonarr_Series_Title", series.Title); + environmentVariables.Add("Sonarr_Series_TitleSlug", series.TitleSlug); environmentVariables.Add("Sonarr_Series_TvdbId", series.TvdbId.ToString()); environmentVariables.Add("Sonarr_Series_TvMazeId", series.TvMazeId.ToString()); environmentVariables.Add("Sonarr_Series_ImdbId", series.ImdbId ?? string.Empty); @@ -58,6 +70,7 @@ namespace NzbDrone.Core.Notifications.CustomScript environmentVariables.Add("Sonarr_Release_EpisodeAirDates", string.Join(",", remoteEpisode.Episodes.Select(e => e.AirDate))); environmentVariables.Add("Sonarr_Release_EpisodeAirDatesUtc", string.Join(",", remoteEpisode.Episodes.Select(e => e.AirDateUtc))); environmentVariables.Add("Sonarr_Release_EpisodeTitles", string.Join("|", remoteEpisode.Episodes.Select(e => e.Title))); + environmentVariables.Add("Sonarr_Release_EpisodeOverviews", string.Join("|", remoteEpisode.Episodes.Select(e => e.Overview))); environmentVariables.Add("Sonarr_Release_Title", remoteEpisode.Release.Title); environmentVariables.Add("Sonarr_Release_Indexer", remoteEpisode.Release.Indexer ?? string.Empty); environmentVariables.Add("Sonarr_Release_Size", remoteEpisode.Release.Size.ToString()); @@ -81,9 +94,12 @@ namespace NzbDrone.Core.Notifications.CustomScript var environmentVariables = new StringDictionary(); environmentVariables.Add("Sonarr_EventType", "Download"); + environmentVariables.Add("Sonarr_InstanceName", _configFileProvider.InstanceName); + environmentVariables.Add("Sonarr_ApplicationUrl", _configService.ApplicationUrl); environmentVariables.Add("Sonarr_IsUpgrade", message.OldFiles.Any().ToString()); environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString()); environmentVariables.Add("Sonarr_Series_Title", series.Title); + environmentVariables.Add("Sonarr_Series_TitleSlug", series.TitleSlug); environmentVariables.Add("Sonarr_Series_Path", series.Path); environmentVariables.Add("Sonarr_Series_TvdbId", series.TvdbId.ToString()); environmentVariables.Add("Sonarr_Series_TvMazeId", series.TvMazeId.ToString()); @@ -99,6 +115,7 @@ namespace NzbDrone.Core.Notifications.CustomScript environmentVariables.Add("Sonarr_EpisodeFile_EpisodeAirDates", string.Join(",", episodeFile.Episodes.Value.Select(e => e.AirDate))); environmentVariables.Add("Sonarr_EpisodeFile_EpisodeAirDatesUtc", string.Join(",", episodeFile.Episodes.Value.Select(e => e.AirDateUtc))); environmentVariables.Add("Sonarr_EpisodeFile_EpisodeTitles", string.Join("|", episodeFile.Episodes.Value.Select(e => e.Title))); + environmentVariables.Add("Sonarr_EpisodeFile_EpisodeOverviews", string.Join("|", episodeFile.Episodes.Value.Select(e => e.Overview))); environmentVariables.Add("Sonarr_EpisodeFile_Quality", episodeFile.Quality.Quality.Name); environmentVariables.Add("Sonarr_EpisodeFile_QualityVersion", episodeFile.Quality.Revision.Version.ToString()); environmentVariables.Add("Sonarr_EpisodeFile_ReleaseGroup", episodeFile.ReleaseGroup ?? string.Empty); @@ -133,8 +150,11 @@ namespace NzbDrone.Core.Notifications.CustomScript var environmentVariables = new StringDictionary(); environmentVariables.Add("Sonarr_EventType", "Rename"); + environmentVariables.Add("Sonarr_InstanceName", _configFileProvider.InstanceName); + environmentVariables.Add("Sonarr_ApplicationUrl", _configService.ApplicationUrl); environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString()); environmentVariables.Add("Sonarr_Series_Title", series.Title); + environmentVariables.Add("Sonarr_Series_TitleSlug", series.TitleSlug); environmentVariables.Add("Sonarr_Series_Path", series.Path); environmentVariables.Add("Sonarr_Series_TvdbId", series.TvdbId.ToString()); environmentVariables.Add("Sonarr_Series_TvMazeId", series.TvMazeId.ToString()); @@ -157,9 +177,12 @@ namespace NzbDrone.Core.Notifications.CustomScript var environmentVariables = new StringDictionary(); environmentVariables.Add("Sonarr_EventType", "EpisodeFileDelete"); + environmentVariables.Add("Sonarr_InstanceName", _configFileProvider.InstanceName); + environmentVariables.Add("Sonarr_ApplicationUrl", _configService.ApplicationUrl); environmentVariables.Add("Sonarr_EpisodeFile_DeleteReason", deleteMessage.Reason.ToString()); environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString()); environmentVariables.Add("Sonarr_Series_Title", series.Title); + environmentVariables.Add("Sonarr_Series_TitleSlug", series.TitleSlug); environmentVariables.Add("Sonarr_Series_Path", series.Path); environmentVariables.Add("Sonarr_Series_TvdbId", series.TvdbId.ToString()); environmentVariables.Add("Sonarr_Series_TvMazeId", series.TvMazeId.ToString()); @@ -175,6 +198,7 @@ namespace NzbDrone.Core.Notifications.CustomScript environmentVariables.Add("Sonarr_EpisodeFile_EpisodeAirDates", string.Join(",", episodeFile.Episodes.Value.Select(e => e.AirDate))); environmentVariables.Add("Sonarr_EpisodeFile_EpisodeAirDatesUtc", string.Join(",", episodeFile.Episodes.Value.Select(e => e.AirDateUtc))); environmentVariables.Add("Sonarr_EpisodeFile_EpisodeTitles", string.Join("|", episodeFile.Episodes.Value.Select(e => e.Title))); + environmentVariables.Add("Sonarr_EpisodeFile_EpisodeOverviews", string.Join("|", episodeFile.Episodes.Value.Select(e => e.Overview))); environmentVariables.Add("Sonarr_EpisodeFile_Quality", episodeFile.Quality.Quality.Name); environmentVariables.Add("Sonarr_EpisodeFile_QualityVersion", episodeFile.Quality.Revision.Version.ToString()); environmentVariables.Add("Sonarr_EpisodeFile_ReleaseGroup", episodeFile.ReleaseGroup ?? string.Empty); @@ -189,8 +213,11 @@ namespace NzbDrone.Core.Notifications.CustomScript var environmentVariables = new StringDictionary(); environmentVariables.Add("Sonarr_EventType", "SeriesDelete"); + environmentVariables.Add("Sonarr_InstanceName", _configFileProvider.InstanceName); + environmentVariables.Add("Sonarr_ApplicationUrl", _configService.ApplicationUrl); environmentVariables.Add("Sonarr_Series_Id", series.Id.ToString()); environmentVariables.Add("Sonarr_Series_Title", series.Title); + environmentVariables.Add("Sonarr_Series_TitleSlug", series.TitleSlug); environmentVariables.Add("Sonarr_Series_Path", series.Path); environmentVariables.Add("Sonarr_Series_TvdbId", series.TvdbId.ToString()); environmentVariables.Add("Sonarr_Series_TvMazeId", series.TvMazeId.ToString()); @@ -206,6 +233,8 @@ namespace NzbDrone.Core.Notifications.CustomScript var environmentVariables = new StringDictionary(); environmentVariables.Add("Sonarr_EventType", "HealthIssue"); + environmentVariables.Add("Sonarr_InstanceName", _configFileProvider.InstanceName); + environmentVariables.Add("Sonarr_ApplicationUrl", _configService.ApplicationUrl); environmentVariables.Add("Sonarr_Health_Issue_Level", Enum.GetName(typeof(HealthCheckResult), healthCheck.Type)); environmentVariables.Add("Sonarr_Health_Issue_Message", healthCheck.Message); environmentVariables.Add("Sonarr_Health_Issue_Type", healthCheck.Source.Name); @@ -219,6 +248,8 @@ namespace NzbDrone.Core.Notifications.CustomScript var environmentVariables = new StringDictionary(); environmentVariables.Add("Sonarr_EventType", "ApplicationUpdate"); + environmentVariables.Add("Sonarr_InstanceName", _configFileProvider.InstanceName); + environmentVariables.Add("Sonarr_ApplicationUrl", _configService.ApplicationUrl); environmentVariables.Add("Sonarr_Update_Message", updateMessage.Message); environmentVariables.Add("Sonarr_Update_NewVersion", updateMessage.NewVersion.ToString()); environmentVariables.Add("Sonarr_Update_PreviousVersion", updateMessage.PreviousVersion.ToString()); @@ -249,6 +280,8 @@ namespace NzbDrone.Core.Notifications.CustomScript { var environmentVariables = new StringDictionary(); environmentVariables.Add("Sonarr_EventType", "Test"); + environmentVariables.Add("Sonarr_InstanceName", _configFileProvider.InstanceName); + environmentVariables.Add("Sonarr_ApplicationUrl", _configService.ApplicationUrl); var processOutput = ExecuteScript(environmentVariables); diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 9f84128a1..2777bd06f 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using FluentValidation.Results; using NzbDrone.Common.Extensions; +using NzbDrone.Core.Configuration; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Tv; using NzbDrone.Core.Validation; @@ -11,10 +12,16 @@ namespace NzbDrone.Core.Notifications.Webhook { public class Webhook : NotificationBase { + private readonly IConfigFileProvider _configFileProvider; + private readonly IConfigService _configService; private readonly IWebhookProxy _proxy; - public Webhook(IWebhookProxy proxy) + public Webhook(IConfigFileProvider configFileProvider, + IConfigService configService, + IWebhookProxy proxy) { + _configFileProvider = configFileProvider; + _configService = configService; _proxy = proxy; } @@ -28,6 +35,8 @@ namespace NzbDrone.Core.Notifications.Webhook var payload = new WebhookGrabPayload { EventType = WebhookEventType.Grab, + InstanceName = _configFileProvider.InstanceName, + ApplicationUrl = _configService.ApplicationUrl, Series = new WebhookSeries(message.Series), Episodes = remoteEpisode.Episodes.ConvertAll(x => new WebhookEpisode(x)), Release = new WebhookRelease(quality, remoteEpisode), @@ -46,6 +55,8 @@ namespace NzbDrone.Core.Notifications.Webhook var payload = new WebhookImportPayload { EventType = WebhookEventType.Download, + InstanceName = _configFileProvider.InstanceName, + ApplicationUrl = _configService.ApplicationUrl, Series = new WebhookSeries(message.Series), Episodes = episodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x)), EpisodeFile = new WebhookEpisodeFile(episodeFile), @@ -71,6 +82,8 @@ namespace NzbDrone.Core.Notifications.Webhook var payload = new WebhookRenamePayload { EventType = WebhookEventType.Rename, + InstanceName = _configFileProvider.InstanceName, + ApplicationUrl = _configService.ApplicationUrl, Series = new WebhookSeries(series), RenamedEpisodeFiles = renamedFiles.ConvertAll(x => new WebhookRenamedEpisodeFile(x)) }; @@ -83,6 +96,8 @@ namespace NzbDrone.Core.Notifications.Webhook var payload = new WebhookEpisodeDeletePayload { EventType = WebhookEventType.EpisodeFileDelete, + InstanceName = _configFileProvider.InstanceName, + ApplicationUrl = _configService.ApplicationUrl, Series = new WebhookSeries(deleteMessage.Series), Episodes = deleteMessage.EpisodeFile.Episodes.Value.ConvertAll(x => new WebhookEpisode(x)), EpisodeFile = deleteMessage.EpisodeFile, @@ -97,6 +112,8 @@ namespace NzbDrone.Core.Notifications.Webhook var payload = new WebhookSeriesDeletePayload { EventType = WebhookEventType.SeriesDelete, + InstanceName = _configFileProvider.InstanceName, + ApplicationUrl = _configService.ApplicationUrl, Series = new WebhookSeries(deleteMessage.Series), DeletedFiles = deleteMessage.DeletedFiles }; @@ -109,6 +126,8 @@ namespace NzbDrone.Core.Notifications.Webhook var payload = new WebhookHealthPayload { EventType = WebhookEventType.Health, + InstanceName = _configFileProvider.InstanceName, + ApplicationUrl = _configService.ApplicationUrl, Level = healthCheck.Type, Message = healthCheck.Message, Type = healthCheck.Source.Name, @@ -123,6 +142,8 @@ namespace NzbDrone.Core.Notifications.Webhook var payload = new WebhookApplicationUpdatePayload { EventType = WebhookEventType.ApplicationUpdate, + InstanceName = _configFileProvider.InstanceName, + ApplicationUrl = _configService.ApplicationUrl, Message = updateMessage.Message, PreviousVersion = updateMessage.PreviousVersion.ToString(), NewVersion = updateMessage.NewVersion.ToString() @@ -149,6 +170,8 @@ namespace NzbDrone.Core.Notifications.Webhook var payload = new WebhookGrabPayload { EventType = WebhookEventType.Test, + InstanceName = _configFileProvider.InstanceName, + ApplicationUrl = _configService.ApplicationUrl, Series = new WebhookSeries() { Id = 1, diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs index 5851e97d0..29fa466aa 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookEpisode.cs @@ -15,15 +15,19 @@ namespace NzbDrone.Core.Notifications.Webhook SeasonNumber = episode.SeasonNumber; EpisodeNumber = episode.EpisodeNumber; Title = episode.Title; + Overview = episode.Overview; AirDate = episode.AirDate; AirDateUtc = episode.AirDateUtc; + SeriesId = episode.SeriesId; } public int Id { get; set; } public int EpisodeNumber { get; set; } public int SeasonNumber { get; set; } public string Title { get; set; } + public string Overview { get; set; } public string AirDate { get; set; } public DateTime? AirDateUtc { get; set; } + public int SeriesId { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs index f16d8e20d..8475b05b9 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookPayload.cs @@ -3,5 +3,7 @@ public class WebhookPayload { public WebhookEventType EventType { get; set; } + public string InstanceName { get; set; } + public string ApplicationUrl { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs index c3f22c998..04734ea51 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookSeries.cs @@ -6,6 +6,7 @@ namespace NzbDrone.Core.Notifications.Webhook { public int Id { get; set; } public string Title { get; set; } + public string TitleSlug { get; set; } public string Path { get; set; } public int TvdbId { get; set; } public int TvMazeId { get; set; } @@ -20,6 +21,7 @@ namespace NzbDrone.Core.Notifications.Webhook { Id = series.Id; Title = series.Title; + TitleSlug = series.TitleSlug; Path = series.Path; TvdbId = series.TvdbId; TvMazeId = series.TvMazeId;