From 078898af917976c316848ce9f9aa839c5c86e061 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 16 Aug 2020 23:43:21 -0400 Subject: [PATCH] Fixed: Format Errors from AudioChannel formatter --- .../FormatAudioChannelsFixture.cs | 18 ++++++++++++++++++ .../MediaFiles/MediaInfo/MediaInfoFormatter.cs | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioChannelsFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioChannelsFixture.cs index 93388a96b..d3f39519b 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioChannelsFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioChannelsFixture.cs @@ -1,3 +1,5 @@ +using System.Globalization; +using System.Threading; using FluentAssertions; using NUnit.Framework; using NzbDrone.Core.MediaFiles.MediaInfo; @@ -126,6 +128,22 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(7.1m); } + [Test] + public void should_ignore_culture_on_channel_summary() + { + Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); + + var mediaInfoModel = new MediaInfoModel + { + AudioChannelsContainer = 2, + AudioChannelPositions = "3/2/0.1", + AudioChannelPositionsTextContainer = null, + SchemaRevision = 3 + }; + + MediaInfoFormatter.FormatAudioChannels(mediaInfoModel).Should().Be(5.1m); + } + [Test] public void should_handle_AudioChannelPositions_three_digits() { diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs index 4469e51cc..14027c573 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs @@ -480,11 +480,11 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo if (channelSplit.Count() == 3) { - positions += decimal.Parse(string.Format("{0}.{1}", channelSplit[1], channelSplit[2])); + positions += decimal.Parse(string.Format("{0}.{1}", channelSplit[1], channelSplit[2]), CultureInfo.InvariantCulture); } else { - positions += decimal.Parse(channel); + positions += decimal.Parse(channel, CultureInfo.InvariantCulture); } }