diff --git a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs index cd07c4155..bfa848193 100644 --- a/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs +++ b/src/NzbDrone.Core/Notifications/CustomScript/CustomScript.cs @@ -134,6 +134,8 @@ namespace NzbDrone.Core.Notifications.CustomScript environmentVariables.Add("Sonarr_EpisodeFile_MediaInfo_Subtitles", episodeFile.MediaInfo.Subtitles.ConcatToString(" / ")); environmentVariables.Add("Sonarr_EpisodeFile_MediaInfo_VideoCodec", MediaInfoFormatter.FormatVideoCodec(episodeFile.MediaInfo, null)); environmentVariables.Add("Sonarr_EpisodeFile_MediaInfo_VideoDynamicRangeType", MediaInfoFormatter.FormatVideoDynamicRangeType(episodeFile.MediaInfo)); + environmentVariables.Add("Sonarr_EpisodeFile_CustomFormat", string.Join("|", message.EpisodeInfo.CustomFormats)); + environmentVariables.Add("Sonarr_EpisodeFile_CustomFormatScore", message.EpisodeInfo.CustomFormatScore.ToString()); if (message.OldFiles.Any()) { diff --git a/src/NzbDrone.Core/Notifications/DownloadMessage.cs b/src/NzbDrone.Core/Notifications/DownloadMessage.cs index 619f4f918..2e94ecf64 100644 --- a/src/NzbDrone.Core/Notifications/DownloadMessage.cs +++ b/src/NzbDrone.Core/Notifications/DownloadMessage.cs @@ -1,6 +1,7 @@ -using System.Collections.Generic; +using System.Collections.Generic; using NzbDrone.Core.Download; using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Tv; namespace NzbDrone.Core.Notifications @@ -9,6 +10,7 @@ namespace NzbDrone.Core.Notifications { public string Message { get; set; } public Series Series { get; set; } + public LocalEpisode EpisodeInfo { get; set; } public EpisodeFile EpisodeFile { get; set; } public List OldFiles { get; set; } public string SourcePath { get; set; } diff --git a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs index 1cedcfd78..893d7f02e 100644 --- a/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs +++ b/src/NzbDrone.Core/Notifications/Notifiarr/Notifiarr.cs @@ -104,6 +104,8 @@ namespace NzbDrone.Core.Notifications.Notifiarr variables.Add("Sonarr_EpisodeFile_MediaInfo_Subtitles", episodeFile.MediaInfo.Subtitles.ConcatToString(" / ")); variables.Add("Sonarr_EpisodeFile_MediaInfo_VideoCodec", MediaInfoFormatter.FormatVideoCodec(episodeFile.MediaInfo, null)); variables.Add("Sonarr_EpisodeFile_MediaInfo_VideoDynamicRangeType", MediaInfoFormatter.FormatVideoDynamicRangeType(episodeFile.MediaInfo)); + variables.Add("Sonarr_EpisodeFile_CustomFormat", string.Join("|", message.EpisodeInfo.CustomFormats)); + variables.Add("Sonarr_EpisodeFile_CustomFormatScore", message.EpisodeInfo.CustomFormatScore.ToString()); if (message.OldFiles.Any()) { diff --git a/src/NzbDrone.Core/Notifications/NotificationService.cs b/src/NzbDrone.Core/Notifications/NotificationService.cs index d6dfee81b..3408f97c7 100644 --- a/src/NzbDrone.Core/Notifications/NotificationService.cs +++ b/src/NzbDrone.Core/Notifications/NotificationService.cs @@ -152,6 +152,7 @@ namespace NzbDrone.Core.Notifications { Message = GetMessage(message.EpisodeInfo.Series, message.EpisodeInfo.Episodes, message.EpisodeInfo.Quality), Series = message.EpisodeInfo.Series, + EpisodeInfo = message.EpisodeInfo, EpisodeFile = message.ImportedEpisode, OldFiles = message.OldFiles, SourcePath = message.EpisodeInfo.Path, diff --git a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs index 2777bd06f..59da139a4 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/Webhook.cs @@ -42,7 +42,8 @@ namespace NzbDrone.Core.Notifications.Webhook Release = new WebhookRelease(quality, remoteEpisode), DownloadClient = message.DownloadClientName, DownloadClientType = message.DownloadClientType, - DownloadId = message.DownloadId + DownloadId = message.DownloadId, + CustomFormatInfo = new WebhookCustomFormatInfo(remoteEpisode.CustomFormats, remoteEpisode.CustomFormatScore) }; _proxy.SendWebhook(payload, Settings); @@ -63,7 +64,8 @@ namespace NzbDrone.Core.Notifications.Webhook IsUpgrade = message.OldFiles.Any(), DownloadClient = message.DownloadClientInfo?.Name, DownloadClientType = message.DownloadClientInfo?.Type, - DownloadId = message.DownloadId + DownloadId = message.DownloadId, + CustomFormatInfo = new WebhookCustomFormatInfo(message.EpisodeInfo.CustomFormats, message.EpisodeInfo.CustomFormatScore) }; if (message.OldFiles.Any()) diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookCustomFormat.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookCustomFormat.cs new file mode 100644 index 000000000..192137f43 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookCustomFormat.cs @@ -0,0 +1,18 @@ +using System.Text.Json.Serialization; +using NzbDrone.Core.CustomFormats; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookCustomFormat + { + [JsonIgnore(Condition = JsonIgnoreCondition.Never)] + public int Id { get; set; } + public string Name { get; set; } + + public WebhookCustomFormat(CustomFormat customFormat) + { + Id = customFormat.Id; + Name = customFormat.Name; + } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookCustomFormatInfo.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookCustomFormatInfo.cs new file mode 100644 index 000000000..81a88e87b --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookCustomFormatInfo.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Linq; +using NzbDrone.Core.CustomFormats; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookCustomFormatInfo + { + public List CustomFormats { get; set; } + public int CustomFormatScore { get; set; } + + public WebhookCustomFormatInfo(List customFormats, int customFormatScore) + { + CustomFormats = customFormats.Select(c => new WebhookCustomFormat(c)).ToList(); + CustomFormatScore = customFormatScore; + } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs index ebeef36f6..3de25d786 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookGrabPayload.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace NzbDrone.Core.Notifications.Webhook { @@ -10,5 +10,6 @@ namespace NzbDrone.Core.Notifications.Webhook public string DownloadClient { get; set; } public string DownloadClientType { get; set; } public string DownloadId { get; set; } + public WebhookCustomFormatInfo CustomFormatInfo { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs index 886a45e0f..e7720d849 100644 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookImportPayload.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace NzbDrone.Core.Notifications.Webhook { @@ -12,5 +12,6 @@ namespace NzbDrone.Core.Notifications.Webhook public string DownloadClientType { get; set; } public string DownloadId { get; set; } public List DeletedFiles { get; set; } + public WebhookCustomFormatInfo CustomFormatInfo { get; set; } } } diff --git a/src/NzbDrone.Core/Parser/Model/LocalEpisode.cs b/src/NzbDrone.Core/Parser/Model/LocalEpisode.cs index 91427a3f7..d9fa0fcd7 100644 --- a/src/NzbDrone.Core/Parser/Model/LocalEpisode.cs +++ b/src/NzbDrone.Core/Parser/Model/LocalEpisode.cs @@ -15,6 +15,7 @@ namespace NzbDrone.Core.Parser.Model { Episodes = new List(); Languages = new List(); + CustomFormats = new List(); } public string Path { get; set; }