Added additional codecs and more complete error message.

Taloth Saldono 7 years ago
parent c7d30ae703
commit 1cb25525ab

@ -8,6 +8,8 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests
[TestFixture] [TestFixture]
public class FormatAudioCodecFixture : TestBase public class FormatAudioCodecFixture : TestBase
{ {
private static string sceneName = "My.Series.S01E01-Sonarr";
[TestCase("AC-3", "AC3")] [TestCase("AC-3", "AC3")]
[TestCase("E-AC-3", "EAC3")] [TestCase("E-AC-3", "EAC3")]
[TestCase("MPEG Audio", "MPEG Audio")] [TestCase("MPEG Audio", "MPEG Audio")]
@ -19,7 +21,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests
AudioFormat = audioFormat AudioFormat = audioFormat
}; };
MediaInfoFormatter.FormatAudioCodec(mediaInfoModel).Should().Be(expectedFormat); MediaInfoFormatter.FormatAudioCodec(mediaInfoModel, sceneName).Should().Be(expectedFormat);
} }
[Test] [Test]
@ -31,7 +33,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests
AudioProfile = "Layer 3" AudioProfile = "Layer 3"
}; };
MediaInfoFormatter.FormatAudioCodec(mediaInfoModel).Should().Be("MP3"); MediaInfoFormatter.FormatAudioCodec(mediaInfoModel, sceneName).Should().Be("MP3");
} }
[Test] [Test]
@ -42,7 +44,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests
AudioFormat = "Other Audio Format" AudioFormat = "Other Audio Format"
}; };
MediaInfoFormatter.FormatAudioCodec(mediaInfoModel).Should().Be(mediaInfoModel.AudioFormat); MediaInfoFormatter.FormatAudioCodec(mediaInfoModel, sceneName).Should().Be(mediaInfoModel.AudioFormat);
ExceptionVerification.ExpectedErrors(1); ExceptionVerification.ExpectedErrors(1);
} }
} }

@ -265,7 +265,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc
var audio = new XElement("audio"); var audio = new XElement("audio");
audio.Add(new XElement("bitrate", episodeFile.MediaInfo.AudioBitrate)); audio.Add(new XElement("bitrate", episodeFile.MediaInfo.AudioBitrate));
audio.Add(new XElement("channels", episodeFile.MediaInfo.AudioChannels)); audio.Add(new XElement("channels", episodeFile.MediaInfo.AudioChannels));
audio.Add(new XElement("codec", MediaInfoFormatter.FormatAudioCodec(episodeFile.MediaInfo))); audio.Add(new XElement("codec", MediaInfoFormatter.FormatAudioCodec(episodeFile.MediaInfo, episodeFile.SceneName)));
audio.Add(new XElement("language", episodeFile.MediaInfo.AudioLanguages)); audio.Add(new XElement("language", episodeFile.MediaInfo.AudioLanguages));
streamDetails.Add(audio); streamDetails.Add(audio);

@ -40,7 +40,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
.Sum(s => decimal.Parse(s, CultureInfo.InvariantCulture)); .Sum(s => decimal.Parse(s, CultureInfo.InvariantCulture));
} }
public static string FormatAudioCodec(MediaInfoModel mediaInfo) public static string FormatAudioCodec(MediaInfoModel mediaInfo, string sceneName)
{ {
var audioFormat = mediaInfo.AudioFormat; var audioFormat = mediaInfo.AudioFormat;
@ -79,7 +79,12 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return "FLAC"; return "FLAC";
} }
Logger.Error("Unknown audio format: {0}", audioFormat); if (audioFormat.Equals("Vorbis", StringComparison.OrdinalIgnoreCase))
{
return "Vorbis";
}
Logger.Error(new Exception(), "Unknown audio format: {0} in {1}. Please notify Sonarr developers.", audioFormat, sceneName);
return audioFormat; return audioFormat;
} }
@ -111,12 +116,22 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo
return "MPEG2"; return "MPEG2";
} }
if (videoCodec.Equals("XviD", StringComparison.OrdinalIgnoreCase)) if (videoCodec.StartsWith("XviD", StringComparison.OrdinalIgnoreCase))
{ {
return "XviD"; return "XviD";
} }
Logger.Error("Unknown video codec: {0}", videoCodec); if (videoCodec.StartsWith("DivX", StringComparison.OrdinalIgnoreCase))
{
return "DivX";
}
if (videoCodec.Equals("VC-1", StringComparison.OrdinalIgnoreCase))
{
return "VC1";
}
Logger.Error(new Exception(), "Unknown video codec: {0} in {1}. Please notify Sonarr developers.", videoCodec, sceneName);
return videoCodec; return videoCodec;
} }
} }

@ -455,7 +455,7 @@ namespace NzbDrone.Core.Organizer
if (episodeFile.MediaInfo == null) return; if (episodeFile.MediaInfo == null) return;
var videoCodec = MediaInfoFormatter.FormatVideoCodec(episodeFile.MediaInfo, episodeFile.SceneName); var videoCodec = MediaInfoFormatter.FormatVideoCodec(episodeFile.MediaInfo, episodeFile.SceneName);
var audioCodec = MediaInfoFormatter.FormatAudioCodec(episodeFile.MediaInfo); var audioCodec = MediaInfoFormatter.FormatAudioCodec(episodeFile.MediaInfo, episodeFile.SceneName);
var audioChannels = MediaInfoFormatter.FormatAudioChannels(episodeFile.MediaInfo); var audioChannels = MediaInfoFormatter.FormatAudioChannels(episodeFile.MediaInfo);
var mediaInfoAudioLanguages = GetLanguagesToken(episodeFile.MediaInfo.AudioLanguages); var mediaInfoAudioLanguages = GetLanguagesToken(episodeFile.MediaInfo.AudioLanguages);

Loading…
Cancel
Save