Enable MultiVersion video tests and added support for naming based on tests 11 & 8

This commit is contained in:
Stepan 2020-11-05 14:51:27 +01:00
parent c96aa0551d
commit 5741150367
3 changed files with 47 additions and 40 deletions

View File

@ -133,7 +133,7 @@ namespace Emby.Naming.Common
CleanStrings = new[]
{
@"[ _\,\.\(\)\[\]\-](3d|sbs|tab|hsbs|htab|mvc|HDR|HDC|UHD|UltraHD|4k|ac3|dts|custom|dc|divx|divx5|dsr|dsrip|dutch|dvd|dvdrip|dvdscr|dvdscreener|screener|dvdivx|cam|fragment|fs|hdtv|hdrip|hdtvrip|internal|limited|multisubs|ntsc|ogg|ogm|pal|pdtv|proper|repack|rerip|retail|cd[1-9]|r3|r5|bd5|bd|se|svcd|swedish|german|read.nfo|nfofix|unrated|ws|telesync|ts|telecine|tc|brrip|bdrip|480p|480i|576p|576i|720p|720i|1080p|1080i|2160p|hrhd|hrhdtv|hddvd|bluray|x264|h264|xvid|xvidvd|xxx|www.www|\[.*\])([ _\,\.\(\)\[\]\-]|$)",
@"[ _\,\.\(\)\[\]\-](3d|sbs|tab|hsbs|htab|mvc|HDR|HDC|UHD|UltraHD|4k|ac3|dts|custom|dc|divx|divx5|dsr|dsrip|dutch|dvd|dvdrip|dvdscr|dvdscreener|screener|dvdivx|cam|fragment|fs|hdtv|hdrip|hdtvrip|internal|limited|multisubs|ntsc|ogg|ogm|pal|pdtv|proper|repack|rerip|retail|cd[1-9]|r3|r5|bd5|bd|se|svcd|swedish|german|read.nfo|nfofix|unrated|ws|telesync|ts|telecine|tc|brrip|bdrip|480p|480i|576p|576i|720p|720i|1080p|1080i|2160p|hrhd|hrhdtv|hddvd|bluray|blu-ray|x264|x265|h264|xvid|xvidvd|xxx|www.www|AAC|DTS|\[.*\])([ _\,\.\(\)\[\]\-]|$)",
@"(\[.*\])"
};

View File

@ -212,9 +212,15 @@ namespace Emby.Naming.Video
if (testFilename.StartsWith(folderName, StringComparison.OrdinalIgnoreCase))
{
if (CleanStringParser.TryClean(testFilename, _options.CleanStringRegexes, out var cleanName))
{
testFilename = cleanName.ToString();
}
testFilename = testFilename.Substring(folderName.Length).Trim();
return string.IsNullOrEmpty(testFilename)
|| testFilename[0] == '-'
|| testFilename[0] == '_'
|| string.IsNullOrWhiteSpace(Regex.Replace(testFilename, @"\[([^]]*)\]", string.Empty));
}

View File

@ -1,4 +1,5 @@
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using Emby.Naming.Common;
using Emby.Naming.Video;
using MediaBrowser.Model.IO;
@ -11,8 +12,8 @@ namespace Jellyfin.Naming.Tests.Video
private readonly NamingOptions _namingOptions = new NamingOptions();
// FIXME
// [Fact]
private void TestMultiEdition1()
[Fact]
public void TestMultiEdition1()
{
var files = new[]
{
@ -35,8 +36,8 @@ namespace Jellyfin.Naming.Tests.Video
}
// FIXME
// [Fact]
private void TestMultiEdition2()
[Fact]
public void TestMultiEdition2()
{
var files = new[]
{
@ -81,8 +82,8 @@ namespace Jellyfin.Naming.Tests.Video
}
// FIXME
// [Fact]
private void TestLetterFolders()
[Fact]
public void TestLetterFolders()
{
var files = new[]
{
@ -109,8 +110,8 @@ namespace Jellyfin.Naming.Tests.Video
}
// FIXME
// [Fact]
private void TestMultiVersionLimit()
[Fact]
public void TestMultiVersionLimit()
{
var files = new[]
{
@ -138,8 +139,8 @@ namespace Jellyfin.Naming.Tests.Video
}
// FIXME
// [Fact]
private void TestMultiVersionLimit2()
[Fact]
public void TestMultiVersionLimit2()
{
var files = new[]
{
@ -168,8 +169,8 @@ namespace Jellyfin.Naming.Tests.Video
}
// FIXME
// [Fact]
private void TestMultiVersion3()
[Fact]
public void TestMultiVersion3()
{
var files = new[]
{
@ -194,8 +195,8 @@ namespace Jellyfin.Naming.Tests.Video
}
// FIXME
// [Fact]
private void TestMultiVersion4()
[Fact]
public void TestMultiVersion4()
{
// Test for false positive
@ -221,9 +222,8 @@ namespace Jellyfin.Naming.Tests.Video
Assert.Empty(result[0].AlternateVersions);
}
// FIXME
// [Fact]
private void TestMultiVersion5()
[Fact]
public void TestMultiVersion5()
{
var files = new[]
{
@ -254,8 +254,8 @@ namespace Jellyfin.Naming.Tests.Video
}
// FIXME
// [Fact]
private void TestMultiVersion6()
[Fact]
public void TestMultiVersion6()
{
var files = new[]
{
@ -285,9 +285,8 @@ namespace Jellyfin.Naming.Tests.Video
Assert.True(result[0].AlternateVersions[5].Is3D);
}
// FIXME
// [Fact]
private void TestMultiVersion7()
[Fact]
public void TestMultiVersion7()
{
var files = new[]
{
@ -306,12 +305,9 @@ namespace Jellyfin.Naming.Tests.Video
Assert.Equal(2, result.Count);
}
// FIXME
// [Fact]
private void TestMultiVersion8()
[Fact]
public void TestMultiVersion8()
{
// This is not actually supported yet
var files = new[]
{
@"/movies/Iron Man/Iron Man.mkv",
@ -339,9 +335,8 @@ namespace Jellyfin.Naming.Tests.Video
Assert.True(result[0].AlternateVersions[4].Is3D);
}
// FIXME
// [Fact]
private void TestMultiVersion9()
[Fact]
public void TestMultiVersion9()
{
// Test for false positive
@ -367,9 +362,8 @@ namespace Jellyfin.Naming.Tests.Video
Assert.Empty(result[0].AlternateVersions);
}
// FIXME
// [Fact]
private void TestMultiVersion10()
[Fact]
public void TestMultiVersion10()
{
var files = new[]
{
@ -390,12 +384,9 @@ namespace Jellyfin.Naming.Tests.Video
Assert.Single(result[0].AlternateVersions);
}
// FIXME
// [Fact]
private void TestMultiVersion11()
[Fact]
public void TestMultiVersion11()
{
// Currently not supported but we should probably handle this.
var files = new[]
{
@"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) [1080p] Blu-ray.x264.DTS.mkv",
@ -415,6 +406,16 @@ namespace Jellyfin.Naming.Tests.Video
Assert.Single(result[0].AlternateVersions);
}
[Fact]
public void TestEmptyList()
{
var resolver = GetResolver();
var result = resolver.Resolve(new List<FileSystemMetadata>()).ToList();
Assert.Empty(result);
}
private VideoListResolver GetResolver()
{
return new VideoListResolver(_namingOptions);