diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index daffbe758..9e1be9150 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -42,20 +42,11 @@ namespace NzbDrone.Core.Organizer private static readonly Regex MediumRegex = new Regex(@"(?\{medium(?:\:0+)?})", RegexOptions.Compiled | RegexOptions.IgnoreCase); - private static readonly Regex AbsoluteEpisodeRegex = new Regex(@"(?\{absolute(?:\:0+)?})", - RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static readonly Regex SeasonEpisodePatternRegex = new Regex(@"(?(?<=})[- ._]+?)?(?s?{season(?:\:0+)?}(?[- ._]?[ex])(?{episode(?:\:0+)?}))(?[- ._]+?(?={))?", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static readonly Regex AbsoluteEpisodePatternRegex = new Regex(@"(?(?<=})[- ._]+?)?(?{absolute(?:\:0+)?})(?[- ._]+?(?={))?", - RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static readonly Regex AirDateRegex = new Regex(@"\{Air(\s|\W|_)Date\}", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static readonly Regex SeriesTitleRegex = new Regex(@"(?\{(?:Series)(?[- ._])(Clean)?Title\})", - RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static readonly Regex ArtistNameRegex = new Regex(@"(?\{(?:Artist)(?[- ._])(Clean)?Name(The)?\})", RegexOptions.Compiled | RegexOptions.IgnoreCase); @@ -479,16 +470,6 @@ namespace NzbDrone.Core.Organizer }).ToArray()); } - private AbsoluteTrackFormat[] GetAbsoluteFormat(string pattern) - { - return _absoluteTrackFormatCache.Get(pattern, () => AbsoluteEpisodePatternRegex.Matches(pattern).OfType() - .Select(match => new AbsoluteTrackFormat - { - Separator = match.Groups["separator"].Value.IsNotNullOrWhiteSpace() ? match.Groups["separator"].Value : "-", - AbsoluteTrackPattern = match.Groups["absolute"].Value - }).ToArray()); - } - private string GetTrackTitle(List tracks, string separator) { separator = string.Format(" {0} ", separator.Trim()); diff --git a/src/NzbDrone.Core/Organizer/FileNameValidation.cs b/src/NzbDrone.Core/Organizer/FileNameValidation.cs index 33f397331..fe20efd31 100644 --- a/src/NzbDrone.Core/Organizer/FileNameValidation.cs +++ b/src/NzbDrone.Core/Organizer/FileNameValidation.cs @@ -6,47 +6,15 @@ namespace NzbDrone.Core.Organizer { public static class FileNameValidation { - private static readonly Regex SeasonFolderRegex = new Regex(@"(\{season(\:\d+)?\})", - RegexOptions.Compiled | RegexOptions.IgnoreCase); - internal static readonly Regex OriginalTokenRegex = new Regex(@"(\{original[- ._](?:title|filename)\})", RegexOptions.Compiled | RegexOptions.IgnoreCase); - public static IRuleBuilderOptions ValidEpisodeFormat(this IRuleBuilder ruleBuilder) - { - ruleBuilder.SetValidator(new NotEmptyValidator(null)); - return ruleBuilder.SetValidator(new ValidStandardEpisodeFormatValidator()); - } - public static IRuleBuilderOptions ValidTrackFormat(this IRuleBuilder ruleBuilder) { ruleBuilder.SetValidator(new NotEmptyValidator(null)); return ruleBuilder.SetValidator(new ValidStandardTrackFormatValidator()); } - public static IRuleBuilderOptions ValidDailyEpisodeFormat(this IRuleBuilder ruleBuilder) - { - ruleBuilder.SetValidator(new NotEmptyValidator(null)); - return ruleBuilder.SetValidator(new ValidDailyEpisodeFormatValidator()); - } - - public static IRuleBuilderOptions ValidAnimeEpisodeFormat(this IRuleBuilder ruleBuilder) - { - ruleBuilder.SetValidator(new NotEmptyValidator(null)); - return ruleBuilder.SetValidator(new ValidAnimeEpisodeFormatValidator()); - } - - public static IRuleBuilderOptions ValidSeriesFolderFormat(this IRuleBuilder ruleBuilder) - { - ruleBuilder.SetValidator(new NotEmptyValidator(null)); - return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.SeriesTitleRegex)).WithMessage("Must contain series title"); - } - - public static IRuleBuilderOptions ValidSeasonFolderFormat(this IRuleBuilder ruleBuilder) - { - ruleBuilder.SetValidator(new NotEmptyValidator(null)); - return ruleBuilder.SetValidator(new RegularExpressionValidator(SeasonFolderRegex)).WithMessage("Must contain season number"); - } public static IRuleBuilderOptions ValidArtistFolderFormat(this IRuleBuilder ruleBuilder) { ruleBuilder.SetValidator(new NotEmptyValidator(null)); @@ -60,28 +28,6 @@ namespace NzbDrone.Core.Organizer } } - public class ValidStandardEpisodeFormatValidator : PropertyValidator - { - public ValidStandardEpisodeFormatValidator() - : base("Must contain season and episode numbers OR Original Title") - { - - } - - protected override bool IsValid(PropertyValidatorContext context) - { - var value = context.PropertyValue as string; - - if (!FileNameBuilder.SeasonEpisodePatternRegex.IsMatch(value) && - !FileNameValidation.OriginalTokenRegex.IsMatch(value)) - { - return false; - } - - return true; - } - } - public class ValidStandardTrackFormatValidator : PropertyValidator { public ValidStandardTrackFormatValidator() @@ -96,50 +42,4 @@ namespace NzbDrone.Core.Organizer return true; //TODO Add Logic here } } - - public class ValidDailyEpisodeFormatValidator : PropertyValidator - { - public ValidDailyEpisodeFormatValidator() - : base("Must contain Air Date OR Season and Episode OR Original Title") - { - - } - - protected override bool IsValid(PropertyValidatorContext context) - { - var value = context.PropertyValue as string; - - if (!FileNameBuilder.SeasonEpisodePatternRegex.IsMatch(value) && - !FileNameBuilder.AirDateRegex.IsMatch(value) && - !FileNameValidation.OriginalTokenRegex.IsMatch(value)) - { - return false; - } - - return true; - } - } - - public class ValidAnimeEpisodeFormatValidator : PropertyValidator - { - public ValidAnimeEpisodeFormatValidator() - : base("Must contain Absolute Episode number OR Season and Episode OR Original Title") - { - - } - - protected override bool IsValid(PropertyValidatorContext context) - { - var value = context.PropertyValue as string; - - if (!FileNameBuilder.SeasonEpisodePatternRegex.IsMatch(value) && - !FileNameBuilder.AbsoluteEpisodePatternRegex.IsMatch(value) && - !FileNameValidation.OriginalTokenRegex.IsMatch(value)) - { - return false; - } - - return true; - } - } }