From 2e1ec2858a5bd2a03d8dd5fd0ae9f9c11487ed7f Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Wed, 1 Apr 2020 18:53:19 +0200 Subject: Match using directory names in ExtraResolver --- Emby.Naming/Video/ExtraResolver.cs | 9 +++++++++ Emby.Naming/Video/ExtraRuleType.cs | 13 +++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'Emby.Naming/Video') diff --git a/Emby.Naming/Video/ExtraResolver.cs b/Emby.Naming/Video/ExtraResolver.cs index 42a5c88b3..fc0424faa 100644 --- a/Emby.Naming/Video/ExtraResolver.cs +++ b/Emby.Naming/Video/ExtraResolver.cs @@ -80,6 +80,15 @@ namespace Emby.Naming.Video result.Rule = rule; } } + else if (rule.RuleType == ExtraRuleType.DirectoryName) + { + var directoryName = Path.GetFileName(Path.GetDirectoryName(path)); + if (string.Equals(directoryName, rule.Token, StringComparison.OrdinalIgnoreCase)) + { + result.ExtraType = rule.ExtraType; + result.Rule = rule; + } + } return result; } diff --git a/Emby.Naming/Video/ExtraRuleType.cs b/Emby.Naming/Video/ExtraRuleType.cs index b021a04a3..0a304874d 100644 --- a/Emby.Naming/Video/ExtraRuleType.cs +++ b/Emby.Naming/Video/ExtraRuleType.cs @@ -5,18 +5,23 @@ namespace Emby.Naming.Video public enum ExtraRuleType { /// - /// The suffix + /// Match against a suffix in the file name. /// Suffix = 0, /// - /// The filename + /// Match against the file name. /// Filename = 1, /// - /// The regex + /// Match against the a regex. /// - Regex = 2 + Regex = 2, + + /// + /// Match against the directory name of the file. + /// + DirectoryName = 3, } } -- cgit v1.2.3 From 4ff8d30e410de6de54b73663c801fa10233e2a82 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Wed, 1 Apr 2020 18:54:06 +0200 Subject: Document ExtraRule properly --- Emby.Naming/Video/ExtraRule.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'Emby.Naming/Video') diff --git a/Emby.Naming/Video/ExtraRule.cs b/Emby.Naming/Video/ExtraRule.cs index cb58a3934..7c9702e24 100644 --- a/Emby.Naming/Video/ExtraRule.cs +++ b/Emby.Naming/Video/ExtraRule.cs @@ -5,30 +5,29 @@ using MediaType = Emby.Naming.Common.MediaType; namespace Emby.Naming.Video { + /// + /// A rule used to match a file path with an . + /// public class ExtraRule { /// - /// Gets or sets the token. + /// Gets or sets the token to use for matching against the file path. /// - /// The token. public string Token { get; set; } /// - /// Gets or sets the type of the extra. + /// Gets or sets the type of the extra to return when matched. /// - /// The type of the extra. public ExtraType ExtraType { get; set; } /// /// Gets or sets the type of the rule. /// - /// The type of the rule. public ExtraRuleType RuleType { get; set; } /// - /// Gets or sets the type of the media. + /// Gets or sets the type of the media to return when matched. /// - /// The type of the media. public MediaType MediaType { get; set; } } } -- cgit v1.2.3 From 377f9896ce65d4a29fe9d2198607ced2771b9abb Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Wed, 1 Apr 2020 19:04:00 +0200 Subject: Small fixes --- Emby.Naming/Video/ExtraRuleType.cs | 2 +- MediaBrowser.Api/UserLibrary/UserLibraryService.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'Emby.Naming/Video') diff --git a/Emby.Naming/Video/ExtraRuleType.cs b/Emby.Naming/Video/ExtraRuleType.cs index 0a304874d..76872f3bc 100644 --- a/Emby.Naming/Video/ExtraRuleType.cs +++ b/Emby.Naming/Video/ExtraRuleType.cs @@ -20,7 +20,7 @@ namespace Emby.Naming.Video Regex = 2, /// - /// Match against the directory name of the file. + /// Match against the name of the directory containing the file. /// DirectoryName = 3, } diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index 4cd201c3b..7fa750adb 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -381,7 +381,7 @@ namespace MediaBrowser.Api.UserLibrary var dtoOptions = GetDtoOptions(_authContext, request); - var dtosExtras = item.GetExtras(new ExtraType[] { ExtraType.Trailer }) + var dtosExtras = item.GetExtras(new[] { ExtraType.Trailer }) .Select(i => _dtoService.GetBaseItemDto(i, dtoOptions, user, item)) .ToArray(); -- cgit v1.2.3 From 7be4b57fe7c1f5c7a84a6a8ed91cb49f388f2169 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sun, 5 Apr 2020 09:47:20 -0400 Subject: Fix documentation for ExtraRuleType enum values --- Emby.Naming/Video/ExtraRuleType.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Emby.Naming/Video') diff --git a/Emby.Naming/Video/ExtraRuleType.cs b/Emby.Naming/Video/ExtraRuleType.cs index 76872f3bc..e89876f4a 100644 --- a/Emby.Naming/Video/ExtraRuleType.cs +++ b/Emby.Naming/Video/ExtraRuleType.cs @@ -10,12 +10,12 @@ namespace Emby.Naming.Video Suffix = 0, /// - /// Match against the file name. + /// Match against the file name, excluding the file extension. /// Filename = 1, /// - /// Match against the a regex. + /// Match against the file name, including the file extension. /// Regex = 2, -- cgit v1.2.3