From 01bc5f6fc85fba17323a74afddbfde438a9cee0e Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 15 Oct 2022 14:18:14 -0500 Subject: [PATCH] New: Include MediaInfo / CF for Webhooks Fixes #7680 (cherry picked from commit 47116ea6637c4bcb3365f6882bfd02ea74bf687e) --- .../Notifications/Webhook/WebhookMovieFile.cs | 2 + .../Webhook/WebhookMovieFileMediaInfo.cs | 38 +++++++++++++++++++ .../Notifications/Webhook/WebhookRelease.cs | 6 +++ 3 files changed, 46 insertions(+) create mode 100644 src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFileMediaInfo.cs diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFile.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFile.cs index 3d1476af3..54b93dc8d 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFile.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFile.cs @@ -21,6 +21,7 @@ namespace NzbDrone.Core.Notifications.Webhook IndexerFlags = movieFile.IndexerFlags.ToString(); Size = movieFile.Size; DateAdded = movieFile.DateAdded; + MediaInfo = new WebhookMovieFileMediaInfo(movieFile); } public int Id { get; set; } @@ -33,5 +34,6 @@ namespace NzbDrone.Core.Notifications.Webhook public string IndexerFlags { get; set; } public long Size { get; set; } public DateTime DateAdded { get; set; } + public WebhookMovieFileMediaInfo MediaInfo { get; set; } } } diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFileMediaInfo.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFileMediaInfo.cs new file mode 100644 index 000000000..55db74954 --- /dev/null +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookMovieFileMediaInfo.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.MediaFiles.MediaInfo; + +namespace NzbDrone.Core.Notifications.Webhook +{ + public class WebhookMovieFileMediaInfo + { + public WebhookMovieFileMediaInfo() + { + } + + public WebhookMovieFileMediaInfo(MovieFile movieFile) + { + AudioChannels = MediaInfoFormatter.FormatAudioChannels(movieFile.MediaInfo); + AudioCodec = MediaInfoFormatter.FormatAudioCodec(movieFile.MediaInfo, movieFile.SceneName); + AudioLanguages = movieFile.MediaInfo.AudioLanguages.Distinct().ToList(); + Height = movieFile.MediaInfo.Height; + Width = movieFile.MediaInfo.Width; + Subtitles = movieFile.MediaInfo.Subtitles.Distinct().ToList(); + VideoCodec = MediaInfoFormatter.FormatVideoCodec(movieFile.MediaInfo, movieFile.SceneName); + VideoDynamicRange = MediaInfoFormatter.FormatVideoDynamicRange(movieFile.MediaInfo); + VideoDynamicRangeType = MediaInfoFormatter.FormatVideoDynamicRangeType(movieFile.MediaInfo); + } + + public decimal AudioChannels { get; set; } + public string AudioCodec { get; set; } + public List AudioLanguages { get; set; } + public int Height { get; set; } + public int Width { get; set; } + public List Subtitles { get; set; } + public string VideoCodec { get; set; } + public string VideoDynamicRange { get; set; } + public string VideoDynamicRangeType { get; set; } + } +} diff --git a/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs b/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs index 2ba11f3cf..66dc3e75a 100755 --- a/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs +++ b/src/NzbDrone.Core/Notifications/Webhook/WebhookRelease.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using System.Linq; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; @@ -17,6 +19,8 @@ namespace NzbDrone.Core.Notifications.Webhook ReleaseTitle = remoteMovie.Release.Title; Indexer = remoteMovie.Release.Indexer; Size = remoteMovie.Release.Size; + CustomFormats = remoteMovie.CustomFormats?.Select(x => x.Name).ToList(); + CustomFormatScore = remoteMovie.CustomFormatScore; } public string Quality { get; set; } @@ -25,5 +29,7 @@ namespace NzbDrone.Core.Notifications.Webhook public string ReleaseTitle { get; set; } public string Indexer { get; set; } public long Size { get; set; } + public int CustomFormatScore { get; set; } + public List CustomFormats { get; set; } } }