Added additional codecs and more complete error message.
This commit is contained in:
parent
c7d30ae703
commit
1cb25525ab
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue