diff --git a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioCodecFixture.cs b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioCodecFixture.cs index fd4949c60..a4e72c538 100644 --- a/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioCodecFixture.cs +++ b/src/NzbDrone.Core.Test/MediaFiles/MediaInfo/MediaInfoFormatterTests/FormatAudioCodecFixture.cs @@ -8,6 +8,8 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests [TestFixture] public class FormatAudioCodecFixture : TestBase { + private static string sceneName = "My.Series.S01E01-Sonarr"; + [TestCase("AC-3", "AC3")] [TestCase("E-AC-3", "EAC3")] [TestCase("MPEG Audio", "MPEG Audio")] @@ -19,7 +21,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests AudioFormat = audioFormat }; - MediaInfoFormatter.FormatAudioCodec(mediaInfoModel).Should().Be(expectedFormat); + MediaInfoFormatter.FormatAudioCodec(mediaInfoModel, sceneName).Should().Be(expectedFormat); } [Test] @@ -31,7 +33,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests AudioProfile = "Layer 3" }; - MediaInfoFormatter.FormatAudioCodec(mediaInfoModel).Should().Be("MP3"); + MediaInfoFormatter.FormatAudioCodec(mediaInfoModel, sceneName).Should().Be("MP3"); } [Test] @@ -42,7 +44,7 @@ namespace NzbDrone.Core.Test.MediaFiles.MediaInfo.MediaInfoFormatterTests AudioFormat = "Other Audio Format" }; - MediaInfoFormatter.FormatAudioCodec(mediaInfoModel).Should().Be(mediaInfoModel.AudioFormat); + MediaInfoFormatter.FormatAudioCodec(mediaInfoModel, sceneName).Should().Be(mediaInfoModel.AudioFormat); ExceptionVerification.ExpectedErrors(1); } } diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs index afece96f2..61b703fa2 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs @@ -265,7 +265,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc var audio = new XElement("audio"); audio.Add(new XElement("bitrate", episodeFile.MediaInfo.AudioBitrate)); 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)); streamDetails.Add(audio); diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs index 76f2ac441..aab2d4a4d 100644 --- a/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs +++ b/src/NzbDrone.Core/MediaFiles/MediaInfo/MediaInfoFormatter.cs @@ -40,7 +40,7 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo .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; @@ -79,7 +79,12 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo 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; } @@ -111,12 +116,22 @@ namespace NzbDrone.Core.MediaFiles.MediaInfo return "MPEG2"; } - if (videoCodec.Equals("XviD", StringComparison.OrdinalIgnoreCase)) + if (videoCodec.StartsWith("XviD", StringComparison.OrdinalIgnoreCase)) { 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; } } diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index cd984d7b4..d84d79b2b 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -131,7 +131,7 @@ namespace NzbDrone.Core.Organizer AddEpisodeFileTokens(tokenHandlers, episodeFile); AddQualityTokens(tokenHandlers, series, episodeFile); AddMediaInfoTokens(tokenHandlers, episodeFile); - + var fileName = ReplaceTokens(pattern, tokenHandlers, namingConfig).Trim(); fileName = FileNameCleanupRegex.Replace(fileName, match => match.Captures[0].Value[0].ToString()); fileName = TrimSeparatorsRegex.Replace(fileName, string.Empty); @@ -455,7 +455,7 @@ namespace NzbDrone.Core.Organizer if (episodeFile.MediaInfo == null) return; 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 mediaInfoAudioLanguages = GetLanguagesToken(episodeFile.MediaInfo.AudioLanguages);