New: Add custom format info to episode import notifications

This commit is contained in:
Mark McDowall 2022-12-12 23:38:02 -08:00 committed by Mark McDowall
parent 899d6ddbab
commit 68d026479f
10 changed files with 53 additions and 5 deletions

View File

@ -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())
{

View File

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

View File

@ -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())
{

View File

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

View File

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

View File

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

View File

@ -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<WebhookCustomFormat> CustomFormats { get; set; }
public int CustomFormatScore { get; set; }
public WebhookCustomFormatInfo(List<CustomFormat> customFormats, int customFormatScore)
{
CustomFormats = customFormats.Select(c => new WebhookCustomFormat(c)).ToList();
CustomFormatScore = customFormatScore;
}
}
}

View File

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

View File

@ -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<WebhookEpisodeFile> DeletedFiles { get; set; }
public WebhookCustomFormatInfo CustomFormatInfo { get; set; }
}
}

View File

@ -15,6 +15,7 @@ namespace NzbDrone.Core.Parser.Model
{
Episodes = new List<Episode>();
Languages = new List<Language>();
CustomFormats = new List<CustomFormat>();
}
public string Path { get; set; }