Match using directory names in ExtraResolver

This commit is contained in:
Mark Monteiro 2020-04-01 18:53:19 +02:00
parent cc8294842a
commit 2e1ec2858a
3 changed files with 27 additions and 5 deletions

View File

@ -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[]

View File

@ -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;
}

View File

@ -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,
}
}