Fix issue #6123
This commit is contained in:
parent
d245e45254
commit
67147400bf
|
@ -478,6 +478,12 @@ namespace Emby.Naming.Common
|
|||
"-deleted",
|
||||
MediaType.Video),
|
||||
|
||||
new ExtraRule(
|
||||
ExtraType.DeletedScene,
|
||||
ExtraRuleType.Suffix,
|
||||
"-deletedscene",
|
||||
MediaType.Video),
|
||||
|
||||
new ExtraRule(
|
||||
ExtraType.Clip,
|
||||
ExtraRuleType.Suffix,
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace Emby.Naming.Video
|
|||
/// </summary>
|
||||
public class ExtraResolver
|
||||
{
|
||||
private static readonly char[] _digits = new[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
|
||||
private readonly NamingOptions _options;
|
||||
|
||||
/// <summary>
|
||||
|
@ -62,9 +63,10 @@ namespace Emby.Naming.Video
|
|||
}
|
||||
else if (rule.RuleType == ExtraRuleType.Suffix)
|
||||
{
|
||||
var filename = Path.GetFileNameWithoutExtension(pathSpan);
|
||||
// Trim the digits from the end of the filename so we can recognize things like -trailer2
|
||||
var filename = Path.GetFileNameWithoutExtension(pathSpan).TrimEnd(_digits);
|
||||
|
||||
if (filename.Contains(rule.Token, StringComparison.OrdinalIgnoreCase))
|
||||
if (filename.EndsWith(rule.Token, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
result.ExtraType = rule.ExtraType;
|
||||
result.Rule = rule;
|
||||
|
|
|
@ -18,30 +18,31 @@ namespace Jellyfin.Naming.Tests.Video
|
|||
[Fact]
|
||||
public void TestKodiExtras()
|
||||
{
|
||||
Test("trailer.mp4", ExtraType.Trailer, _videoOptions);
|
||||
Test("300-trailer.mp4", ExtraType.Trailer, _videoOptions);
|
||||
Test("trailer.mp4", ExtraType.Trailer);
|
||||
Test("300-trailer.mp4", ExtraType.Trailer);
|
||||
|
||||
Test("theme.mp3", ExtraType.ThemeSong, _videoOptions);
|
||||
Test("theme.mp3", ExtraType.ThemeSong);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestExpandedExtras()
|
||||
{
|
||||
Test("trailer.mp4", ExtraType.Trailer, _videoOptions);
|
||||
Test("trailer.mp3", null, _videoOptions);
|
||||
Test("300-trailer.mp4", ExtraType.Trailer, _videoOptions);
|
||||
Test("trailer.mp4", ExtraType.Trailer);
|
||||
Test("trailer.mp3", null);
|
||||
Test("300-trailer.mp4", ExtraType.Trailer);
|
||||
Test("stuff trailerthings.mkv", null);
|
||||
|
||||
Test("theme.mp3", ExtraType.ThemeSong, _videoOptions);
|
||||
Test("theme.mkv", null, _videoOptions);
|
||||
Test("theme.mp3", ExtraType.ThemeSong);
|
||||
Test("theme.mkv", null);
|
||||
|
||||
Test("300-scene.mp4", ExtraType.Scene, _videoOptions);
|
||||
Test("300-scene2.mp4", ExtraType.Scene, _videoOptions);
|
||||
Test("300-clip.mp4", ExtraType.Clip, _videoOptions);
|
||||
Test("300-scene.mp4", ExtraType.Scene);
|
||||
Test("300-scene2.mp4", ExtraType.Scene);
|
||||
Test("300-clip.mp4", ExtraType.Clip);
|
||||
|
||||
Test("300-deleted.mp4", ExtraType.DeletedScene, _videoOptions);
|
||||
Test("300-deletedscene.mp4", ExtraType.DeletedScene, _videoOptions);
|
||||
Test("300-interview.mp4", ExtraType.Interview, _videoOptions);
|
||||
Test("300-behindthescenes.mp4", ExtraType.BehindTheScenes, _videoOptions);
|
||||
Test("300-deleted.mp4", ExtraType.DeletedScene);
|
||||
Test("300-deletedscene.mp4", ExtraType.DeletedScene);
|
||||
Test("300-interview.mp4", ExtraType.Interview);
|
||||
Test("300-behindthescenes.mp4", ExtraType.BehindTheScenes);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
@ -55,9 +56,9 @@ namespace Jellyfin.Naming.Tests.Video
|
|||
[InlineData(ExtraType.Unknown, "extras")]
|
||||
public void TestDirectories(ExtraType type, string dirName)
|
||||
{
|
||||
Test(dirName + "/300.mp4", type, _videoOptions);
|
||||
Test("300/" + dirName + "/something.mkv", type, _videoOptions);
|
||||
Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", type, _videoOptions);
|
||||
Test(dirName + "/300.mp4", type);
|
||||
Test("300/" + dirName + "/something.mkv", type);
|
||||
Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", type);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
@ -66,32 +67,25 @@ namespace Jellyfin.Naming.Tests.Video
|
|||
[InlineData("The Big Short")]
|
||||
public void TestNonExtraDirectories(string dirName)
|
||||
{
|
||||
Test(dirName + "/300.mp4", null, _videoOptions);
|
||||
Test("300/" + dirName + "/something.mkv", null, _videoOptions);
|
||||
Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", null, _videoOptions);
|
||||
Test("/data/something/Movies/" + dirName + "/" + dirName + ".mp4", null, _videoOptions);
|
||||
Test(dirName + "/300.mp4", null);
|
||||
Test("300/" + dirName + "/something.mkv", null);
|
||||
Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", null);
|
||||
Test("/data/something/Movies/" + dirName + "/" + dirName + ".mp4", null);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSample()
|
||||
{
|
||||
Test("300-sample.mp4", ExtraType.Sample, _videoOptions);
|
||||
Test("300-sample.mp4", ExtraType.Sample);
|
||||
}
|
||||
|
||||
private void Test(string input, ExtraType? expectedType, NamingOptions videoOptions)
|
||||
private void Test(string input, ExtraType? expectedType)
|
||||
{
|
||||
var parser = GetExtraTypeParser(videoOptions);
|
||||
var parser = GetExtraTypeParser(_videoOptions);
|
||||
|
||||
var extraType = parser.GetExtraInfo(input).ExtraType;
|
||||
|
||||
if (expectedType == null)
|
||||
{
|
||||
Assert.Null(extraType);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal(expectedType, extraType);
|
||||
}
|
||||
Assert.Equal(expectedType, extraType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
Loading…
Reference in New Issue
Block a user