diff options
| author | Mark Monteiro <marknr.monteiro@protonmail.com> | 2020-04-01 18:53:19 +0200 |
|---|---|---|
| committer | Mark Monteiro <marknr.monteiro@protonmail.com> | 2020-04-01 18:53:19 +0200 |
| commit | 2e1ec2858a5bd2a03d8dd5fd0ae9f9c11487ed7f (patch) | |
| tree | 6018e7f0b9af0d2ba362c71a202442bf4547b309 | |
| parent | cc8294842a41478e7c22bcef39c0cfcc114f05a0 (diff) | |
Match using directory names in ExtraResolver
| -rw-r--r-- | Emby.Naming/Common/NamingOptions.cs | 10 | ||||
| -rw-r--r-- | Emby.Naming/Video/ExtraResolver.cs | 9 | ||||
| -rw-r--r-- | Emby.Naming/Video/ExtraRuleType.cs | 13 |
3 files changed, 27 insertions, 5 deletions
diff --git a/Emby.Naming/Common/NamingOptions.cs b/Emby.Naming/Common/NamingOptions.cs index 793847f84..8ac33d3f5 100644 --- a/Emby.Naming/Common/NamingOptions.cs +++ b/Emby.Naming/Common/NamingOptions.cs @@ -505,7 +505,15 @@ namespace Emby.Naming.Common RuleType = ExtraRuleType.Suffix, Token = "-short", MediaType = MediaType.Video - } + }, + new ExtraRule { RuleType = ExtraRuleType.DirectoryName, MediaType = MediaType.Video, ExtraType = ExtraType.BehindTheScenes, Token = "behind the scenes" }, + new ExtraRule { RuleType = ExtraRuleType.DirectoryName, MediaType = MediaType.Video, ExtraType = ExtraType.DeletedScene, Token = "deleted scenes" }, + new ExtraRule { RuleType = ExtraRuleType.DirectoryName, MediaType = MediaType.Video, ExtraType = ExtraType.Interview, Token = "interviews" }, + new ExtraRule { RuleType = ExtraRuleType.DirectoryName, MediaType = MediaType.Video, ExtraType = ExtraType.Scene, Token = "scenes" }, + new ExtraRule { RuleType = ExtraRuleType.DirectoryName, MediaType = MediaType.Video, ExtraType = ExtraType.Sample, Token = "samples" }, + new ExtraRule { RuleType = ExtraRuleType.DirectoryName, MediaType = MediaType.Video, ExtraType = ExtraType.Clip, Token = "shorts" }, + new ExtraRule { RuleType = ExtraRuleType.DirectoryName, MediaType = MediaType.Video, ExtraType = ExtraType.Clip, Token = "featurettes" }, + new ExtraRule { RuleType = ExtraRuleType.DirectoryName, MediaType = MediaType.Video, ExtraType = ExtraType.Unknown, Token = "extras" }, }; Format3DRules = new[] 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 { /// <summary> - /// The suffix + /// Match <see cref="ExtraRule.Token"/> against a suffix in the file name. /// </summary> Suffix = 0, /// <summary> - /// The filename + /// Match <see cref="ExtraRule.Token"/> against the file name. /// </summary> Filename = 1, /// <summary> - /// The regex + /// Match <see cref="ExtraRule.Token"/> against the a regex. /// </summary> - Regex = 2 + Regex = 2, + + /// <summary> + /// Match <see cref="ExtraRule.Token"/> against the directory name of the file. + /// </summary> + DirectoryName = 3, } } |
