diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioChannelsFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioChannelsFixture.cs index d3f39519b..3cd71c247 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioChannelsFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioChannelsFixture.cs @@ -64,6 +64,21 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(2); } + [Test] + public void should_use_AudioChannels_if_schema_revision_is_3_and_AudioChannelPositions_is_0() + { + var mediaInfoModel = new MediaInfoModel + { + AudioFormat = "FLAC", + AudioChannelsContainer = 6, + AudioChannelPositions = "0/0/0", + AudioChannelPositionsTextContainer = null, + SchemaRevision = 3 + }; + + MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m); + } + [Test] public void should_sum_AudioChannelPositions() { @@ -128,6 +143,21 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(7.1m); } + [Test] + public void should_format_6_channel_zero_as_51_if_flac() + { + var mediaInfoModel = new MediaInfoModel + { + AudioFormat = "FLAC", + AudioChannelsContainer = 6, + AudioChannelPositions = "0/0/0", + AudioChannelPositionsTextContainer = null, + SchemaRevision = 3 + }; + + MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m); + } + [Test] public void should_ignore_culture_on_channel_summary() { diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs index 58f1ef0ef..4de9cd393 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs @@ -21,12 +21,12 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo { var audioChannels = FormatAudioChannelsFromAudioChannelPositions(mediaInfo); - if (audioChannels == null) + if (audioChannels == null || audioChannels == 0.0m) { audioChannels = FormatAudioChannelsFromAudioChannelPositionsText(mediaInfo); } - if (audioChannels == null) + if (audioChannels == null || audioChannels == 0.0m) { audioChannels = FormatAudioChannelsFromAudioChannels(mediaInfo); } @@ -565,6 +565,12 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo return audioChannelsContainer - 1 + 0.1m; } + // FLAC 6 channels is likely 5.1 + if (audioFormat.ContainsIgnoreCase("FLAC") && audioChannelsContainer == 6) + { + return 5.1m; + } + if (mediaInfo.SchemaRevision > 5) { return audioChannelsStream > 0 ? audioChannelsStream : audioChannelsContainer;