1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

And a bunch of video codecs. Also fixed the dual-video channel issue.

This commit is contained in:
Taloth Saldono 2019-09-05 00:32:18 +02:00 committed by Qstick
parent 54cfabec5c
commit 9a25878104
2 changed files with 54 additions and 19 deletions

View File

@ -32,6 +32,8 @@ public void should_format_video_codec_with_source_title_legacy(string videoCodec
[TestCase("VC-1, V_MS/VFW/FOURCC / WVC1, Advanced@L3, ", "", "VC1")] [TestCase("VC-1, V_MS/VFW/FOURCC / WVC1, Advanced@L3, ", "", "VC1")]
[TestCase("VC-1, WMV3, MP@LL, ", "It's Always Sunny S07E13 The Gang's RevengeHDTV.XviD-2HD.avi", "VC1")] [TestCase("VC-1, WMV3, MP@LL, ", "It's Always Sunny S07E13 The Gang's RevengeHDTV.XviD-2HD.avi", "VC1")]
[TestCase("V.MPEG4/ISO/AVC, V.MPEG4/ISO/AVC, , ", "pd.2015.S03E08.720p.iP.WEBRip.AAC2.0.H264-BTW", "h264")] [TestCase("V.MPEG4/ISO/AVC, V.MPEG4/ISO/AVC, , ", "pd.2015.S03E08.720p.iP.WEBRip.AAC2.0.H264-BTW", "h264")]
[TestCase("AVC / AVC, V_MPEG4/ISO/AVC, High@L4, ", "Resistance.2019.S01E03.1080p.RTE.WEB-DL.AAC2.0.x264-RTN", "x264")]
[TestCase("WMV1, WMV1, , ", "Droned.wmv", "WMV")]
[TestCase("WMV2, WMV2, , ", "Droned.wmv", "WMV")] [TestCase("WMV2, WMV2, , ", "Droned.wmv", "WMV")]
[TestCase("xvid, xvid, , ", "", "XviD")] [TestCase("xvid, xvid, , ", "", "XviD")]
[TestCase("div3, div3, , ", "spsm.dvdrip.divx.avi'.", "DivX")] [TestCase("div3, div3, , ", "spsm.dvdrip.divx.avi'.", "DivX")]
@ -43,7 +45,12 @@ public void should_format_video_codec_with_source_title_legacy(string videoCodec
[TestCase("V_MPEGH/ISO/HEVC, V_MPEGH/ISO/HEVC, , ", "The BBT S11E12 The Matrimonial Metric 1080p 10bit AMZN WEB-DL", "h265")] [TestCase("V_MPEGH/ISO/HEVC, V_MPEGH/ISO/HEVC, , ", "The BBT S11E12 The Matrimonial Metric 1080p 10bit AMZN WEB-DL", "h265")]
[TestCase("MPEG-4 Visual, 20, Simple@L1, Lavc52.29.0", "Will.And.Grace.S08E14.WS.DVDrip.XviD.I.Love.L.Gay-Obfuscated", "XviD")] [TestCase("MPEG-4 Visual, 20, Simple@L1, Lavc52.29.0", "Will.And.Grace.S08E14.WS.DVDrip.XviD.I.Love.L.Gay-Obfuscated", "XviD")]
[TestCase("MPEG-4 Visual, 20, Advanced Simple@L5, XviD0046", "", "XviD")] [TestCase("MPEG-4 Visual, 20, Advanced Simple@L5, XviD0046", "", "XviD")]
[TestCase("MPEG-4 Visual, 20, , ", "", "")]
[TestCase("MPEG-4 Visual, mp4v-20, Simple@L1, Lavc57.48.101", "", "")]
[TestCase("mp4v, mp4v, , ", "American.Chopper.S06E07.Mountain.Creek.Bike.DSR.XviD-KRS", "XviD")] [TestCase("mp4v, mp4v, , ", "American.Chopper.S06E07.Mountain.Creek.Bike.DSR.XviD-KRS", "XviD")]
[TestCase("V_QUICKTIME, V_QUICKTIME, , ", "Custom", "")]
[TestCase("MPEG-4 Visual, FMP4, , ", "", "")]
[TestCase("MPEG-4 Visual, MP42, , ", "", "")]
[TestCase("mp43, V_MS/VFW/FOURCC / mp43, , ", "Bubble.Guppies.S01E13.480p.WEB-DL.H.264-BTN-Custom", "")] [TestCase("mp43, V_MS/VFW/FOURCC / mp43, , ", "Bubble.Guppies.S01E13.480p.WEB-DL.H.264-BTN-Custom", "")]
public void should_format_video_format(string videoFormatPack, string sceneName, string expectedFormat) public void should_format_video_format(string videoFormatPack, string sceneName, string expectedFormat)
{ {

View File

@ -239,24 +239,24 @@ public static string FormatVideoCodec(MediaInfoModel mediaInfo, string sceneName
return FormatVideoCodecLegacy(mediaInfo, sceneName); return FormatVideoCodecLegacy(mediaInfo, sceneName);
} }
var videoFormat = mediaInfo.VideoFormat; var videoFormat = mediaInfo.VideoFormat.Trim().Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries);
var videoCodecID = mediaInfo.VideoCodecID ?? string.Empty; var videoCodecID = mediaInfo.VideoCodecID ?? string.Empty;
var videoProfile = mediaInfo.VideoProfile ?? string.Empty; var videoProfile = mediaInfo.VideoProfile ?? string.Empty;
var videoCodecLibrary = mediaInfo.VideoCodecLibrary ?? string.Empty; var videoCodecLibrary = mediaInfo.VideoCodecLibrary ?? string.Empty;
var result = videoFormat; var result = mediaInfo.VideoFormat.Trim();
if (videoFormat.IsNullOrWhiteSpace()) if (videoFormat.Empty())
{ {
return result; return result;
} }
if (videoFormat == "x264") if (videoFormat.ContainsIgnoreCase("x264"))
{ {
return "x264"; return "x264";
} }
if (videoFormat == "AVC" || videoFormat == "V.MPEG4/ISO/AVC") if (videoFormat.ContainsIgnoreCase("AVC") || videoFormat.ContainsIgnoreCase("V.MPEG4/ISO/AVC"))
{ {
if (videoCodecLibrary.StartsWithIgnoreCase("x264")) if (videoCodecLibrary.StartsWithIgnoreCase("x264"))
{ {
@ -266,7 +266,7 @@ public static string FormatVideoCodec(MediaInfoModel mediaInfo, string sceneName
return GetSceneNameMatch(sceneName, "AVC", "x264", "h264"); return GetSceneNameMatch(sceneName, "AVC", "x264", "h264");
} }
if (videoFormat == "HEVC" || videoFormat == "V_MPEGH/ISO/HEVC") if (videoFormat.ContainsIgnoreCase("HEVC") || videoFormat.ContainsIgnoreCase("V_MPEGH/ISO/HEVC"))
{ {
if (videoCodecLibrary.StartsWithIgnoreCase("x265")) if (videoCodecLibrary.StartsWithIgnoreCase("x265"))
{ {
@ -276,7 +276,7 @@ public static string FormatVideoCodec(MediaInfoModel mediaInfo, string sceneName
return GetSceneNameMatch(sceneName, "HEVC", "x265", "h265"); return GetSceneNameMatch(sceneName, "HEVC", "x265", "h265");
} }
if (videoFormat == "MPEG Video") if (videoFormat.ContainsIgnoreCase("MPEG Video"))
{ {
if (videoCodecID == "2" || videoCodecID == "V_MPEG2") if (videoCodecID == "2" || videoCodecID == "V_MPEG2")
{ {
@ -289,12 +289,12 @@ public static string FormatVideoCodec(MediaInfoModel mediaInfo, string sceneName
} }
} }
if (videoFormat == "MPEG-2 Video") if (videoFormat.ContainsIgnoreCase("MPEG-2 Video"))
{ {
return "MPEG2"; return "MPEG2";
} }
if (videoFormat == "MPEG-4 Visual") if (videoFormat.ContainsIgnoreCase("MPEG-4 Visual"))
{ {
if (videoCodecID.ContainsIgnoreCase("XVID") || if (videoCodecID.ContainsIgnoreCase("XVID") ||
videoCodecLibrary.StartsWithIgnoreCase("XviD")) videoCodecLibrary.StartsWithIgnoreCase("XviD"))
@ -311,49 +311,77 @@ public static string FormatVideoCodec(MediaInfoModel mediaInfo, string sceneName
} }
} }
if (videoFormat == "MPEG-4 Visual" || videoFormat == "mp4v") if (videoFormat.ContainsIgnoreCase("MPEG-4 Visual") || videoFormat.ContainsIgnoreCase("mp4v"))
{ {
result = GetSceneNameMatch(sceneName, "XviD", "DivX", ""); result = GetSceneNameMatch(sceneName, "XviD", "DivX", "");
if (result.IsNotNullOrWhiteSpace()) if (result.IsNotNullOrWhiteSpace())
{ {
return result; return result;
} }
if (videoCodecLibrary.Contains("Lavc"))
{
return ""; // libavcodec mpeg-4
} }
if (videoFormat == "VC-1") if (videoCodecLibrary.Contains("em4v"))
{
return ""; // NeroDigital
}
if (videoCodecLibrary.Contains("Intel(R) IPP"))
{
return ""; // Intel(R) IPP
}
if (videoCodecLibrary == "")
{
return ""; // Unknown mp4v
}
}
if (videoFormat.ContainsIgnoreCase("VC-1"))
{ {
return "VC1"; return "VC1";
} }
if (videoFormat.EqualsIgnoreCase("VP6") || videoFormat.EqualsIgnoreCase("VP7") || if (videoFormat.ContainsIgnoreCase("VP6") || videoFormat.ContainsIgnoreCase("VP7") ||
videoFormat.EqualsIgnoreCase("VP8") || videoFormat.EqualsIgnoreCase("VP9")) videoFormat.ContainsIgnoreCase("VP8") || videoFormat.ContainsIgnoreCase("VP9"))
{ {
return videoFormat.ToUpperInvariant(); return videoFormat.First().ToUpperInvariant();
} }
if (videoFormat == "WMV2") if (videoFormat.ContainsIgnoreCase("WMV1") || videoFormat.ContainsIgnoreCase("WMV2"))
{ {
return "WMV"; return "WMV";
} }
if (videoFormat.EqualsIgnoreCase("DivX") || videoFormat.EqualsIgnoreCase("div3")) if (videoFormat.ContainsIgnoreCase("DivX") || videoFormat.ContainsIgnoreCase("div3"))
{ {
return "DivX"; return "DivX";
} }
if (videoFormat.EqualsIgnoreCase("XviD")) if (videoFormat.ContainsIgnoreCase("XviD"))
{ {
return "XviD"; return "XviD";
} }
if (videoFormat.EqualsIgnoreCase("mp43")) if (videoFormat.ContainsIgnoreCase("V_QUICKTIME") ||
videoFormat.ContainsIgnoreCase("RealVideo 4"))
{ {
return ""; return "";
} }
if (videoFormat.ContainsIgnoreCase("mp42") ||
videoFormat.ContainsIgnoreCase("mp43"))
{
// MS old DivX competitor
return "";
}
Logger.Debug() Logger.Debug()
.Message("Unknown video format: '{0}' in '{1}'.", string.Join(", ", videoFormat, videoCodecID, videoProfile, videoCodecLibrary), sceneName) .Message("Unknown video format: '{0}' in '{1}'.", string.Join(", ", videoFormat, videoCodecID, videoProfile, videoCodecLibrary), sceneName)
.WriteSentryWarn("UnknownVideoFormat", mediaInfo.ContainerFormat, videoFormat, videoCodecID) .WriteSentryWarn("UnknownVideoFormat", mediaInfo.ContainerFormat, mediaInfo.VideoFormat, videoCodecID)
.Write(); .Write();
return result; return result;