Fixed: FLAC audio channels in media info

phantom-rtorrent-seedcache
Taloth Saldono 4 years ago
parent 53f5694535
commit ab45910e56

@ -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()
{

@ -18,12 +18,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);
}
@ -550,6 +550,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;

Loading…
Cancel
Save