1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fix error with weirdly formatted audioChannelPositions on MediaInfo.

This commit is contained in:
Leonardo Galli 2017-03-07 10:33:59 +01:00
parent 0083e95019
commit 0668f12e62
2 changed files with 42 additions and 18 deletions

View File

@ -100,5 +100,23 @@ public void should_dispose_file_after_scanning_mediainfo()
stream.Close();
}
[Test]
[TestCase("/ Front: L R", 2.0)]
public void should_correctly_read_audio_channels(string ChannelPositions, decimal formattedChannels)
{
var info = new MediaInfoModel()
{
VideoCodec = "AVC",
AudioFormat = "DTS",
AudioLanguages = "English",
Subtitles = "English",
AudioChannels = 2,
AudioChannelPositions = ChannelPositions,
SchemaRevision = 3,
};
info.FormattedAudioChannels.Should().Be(formattedChannels);
}
}
}

View File

@ -34,27 +34,33 @@ public decimal FormattedAudioChannels
{
get
{
if (AudioChannelPositions.IsNullOrWhiteSpace())
{
if (AudioChannelPositionsText.IsNullOrWhiteSpace())
{
if (SchemaRevision >= 3)
{
return AudioChannels;
}
try
{
return
AudioChannelPositions.Replace("Object Based /", "").Replace(" / ", "$")
.Split('$')
.First()
.Split('/')
.Sum(s => decimal.Parse(s, CultureInfo.InvariantCulture));
}
catch
{
return 0;
}
if (AudioChannelPositionsText.IsNullOrWhiteSpace())
{
if (SchemaRevision >= 3)
{
return AudioChannels;
}
return AudioChannelPositionsText.ContainsIgnoreCase("LFE") ? AudioChannels - 1 + 0.1m : AudioChannels;
}
return 0;
}
return AudioChannelPositionsText.ContainsIgnoreCase("LFE") ? AudioChannels - 1 + 0.1m : AudioChannels;
}
return
AudioChannelPositions.Replace("Object Based /", "").Replace(" / ", "$")
.Split('$')
.First()
.Split('/')
.Sum(s => decimal.Parse(s, CultureInfo.InvariantCulture));
}
}
}