From 5fcd65ef57c8bb542d35c8da572819a2ac97fa0a Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 16 Aug 2016 16:46:27 -0700 Subject: [PATCH] Fixed: MediaInfo.AudioChannels for some eac3 and mp3 files --- .../MediaFiles/MediaInfo/MediaInfoModel.cs | 13 ++++++++++++- .../MediaFiles/MediaInfo/UpdateMediaInfoService.cs | 2 +- .../MediaFiles/MediaInfo/VideoFileInfoReader.cs | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs index f4242ed13..0148fb03a 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs @@ -20,6 +20,7 @@ public class MediaInfoModel : IEmbeddedDocument public int AudioStreamCount { get; set; } public int AudioChannels { get; set; } public string AudioChannelPositions { get; set; } + public string AudioChannelPositionsText { get; set; } public string AudioProfile { get; set; } public decimal VideoFps { get; set; } public string AudioLanguages { get; set; } @@ -34,7 +35,17 @@ public decimal FormattedAudioChannels { if (AudioChannelPositions.IsNullOrWhiteSpace()) { - return 0; + if (AudioChannelPositionsText.IsNullOrWhiteSpace()) + { + if (SchemaRevision >= 3) + { + return AudioChannels; + } + + return 0; + } + + return AudioChannelPositionsText.ContainsIgnoreCase("LFE") ? AudioChannels - 1 + 0.1m : AudioChannels; } return AudioChannelPositions.Split('/').Sum(s => decimal.Parse(s, CultureInfo.InvariantCulture)); diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/UpdateMediaInfoService.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/UpdateMediaInfoService.cs index 8918835c4..fb232f2f9 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/UpdateMediaInfoService.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/UpdateMediaInfoService.cs @@ -18,7 +18,7 @@ public class UpdateMediaInfoService : IHandle private readonly IConfigService _configService; private readonly Logger _logger; - private const int CURRENT_MEDIA_INFO_SCHEMA_REVISION = 2; + private const int CURRENT_MEDIA_INFO_SCHEMA_REVISION = 3; public UpdateMediaInfoService(IDiskProvider diskProvider, IMediaFileService mediaFileService, diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs index bf46b58b2..65d849b6e 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/VideoFileInfoReader.cs @@ -30,7 +30,9 @@ public VideoFileInfoReader(IDiskProvider diskProvider, Logger logger) public MediaInfoModel GetMediaInfo(string filename) { if (!_diskProvider.FileExists(filename)) + { throw new FileNotFoundException("Media file does not exist: " + filename); + } MediaInfo mediaInfo = null; @@ -124,6 +126,7 @@ public MediaInfoModel GetMediaInfo(string filename) } var audioChannelPositions = mediaInfo.Get(StreamKind.Audio, 0, "ChannelPositions/String2"); + var audioChannelPositionsText = mediaInfo.Get(StreamKind.Audio, 0, "ChannelPositions"); string audioLanguages = mediaInfo.Get(StreamKind.General, 0, "Audio_Language_List"); string audioProfile = mediaInfo.Get(StreamKind.Audio, 0, "Format_Profile"); @@ -149,6 +152,7 @@ public MediaInfoModel GetMediaInfo(string filename) AudioStreamCount = streamCount, AudioChannels = audioChannels, AudioChannelPositions = audioChannelPositions, + AudioChannelPositionsText = audioChannelPositionsText, AudioProfile = audioProfile.Trim(), VideoFps = videoFrameRate, AudioLanguages = audioLanguages,