2020-04-25 13:29:59 +00:00
|
|
|
|
using System.Collections.Generic;
|
2020-04-21 10:11:55 +00:00
|
|
|
|
using Emby.Naming.Common;
|
|
|
|
|
using Emby.Naming.Video;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
2019-12-06 19:40:06 +00:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Jellyfin.Naming.Tests.Video
|
|
|
|
|
{
|
2020-04-25 16:55:54 +00:00
|
|
|
|
public class VideoResolverTests
|
2019-12-06 19:40:06 +00:00
|
|
|
|
{
|
2020-04-21 10:11:55 +00:00
|
|
|
|
private readonly NamingOptions _namingOptions = new NamingOptions();
|
|
|
|
|
|
2020-04-25 13:29:59 +00:00
|
|
|
|
public static IEnumerable<object[]> GetResolveFileTestData()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
yield return new object[]
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/7 Psychos.mkv/7 Psychos.mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "7 Psychos"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "3 days to kill",
|
|
|
|
|
Year = 2005
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/American Psycho/American.Psycho.mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "American.Psycho",
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "brave",
|
|
|
|
|
Year = 2006,
|
|
|
|
|
Is3D = true,
|
|
|
|
|
Format3D = "sbs",
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "300",
|
|
|
|
|
Year = 2006
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "300",
|
|
|
|
|
Year = 2006,
|
|
|
|
|
Is3D = true,
|
|
|
|
|
Format3D = "sbs",
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc",
|
|
|
|
|
Container = "disc",
|
|
|
|
|
Name = "brave",
|
|
|
|
|
Year = 2006,
|
|
|
|
|
IsStub = true,
|
|
|
|
|
StubType = "bluray",
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc",
|
|
|
|
|
Container = "disc",
|
|
|
|
|
Name = "300",
|
|
|
|
|
Year = 2006,
|
|
|
|
|
IsStub = true,
|
|
|
|
|
StubType = "bluray",
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/Brave (2007)/Brave (2006).bluray.disc",
|
|
|
|
|
Container = "disc",
|
|
|
|
|
Name = "Brave",
|
|
|
|
|
Year = 2006,
|
|
|
|
|
IsStub = true,
|
|
|
|
|
StubType = "bluray",
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006).bluray.disc",
|
|
|
|
|
Container = "disc",
|
|
|
|
|
Name = "300",
|
|
|
|
|
Year = 2006,
|
|
|
|
|
IsStub = true,
|
|
|
|
|
StubType = "bluray",
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006)-trailer.mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "300",
|
|
|
|
|
Year = 2006,
|
|
|
|
|
ExtraType = ExtraType.Trailer,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "Brave",
|
|
|
|
|
Year = 2006,
|
|
|
|
|
ExtraType = ExtraType.Trailer,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/300 (2007)/300 (2006).mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "300",
|
|
|
|
|
Year = 2006
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "Bad Boys",
|
|
|
|
|
Year = 1995,
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
yield return new object[]
|
|
|
|
|
{
|
|
|
|
|
new VideoFileInfo()
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
2020-04-25 13:29:59 +00:00
|
|
|
|
Path = @"/server/Movies/Brave (2007)/Brave (2006).mkv",
|
|
|
|
|
Container = "mkv",
|
|
|
|
|
Name = "Brave",
|
|
|
|
|
Year = 2006,
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-04-21 10:11:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
2020-04-25 13:29:59 +00:00
|
|
|
|
[MemberData(nameof(GetResolveFileTestData))]
|
2020-04-21 10:54:04 +00:00
|
|
|
|
public void ResolveFile_ValidFileName_Success(VideoFileInfo expectedResult)
|
2020-04-21 10:11:55 +00:00
|
|
|
|
{
|
|
|
|
|
var result = new VideoResolver(_namingOptions).ResolveFile(expectedResult.Path);
|
|
|
|
|
|
2020-04-21 10:54:04 +00:00
|
|
|
|
Assert.NotNull(result);
|
2020-05-13 22:59:19 +00:00
|
|
|
|
Assert.Equal(result?.Path, expectedResult.Path);
|
|
|
|
|
Assert.Equal(result?.Container, expectedResult.Container);
|
|
|
|
|
Assert.Equal(result?.Name, expectedResult.Name);
|
|
|
|
|
Assert.Equal(result?.Year, expectedResult.Year);
|
|
|
|
|
Assert.Equal(result?.ExtraType, expectedResult.ExtraType);
|
|
|
|
|
Assert.Equal(result?.Format3D, expectedResult.Format3D);
|
|
|
|
|
Assert.Equal(result?.Is3D, expectedResult.Is3D);
|
|
|
|
|
Assert.Equal(result?.IsStub, expectedResult.IsStub);
|
|
|
|
|
Assert.Equal(result?.StubType, expectedResult.StubType);
|
|
|
|
|
Assert.Equal(result?.IsDirectory, expectedResult.IsDirectory);
|
|
|
|
|
Assert.Equal(result?.FileNameWithoutExtension, expectedResult.FileNameWithoutExtension);
|
2019-12-06 19:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|