diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/FormattedAudioChannelsFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/FormattedAudioChannelsFixture.cs
new file mode 100644
index 000000000..c344c0906
--- /dev/null
+++ b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/FormattedAudioChannelsFixture.cs
@@ -0,0 +1,120 @@
+using FluentAssertions;
+using NUnit.Framework;
+using NzbDrone.Core.MediaFiles.MediaInfo;
+
+namespace NzbDrone.Core.Test.MediaFiles.MediaInfo
+{
+ [TestFixture]
+ public class FormattedAudioChannelsFixture
+ {
+ [Test]
+ public void should_subtract_one_from_AudioChannels_as_total_channels_if_LFE_in_AudioChannelPositionsText()
+ {
+ var mediaInfoModel = new MediaInfoModel
+ {
+ AudioChannels = 6,
+ AudioChannelPositions = null,
+ AudioChannelPositionsText = "Front: L C R, Side: L R, LFE"
+ };
+
+ mediaInfoModel.FormattedAudioChannels.Should().Be(5.1m);
+ }
+
+ [Test]
+ public void should_use_AudioChannels_as_total_channels_if_LFE_not_in_AudioChannelPositionsText()
+ {
+ var mediaInfoModel = new MediaInfoModel
+ {
+ AudioChannels = 2,
+ AudioChannelPositions = null,
+ AudioChannelPositionsText = "Front: L R"
+ };
+
+ mediaInfoModel.FormattedAudioChannels.Should().Be(2);
+ }
+
+ [Test]
+ public void should_return_0_if_schema_revision_is_less_than_3_and_other_properties_are_null()
+ {
+ var mediaInfoModel = new MediaInfoModel
+ {
+ AudioChannels = 2,
+ AudioChannelPositions = null,
+ AudioChannelPositionsText = null,
+ SchemaRevision = 2
+ };
+
+ mediaInfoModel.FormattedAudioChannels.Should().Be(0);
+ }
+
+ [Test]
+ public void should_use_AudioChannels_if_schema_revision_is_3_and_other_properties_are_null()
+ {
+ var mediaInfoModel = new MediaInfoModel
+ {
+ AudioChannels = 2,
+ AudioChannelPositions = null,
+ AudioChannelPositionsText = null,
+ SchemaRevision = 3
+ };
+
+ mediaInfoModel.FormattedAudioChannels.Should().Be(2);
+ }
+
+ [Test]
+ public void should_sum_AudioChannelPositions()
+ {
+ var mediaInfoModel = new MediaInfoModel
+ {
+ AudioChannels = 2,
+ AudioChannelPositions = "2/0/0",
+ AudioChannelPositionsText = null,
+ SchemaRevision = 3
+ };
+
+ mediaInfoModel.FormattedAudioChannels.Should().Be(2);
+ }
+
+ [Test]
+ public void should_sum_AudioChannelPositions_including_decimal()
+ {
+ var mediaInfoModel = new MediaInfoModel
+ {
+ AudioChannels = 2,
+ AudioChannelPositions = "3/2/0.1",
+ AudioChannelPositionsText = null,
+ SchemaRevision = 3
+ };
+
+ mediaInfoModel.FormattedAudioChannels.Should().Be(5.1m);
+ }
+
+ [Test]
+ public void should_cleanup_extraneous_text_from_AudioChannelPositions()
+ {
+ var mediaInfoModel = new MediaInfoModel
+ {
+ AudioChannels = 2,
+ AudioChannelPositions = "Object Based / 3/2/2.1",
+ AudioChannelPositionsText = null,
+ SchemaRevision = 3
+ };
+
+ mediaInfoModel.FormattedAudioChannels.Should().Be(7.1m);
+ }
+
+ [Test]
+ public void should_sum_first_series_of_numbers_from_AudioChannelPositions()
+ {
+ var mediaInfoModel = new MediaInfoModel
+ {
+ AudioChannels = 2,
+ AudioChannelPositions = "3/2/2.1 / 3/2/2.1",
+ AudioChannelPositionsText = null,
+ SchemaRevision = 3
+ };
+
+ mediaInfoModel.FormattedAudioChannels.Should().Be(7.1m);
+ }
+ }
+}
diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 907bb7b08..72b2b278e 100644
--- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -285,6 +285,7 @@
+
diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs
index 0148fb03a..af02288e8 100644
--- a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs
+++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoModel.cs
@@ -48,7 +48,11 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return AudioChannelPositionsText.ContainsIgnoreCase("LFE") ? AudioChannels - 1 + 0.1m : AudioChannels;
}
- return AudioChannelPositions.Split('/').Sum(s => decimal.Parse(s, CultureInfo.InvariantCulture));
+ return AudioChannelPositions.Replace("Object Based / ", "")
+ .Split(new string[] { " / " }, StringSplitOptions.None)
+ .First()
+ .Split('/')
+ .Sum(s => decimal.Parse(s, CultureInfo.InvariantCulture));
}
}
}