Order rules so directory takes precedence over naming

This commit is contained in:
Joe Rogers 2022-01-15 15:16:11 +01:00
parent d88e39b71d
commit f11fa59b15
No known key found for this signature in database
GPG Key ID: 0074AD57B8FDBBB4
2 changed files with 86 additions and 68 deletions

View File

@ -410,6 +410,66 @@ namespace Emby.Naming.Common
"trailers",
MediaType.Video),
new ExtraRule(
ExtraType.ThemeVideo,
ExtraRuleType.DirectoryName,
"backdrops",
MediaType.Video),
new ExtraRule(
ExtraType.ThemeSong,
ExtraRuleType.DirectoryName,
"theme-music",
MediaType.Audio),
new ExtraRule(
ExtraType.BehindTheScenes,
ExtraRuleType.DirectoryName,
"behind the scenes",
MediaType.Video),
new ExtraRule(
ExtraType.DeletedScene,
ExtraRuleType.DirectoryName,
"deleted scenes",
MediaType.Video),
new ExtraRule(
ExtraType.Interview,
ExtraRuleType.DirectoryName,
"interviews",
MediaType.Video),
new ExtraRule(
ExtraType.Scene,
ExtraRuleType.DirectoryName,
"scenes",
MediaType.Video),
new ExtraRule(
ExtraType.Sample,
ExtraRuleType.DirectoryName,
"samples",
MediaType.Video),
new ExtraRule(
ExtraType.Clip,
ExtraRuleType.DirectoryName,
"shorts",
MediaType.Video),
new ExtraRule(
ExtraType.Clip,
ExtraRuleType.DirectoryName,
"featurettes",
MediaType.Video),
new ExtraRule(
ExtraType.Unknown,
ExtraRuleType.DirectoryName,
"extras",
MediaType.Video),
new ExtraRule(
ExtraType.Trailer,
ExtraRuleType.Filename,
@ -470,24 +530,12 @@ namespace Emby.Naming.Common
" sample",
MediaType.Video),
new ExtraRule(
ExtraType.ThemeVideo,
ExtraRuleType.DirectoryName,
"backdrops",
MediaType.Video),
new ExtraRule(
ExtraType.ThemeSong,
ExtraRuleType.Filename,
"theme",
MediaType.Audio),
new ExtraRule(
ExtraType.ThemeSong,
ExtraRuleType.DirectoryName,
"theme-music",
MediaType.Audio),
new ExtraRule(
ExtraType.Scene,
ExtraRuleType.Suffix,
@ -534,54 +582,6 @@ namespace Emby.Naming.Common
ExtraType.Clip,
ExtraRuleType.Suffix,
"-short",
MediaType.Video),
new ExtraRule(
ExtraType.BehindTheScenes,
ExtraRuleType.DirectoryName,
"behind the scenes",
MediaType.Video),
new ExtraRule(
ExtraType.DeletedScene,
ExtraRuleType.DirectoryName,
"deleted scenes",
MediaType.Video),
new ExtraRule(
ExtraType.Interview,
ExtraRuleType.DirectoryName,
"interviews",
MediaType.Video),
new ExtraRule(
ExtraType.Scene,
ExtraRuleType.DirectoryName,
"scenes",
MediaType.Video),
new ExtraRule(
ExtraType.Sample,
ExtraRuleType.DirectoryName,
"samples",
MediaType.Video),
new ExtraRule(
ExtraType.Clip,
ExtraRuleType.DirectoryName,
"shorts",
MediaType.Video),
new ExtraRule(
ExtraType.Clip,
ExtraRuleType.DirectoryName,
"featurettes",
MediaType.Video),
new ExtraRule(
ExtraType.Unknown,
ExtraRuleType.DirectoryName,
"extras",
MediaType.Video)
};

View File

@ -92,7 +92,8 @@ public class FindExtrasTests
"/movies/Up/behind the scenes",
"/movies/Up/behind the scenes.mkv",
"/movies/Up/Up - sample.mkv",
"/movies/Up/Up something else.mkv"
"/movies/Up/Up something else.mkv",
"/movies/Up/extras"
};
_fileSystemMock.Setup(f => f.GetFiles(
@ -140,6 +141,21 @@ public class FindExtrasTests
}
}).Verifiable();
_fileSystemMock.Setup(f => f.GetFiles(
"/movies/Up/extras",
It.IsAny<string[]>(),
false,
false))
.Returns(new List<FileSystemMetadata>
{
new()
{
FullName = "/movies/Up/extras/Honest Trailer.mkv",
Name = "Honest Trailer.mkv",
IsDirectory = false
}
}).Verifiable();
var files = paths.Select(p => new FileSystemMetadata
{
FullName = p,
@ -150,17 +166,19 @@ public class FindExtrasTests
var extras = _libraryManager.FindExtras(owner, files, new DirectoryService(_fileSystemMock.Object)).OrderBy(e => e.ExtraType).ToList();
_fileSystemMock.Verify();
Assert.Equal(6, extras.Count);
Assert.Equal(ExtraType.Trailer, extras[0].ExtraType);
Assert.Equal(typeof(Trailer), extras[0].GetType());
Assert.Equal(7, extras.Count);
Assert.Equal(ExtraType.Unknown, extras[0].ExtraType);
Assert.Equal(typeof(Video), extras[0].GetType());
Assert.Equal(ExtraType.Trailer, extras[1].ExtraType);
Assert.Equal(typeof(Trailer), extras[1].GetType());
Assert.Equal(ExtraType.BehindTheScenes, extras[2].ExtraType);
Assert.Equal(ExtraType.Sample, extras[3].ExtraType);
Assert.Equal(ExtraType.ThemeSong, extras[4].ExtraType);
Assert.Equal(typeof(Audio), extras[4].GetType());
Assert.Equal(ExtraType.Trailer, extras[2].ExtraType);
Assert.Equal(typeof(Trailer), extras[2].GetType());
Assert.Equal(ExtraType.BehindTheScenes, extras[3].ExtraType);
Assert.Equal(ExtraType.Sample, extras[4].ExtraType);
Assert.Equal(ExtraType.ThemeSong, extras[5].ExtraType);
Assert.Equal(typeof(Audio), extras[5].GetType());
Assert.Equal(ExtraType.ThemeSong, extras[6].ExtraType);
Assert.Equal(typeof(Audio), extras[6].GetType());
}
[Fact]