From ecb0438b1696fb8c5a28d798fee13eda41d36498 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 21 Feb 2018 20:40:26 -0800 Subject: [PATCH] New: Add MediaInfo to Episode Files returned from the API --- .../EpisodeFiles/EpisodeFileResource.cs | 7 +++-- .../EpisodeFiles/MediaInfoResource.cs | 30 +++++++++++++++++++ src/NzbDrone.Api/NzbDrone.Api.csproj | 1 + 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/NzbDrone.Api/EpisodeFiles/MediaInfoResource.cs diff --git a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs b/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs index bd856776d..55e01c41f 100644 --- a/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs +++ b/src/NzbDrone.Api/EpisodeFiles/EpisodeFileResource.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using NzbDrone.Api.REST; using NzbDrone.Core.Qualities; @@ -15,6 +15,7 @@ namespace NzbDrone.Api.EpisodeFiles public DateTime DateAdded { get; set; } public string SceneName { get; set; } public QualityModel Quality { get; set; } + public MediaInfoResource MediaInfo { get; set; } public bool QualityCutoffNotMet { get; set; } } @@ -37,6 +38,7 @@ namespace NzbDrone.Api.EpisodeFiles DateAdded = model.DateAdded, SceneName = model.SceneName, Quality = model.Quality, + MediaInfo = model.MediaInfo.ToResource(model.SceneName) //QualityCutoffNotMet }; } @@ -57,7 +59,8 @@ namespace NzbDrone.Api.EpisodeFiles DateAdded = model.DateAdded, SceneName = model.SceneName, Quality = model.Quality, - QualityCutoffNotMet = qualityUpgradableSpecification.CutoffNotMet(series.Profile.Value, model.Quality) + QualityCutoffNotMet = qualityUpgradableSpecification.CutoffNotMet(series.Profile.Value, model.Quality), + MediaInfo = model.MediaInfo.ToResource(model.SceneName), }; } } diff --git a/src/NzbDrone.Api/EpisodeFiles/MediaInfoResource.cs b/src/NzbDrone.Api/EpisodeFiles/MediaInfoResource.cs new file mode 100644 index 000000000..672c48fcd --- /dev/null +++ b/src/NzbDrone.Api/EpisodeFiles/MediaInfoResource.cs @@ -0,0 +1,30 @@ +using NzbDrone.Api.REST; +using NzbDrone.Core.MediaFiles.MediaInfo; + +namespace NzbDrone.Api.EpisodeFiles +{ + public class MediaInfoResource : RestResource + { + public decimal AudioChannels { get; set; } + public string AudioCodec { get; set; } + public string VideoCodec { get; set; } + } + + public static class MediaInfoResourceMapper + { + public static MediaInfoResource ToResource(this MediaInfoModel model, string sceneName) + { + if (model == null) + { + return null; + } + + return new MediaInfoResource + { + AudioChannels = MediaInfoFormatter.FormatAudioChannels(model), + AudioCodec = MediaInfoFormatter.FormatAudioCodec(model, sceneName), + VideoCodec = MediaInfoFormatter.FormatVideoCodec(model, sceneName) + }; + } + } +} diff --git a/src/NzbDrone.Api/NzbDrone.Api.csproj b/src/NzbDrone.Api/NzbDrone.Api.csproj index e17ad64b8..3913b9601 100644 --- a/src/NzbDrone.Api/NzbDrone.Api.csproj +++ b/src/NzbDrone.Api/NzbDrone.Api.csproj @@ -104,6 +104,7 @@ +