From 8b706cebef8bbb82e3bc91ee7527fb4be15ee505 Mon Sep 17 00:00:00 2001 From: Joe Rogers <1337joe@gmail.com> Date: Sun, 16 Jan 2022 23:00:30 +0100 Subject: [PATCH] Add alternate resolver test, generate extra folder names --- Emby.Naming/Common/NamingOptions.cs | 27 +++++---------- .../Library/MovieResolverTests.cs | 34 +++++++++++++++++++ 2 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 tests/Jellyfin.Server.Implementations.Tests/Library/MovieResolverTests.cs diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs index e8c855b5a9..eb211050f1 100644 --- a/Emby.Naming/Common/NamingOptions.cs +++ b/Emby.Naming/Common/NamingOptions.cs @@ -591,6 +591,10 @@ namespace Emby.Naming.Common MediaType.Video) }; + AllExtrasTypesFolderNames = VideoExtraRules + .Where(i => i.RuleType == ExtraRuleType.DirectoryName) + .ToDictionary(i => i.Token, i => i.ExtraType, StringComparer.OrdinalIgnoreCase); + Format3DRules = new[] { // Kodi rules: @@ -679,6 +683,10 @@ namespace Emby.Naming.Common ".mxf" }); + VideoFileExtensions = extensions + .Distinct(StringComparer.OrdinalIgnoreCase) + .ToArray(); + MultipleEpisodeExpressions = new[] { @".*(\\|\/)[sS]?(?[0-9]{1,4})[xX](?[0-9]{1,3})((-| - )[0-9]{1,4}[eExX](?[0-9]{1,3}))+[^\\\/]*$", @@ -696,25 +704,6 @@ namespace Emby.Naming.Common IsNamed = true }).ToArray(); - VideoFileExtensions = extensions - .Distinct(StringComparer.OrdinalIgnoreCase) - .ToArray(); - - AllExtrasTypesFolderNames = new Dictionary(StringComparer.OrdinalIgnoreCase) - { - ["trailers"] = ExtraType.Trailer, - ["theme-music"] = ExtraType.ThemeSong, - ["backdrops"] = ExtraType.ThemeVideo, - ["extras"] = ExtraType.Unknown, - ["behind the scenes"] = ExtraType.BehindTheScenes, - ["deleted scenes"] = ExtraType.DeletedScene, - ["interviews"] = ExtraType.Interview, - ["scenes"] = ExtraType.Scene, - ["samples"] = ExtraType.Sample, - ["shorts"] = ExtraType.Clip, - ["featurettes"] = ExtraType.Clip - }; - Compile(); } diff --git a/tests/Jellyfin.Server.Implementations.Tests/Library/MovieResolverTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Library/MovieResolverTests.cs new file mode 100644 index 0000000000..f2efcddbae --- /dev/null +++ b/tests/Jellyfin.Server.Implementations.Tests/Library/MovieResolverTests.cs @@ -0,0 +1,34 @@ +using Emby.Naming.Common; +using Emby.Server.Implementations.Library.Resolvers.Movies; +using MediaBrowser.Controller; +using MediaBrowser.Controller.Drawing; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.IO; +using Moq; +using Xunit; + +namespace Jellyfin.Server.Implementations.Tests.Library; + +public class MovieResolverTests +{ + private static readonly NamingOptions _namingOptions = new(); + + [Fact] + public void Resolve_GivenLocalAlternateVersion_ResolvesToVideo() + { + var movieResolver = new MovieResolver(Mock.Of(), _namingOptions); + var itemResolveArgs = new ItemResolveArgs( + Mock.Of(), + Mock.Of()) + { + Parent = null, + FileInfo = new FileSystemMetadata + { + FullName = "/movies/Black Panther (2018)/Black Panther (2018) - 1080p 3D.mk3d" + } + }; + + Assert.NotNull(movieResolver.Resolve(itemResolveArgs)); + } +}