Order rules so directory takes precedence over naming

pull/7186/head
Joe Rogers 3 years ago
parent d88e39b71d
commit f11fa59b15
No known key found for this signature in database
GPG Key ID: 0074AD57B8FDBBB4

@ -410,6 +410,66 @@ namespace Emby.Naming.Common
"trailers", "trailers",
MediaType.Video), 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( new ExtraRule(
ExtraType.Trailer, ExtraType.Trailer,
ExtraRuleType.Filename, ExtraRuleType.Filename,
@ -470,24 +530,12 @@ namespace Emby.Naming.Common
" sample", " sample",
MediaType.Video), MediaType.Video),
new ExtraRule(
ExtraType.ThemeVideo,
ExtraRuleType.DirectoryName,
"backdrops",
MediaType.Video),
new ExtraRule( new ExtraRule(
ExtraType.ThemeSong, ExtraType.ThemeSong,
ExtraRuleType.Filename, ExtraRuleType.Filename,
"theme", "theme",
MediaType.Audio), MediaType.Audio),
new ExtraRule(
ExtraType.ThemeSong,
ExtraRuleType.DirectoryName,
"theme-music",
MediaType.Audio),
new ExtraRule( new ExtraRule(
ExtraType.Scene, ExtraType.Scene,
ExtraRuleType.Suffix, ExtraRuleType.Suffix,
@ -534,54 +582,6 @@ namespace Emby.Naming.Common
ExtraType.Clip, ExtraType.Clip,
ExtraRuleType.Suffix, ExtraRuleType.Suffix,
"-short", "-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) MediaType.Video)
}; };

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

Loading…
Cancel
Save