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:
parent
0083e95019
commit
0668f12e62
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user