|
|
@ -1,275 +1,200 @@
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using Emby.Naming.Common;
|
|
|
|
|
|
|
|
using Emby.Naming.Video;
|
|
|
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
using Xunit;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Jellyfin.Naming.Tests.Video
|
|
|
|
namespace Jellyfin.Naming.Tests.Video
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class VideoResolverTests : BaseVideoTest
|
|
|
|
public class VideoResolverTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// FIXME
|
|
|
|
private readonly NamingOptions _namingOptions = new NamingOptions();
|
|
|
|
// [Fact]
|
|
|
|
|
|
|
|
public void TestSimpleFile()
|
|
|
|
public static IEnumerable<object[]> GetResolveFileTestData()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var parser = GetParser();
|
|
|
|
yield return new object[]
|
|
|
|
|
|
|
|
{
|
|
|
|
var result =
|
|
|
|
new VideoFileInfo()
|
|
|
|
parser.ResolveFile(@"/server/Movies/Brave (2007)/Brave (2006).mkv");
|
|
|
|
{
|
|
|
|
|
|
|
|
Path = @"/server/Movies/7 Psychos.mkv/7 Psychos.mkv",
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
Container = "mkv",
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
Name = "7 Psychos"
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
}
|
|
|
|
Assert.Equal("Brave", result.Name);
|
|
|
|
};
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
yield return new object[]
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
new VideoFileInfo()
|
|
|
|
// FIXME
|
|
|
|
{
|
|
|
|
// [Fact]
|
|
|
|
Path = @"/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv",
|
|
|
|
public void TestSimpleFile2()
|
|
|
|
Container = "mkv",
|
|
|
|
{
|
|
|
|
Name = "3 days to kill",
|
|
|
|
var parser = GetParser();
|
|
|
|
Year = 2005
|
|
|
|
|
|
|
|
}
|
|
|
|
var result =
|
|
|
|
};
|
|
|
|
parser.ResolveFile(@"/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv");
|
|
|
|
yield return new object[]
|
|
|
|
|
|
|
|
{
|
|
|
|
Assert.Equal(1995, result.Year);
|
|
|
|
new VideoFileInfo()
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
{
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
Path = @"/server/Movies/American Psycho/American.Psycho.mkv",
|
|
|
|
Assert.Equal("Bad Boys", result.Name);
|
|
|
|
Container = "mkv",
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
Name = "American.Psycho",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
// FIXME
|
|
|
|
yield return new object[]
|
|
|
|
// [Fact]
|
|
|
|
{
|
|
|
|
public void TestSimpleFileWithNumericName()
|
|
|
|
new VideoFileInfo()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var parser = GetParser();
|
|
|
|
Path = @"/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv",
|
|
|
|
|
|
|
|
Container = "mkv",
|
|
|
|
var result =
|
|
|
|
Name = "brave",
|
|
|
|
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006).mkv");
|
|
|
|
Year = 2006,
|
|
|
|
|
|
|
|
Is3D = true,
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
Format3D = "sbs",
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
}
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
};
|
|
|
|
Assert.Equal("300", result.Name);
|
|
|
|
yield return new object[]
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
{
|
|
|
|
}
|
|
|
|
new VideoFileInfo()
|
|
|
|
|
|
|
|
{
|
|
|
|
// FIXME
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv",
|
|
|
|
// [Fact]
|
|
|
|
Container = "mkv",
|
|
|
|
public void TestExtra()
|
|
|
|
Name = "300",
|
|
|
|
{
|
|
|
|
Year = 2006
|
|
|
|
var parser = GetParser();
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
var result =
|
|
|
|
yield return new object[]
|
|
|
|
parser.ResolveFile(@"/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv");
|
|
|
|
{
|
|
|
|
|
|
|
|
new VideoFileInfo()
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
{
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv",
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
Container = "mkv",
|
|
|
|
Assert.Equal(ExtraType.Trailer, result.ExtraType);
|
|
|
|
Name = "300",
|
|
|
|
Assert.Equal("Brave (2006)-trailer", result.Name);
|
|
|
|
Year = 2006,
|
|
|
|
}
|
|
|
|
Is3D = true,
|
|
|
|
|
|
|
|
Format3D = "sbs",
|
|
|
|
// FIXME
|
|
|
|
}
|
|
|
|
// [Fact]
|
|
|
|
};
|
|
|
|
public void TestExtraWithNumericName()
|
|
|
|
yield return new object[]
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var parser = GetParser();
|
|
|
|
new VideoFileInfo()
|
|
|
|
|
|
|
|
{
|
|
|
|
var result =
|
|
|
|
Path = @"/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc",
|
|
|
|
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006)-trailer.mkv");
|
|
|
|
Container = "disc",
|
|
|
|
|
|
|
|
Name = "brave",
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
Year = 2006,
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
IsStub = true,
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
StubType = "bluray",
|
|
|
|
Assert.Equal("300 (2006)-trailer", result.Name);
|
|
|
|
}
|
|
|
|
Assert.Equal(ExtraType.Trailer, result.ExtraType);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
yield return new object[]
|
|
|
|
|
|
|
|
{
|
|
|
|
// FIXME
|
|
|
|
new VideoFileInfo()
|
|
|
|
// [Fact]
|
|
|
|
{
|
|
|
|
public void TestStubFileWithNumericName()
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc",
|
|
|
|
{
|
|
|
|
Container = "disc",
|
|
|
|
var parser = GetParser();
|
|
|
|
Name = "300",
|
|
|
|
|
|
|
|
Year = 2006,
|
|
|
|
var result =
|
|
|
|
IsStub = true,
|
|
|
|
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006).bluray.disc");
|
|
|
|
StubType = "bluray",
|
|
|
|
|
|
|
|
}
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
};
|
|
|
|
Assert.True(result.IsStub);
|
|
|
|
yield return new object[]
|
|
|
|
Assert.Equal("bluray", result.StubType);
|
|
|
|
{
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
new VideoFileInfo()
|
|
|
|
Assert.Equal("300", result.Name);
|
|
|
|
{
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
Path = @"/server/Movies/Brave (2007)/Brave (2006).bluray.disc",
|
|
|
|
}
|
|
|
|
Container = "disc",
|
|
|
|
|
|
|
|
Name = "Brave",
|
|
|
|
// FIXME
|
|
|
|
Year = 2006,
|
|
|
|
// [Fact]
|
|
|
|
IsStub = true,
|
|
|
|
public void TestStubFile()
|
|
|
|
StubType = "bluray",
|
|
|
|
{
|
|
|
|
}
|
|
|
|
var parser = GetParser();
|
|
|
|
};
|
|
|
|
|
|
|
|
yield return new object[]
|
|
|
|
var result =
|
|
|
|
{
|
|
|
|
parser.ResolveFile(@"/server/Movies/Brave (2007)/Brave (2006).bluray.disc");
|
|
|
|
new VideoFileInfo()
|
|
|
|
|
|
|
|
{
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006).bluray.disc",
|
|
|
|
Assert.True(result.IsStub);
|
|
|
|
Container = "disc",
|
|
|
|
Assert.Equal("bluray", result.StubType);
|
|
|
|
Name = "300",
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
Year = 2006,
|
|
|
|
Assert.Equal("Brave", result.Name);
|
|
|
|
IsStub = true,
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
StubType = "bluray",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
// FIXME
|
|
|
|
yield return new object[]
|
|
|
|
// [Fact]
|
|
|
|
{
|
|
|
|
public void TestExtraStubWithNumericNameNotSupported()
|
|
|
|
new VideoFileInfo()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var parser = GetParser();
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.mkv",
|
|
|
|
|
|
|
|
Container = "mkv",
|
|
|
|
var result =
|
|
|
|
Name = "300",
|
|
|
|
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc");
|
|
|
|
Year = 2006,
|
|
|
|
|
|
|
|
ExtraType = ExtraType.Trailer,
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
}
|
|
|
|
Assert.True(result.IsStub);
|
|
|
|
};
|
|
|
|
Assert.Equal("bluray", result.StubType);
|
|
|
|
yield return new object[]
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
{
|
|
|
|
Assert.Equal("300", result.Name);
|
|
|
|
new VideoFileInfo()
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
{
|
|
|
|
}
|
|
|
|
Path = @"/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv",
|
|
|
|
|
|
|
|
Container = "mkv",
|
|
|
|
// FIXME
|
|
|
|
Name = "Brave",
|
|
|
|
// [Fact]
|
|
|
|
Year = 2006,
|
|
|
|
public void TestExtraStubNotSupported()
|
|
|
|
ExtraType = ExtraType.Trailer,
|
|
|
|
{
|
|
|
|
}
|
|
|
|
// Using a stub for an extra is currently not supported
|
|
|
|
};
|
|
|
|
var parser = GetParser();
|
|
|
|
yield return new object[]
|
|
|
|
|
|
|
|
{
|
|
|
|
var result =
|
|
|
|
new VideoFileInfo()
|
|
|
|
parser.ResolveFile(@"/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc");
|
|
|
|
{
|
|
|
|
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006).mkv",
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
Container = "mkv",
|
|
|
|
Assert.True(result.IsStub);
|
|
|
|
Name = "300",
|
|
|
|
Assert.Equal("bluray", result.StubType);
|
|
|
|
Year = 2006
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
}
|
|
|
|
Assert.Equal("brave", result.Name);
|
|
|
|
};
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
yield return new object[]
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
new VideoFileInfo()
|
|
|
|
// FIXME
|
|
|
|
{
|
|
|
|
// [Fact]
|
|
|
|
Path = @"/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv",
|
|
|
|
public void Test3DFileWithNumericName()
|
|
|
|
Container = "mkv",
|
|
|
|
{
|
|
|
|
Name = "Bad Boys",
|
|
|
|
var parser = GetParser();
|
|
|
|
Year = 1995,
|
|
|
|
|
|
|
|
}
|
|
|
|
var result =
|
|
|
|
};
|
|
|
|
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv");
|
|
|
|
yield return new object[]
|
|
|
|
|
|
|
|
{
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
new VideoFileInfo()
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
{
|
|
|
|
Assert.True(result.Is3D);
|
|
|
|
Path = @"/server/Movies/Brave (2007)/Brave (2006).mkv",
|
|
|
|
Assert.Equal("sbs", result.Format3D);
|
|
|
|
Container = "mkv",
|
|
|
|
Assert.Equal("300", result.Name);
|
|
|
|
Name = "Brave",
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
Year = 2006,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
// FIXME
|
|
|
|
}
|
|
|
|
// [Fact]
|
|
|
|
|
|
|
|
public void TestBad3DFileWithNumericName()
|
|
|
|
|
|
|
|
{
|
|
|
|
[Theory]
|
|
|
|
var parser = GetParser();
|
|
|
|
[MemberData(nameof(GetResolveFileTestData))]
|
|
|
|
|
|
|
|
public void ResolveFile_ValidFileName_Success(VideoFileInfo expectedResult)
|
|
|
|
var result =
|
|
|
|
{
|
|
|
|
parser.ResolveFile(@"/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv");
|
|
|
|
var result = new VideoResolver(_namingOptions).ResolveFile(expectedResult.Path);
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
Assert.NotNull(result);
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
Assert.Equal(result.Path, expectedResult.Path);
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
Assert.Equal(result.Container, expectedResult.Container);
|
|
|
|
Assert.Equal("300", result.Name);
|
|
|
|
Assert.Equal(result.Name, expectedResult.Name);
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
Assert.Equal(result.Year, expectedResult.Year);
|
|
|
|
Assert.Null(result.Format3D);
|
|
|
|
Assert.Equal(result.ExtraType, expectedResult.ExtraType);
|
|
|
|
}
|
|
|
|
Assert.Equal(result.Format3D, expectedResult.Format3D);
|
|
|
|
|
|
|
|
Assert.Equal(result.Is3D, expectedResult.Is3D);
|
|
|
|
// FIXME
|
|
|
|
Assert.Equal(result.IsStub, expectedResult.IsStub);
|
|
|
|
// [Fact]
|
|
|
|
Assert.Equal(result.StubType, expectedResult.StubType);
|
|
|
|
public void Test3DFile()
|
|
|
|
Assert.Equal(result.IsDirectory, expectedResult.IsDirectory);
|
|
|
|
{
|
|
|
|
Assert.Equal(result.FileNameWithoutExtension, expectedResult.FileNameWithoutExtension);
|
|
|
|
var parser = GetParser();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result =
|
|
|
|
|
|
|
|
parser.ResolveFile(@"/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2006, result.Year);
|
|
|
|
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
|
|
|
|
Assert.True(result.Is3D);
|
|
|
|
|
|
|
|
Assert.Equal("sbs", result.Format3D);
|
|
|
|
|
|
|
|
Assert.Equal("brave", result.Name);
|
|
|
|
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void TestNameWithoutDate()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var parser = GetParser();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result =
|
|
|
|
|
|
|
|
parser.ResolveFile(@"/server/Movies/American Psycho/American.Psycho.mkv");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Null(result.Year);
|
|
|
|
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
|
|
|
|
Assert.Null(result.Format3D);
|
|
|
|
|
|
|
|
Assert.Equal("American.Psycho", result.Name);
|
|
|
|
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME
|
|
|
|
|
|
|
|
// [Fact]
|
|
|
|
|
|
|
|
public void TestCleanDateAndStringsSequence()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var parser = GetParser();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// In this test case, running CleanDateTime first produces no date, so it will attempt to run CleanString first and then CleanDateTime again
|
|
|
|
|
|
|
|
var result =
|
|
|
|
|
|
|
|
parser.ResolveFile(@"/server/Movies/3.Days.to.Kill/3.Days.to.Kill.2014.720p.BluRay.x264.YIFY.mkv");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2014, result.Year);
|
|
|
|
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
|
|
|
|
Assert.Null(result.Format3D);
|
|
|
|
|
|
|
|
Assert.Equal("3.Days.to.Kill", result.Name);
|
|
|
|
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME
|
|
|
|
|
|
|
|
// [Fact]
|
|
|
|
|
|
|
|
public void TestCleanDateAndStringsSequence1()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var parser = GetParser();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// In this test case, running CleanDateTime first produces no date, so it will attempt to run CleanString first and then CleanDateTime again
|
|
|
|
|
|
|
|
var result =
|
|
|
|
|
|
|
|
parser.ResolveFile(@"/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(2005, result.Year);
|
|
|
|
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
|
|
|
|
Assert.Null(result.Format3D);
|
|
|
|
|
|
|
|
Assert.Equal("3 days to kill", result.Name);
|
|
|
|
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
|
|
public void TestFolderNameWithExtension()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var parser = GetParser();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result =
|
|
|
|
|
|
|
|
parser.ResolveFile(@"/server/Movies/7 Psychos.mkv/7 Psychos.mkv");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.Null(result.Year);
|
|
|
|
|
|
|
|
Assert.False(result.IsStub);
|
|
|
|
|
|
|
|
Assert.False(result.Is3D);
|
|
|
|
|
|
|
|
Assert.Equal("7 Psychos", result.Name);
|
|
|
|
|
|
|
|
Assert.Null(result.ExtraType);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|