mirror of
https://github.com/Readarr/Readarr.git
synced 2026-03-28 18:05:51 -04:00
New: Anime support New: pull alternate names from thexem.de New: Search using all alternate names (if rage ID is unavailable) New: Show scene mapping information when hovering over episode number New: Full season searching for anime (searches for each episode) New: animezb.com anime indexer New: Treat BD as bluray Fixed: Parsing of 2 digit absolute episode numbers Fixed: Loading series details page for series that start with period Fixed: Return 0 results when manual search fails, instead of an error Fixed: animezb URL
88 lines
3.3 KiB
C#
88 lines
3.3 KiB
C#
using System;
|
|
using System.Text.RegularExpressions;
|
|
using FluentValidation;
|
|
using FluentValidation.Validators;
|
|
|
|
namespace NzbDrone.Core.Organizer
|
|
{
|
|
public static class FileNameValidation
|
|
{
|
|
private static readonly Regex SeasonFolderRegex = new Regex(@"(\{season(\:\d+)?\})",
|
|
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
|
|
public static IRuleBuilderOptions<T, string> ValidEpisodeFormat<T>(this IRuleBuilder<T, string> ruleBuilder)
|
|
{
|
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
|
return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.SeasonEpisodePatternRegex)).WithMessage("Must contain season and episode numbers");
|
|
}
|
|
|
|
public static IRuleBuilderOptions<T, string> ValidDailyEpisodeFormat<T>(this IRuleBuilder<T, string> ruleBuilder)
|
|
{
|
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
|
return ruleBuilder.SetValidator(new ValidDailyEpisodeFormatValidator());
|
|
}
|
|
|
|
public static IRuleBuilderOptions<T, string> ValidAnimeEpisodeFormat<T>(this IRuleBuilder<T, string> ruleBuilder)
|
|
{
|
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
|
return ruleBuilder.SetValidator(new ValidAnimeEpisodeFormatValidator());
|
|
}
|
|
|
|
public static IRuleBuilderOptions<T, string> ValidSeriesFolderFormat<T>(this IRuleBuilder<T, string> ruleBuilder)
|
|
{
|
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
|
return ruleBuilder.SetValidator(new RegularExpressionValidator(FileNameBuilder.SeriesTitleRegex)).WithMessage("Must contain series title");
|
|
}
|
|
|
|
public static IRuleBuilderOptions<T, string> ValidSeasonFolderFormat<T>(this IRuleBuilder<T, string> ruleBuilder)
|
|
{
|
|
ruleBuilder.SetValidator(new NotEmptyValidator(null));
|
|
return ruleBuilder.SetValidator(new RegularExpressionValidator(SeasonFolderRegex)).WithMessage("Must contain season number");
|
|
}
|
|
}
|
|
|
|
public class ValidDailyEpisodeFormatValidator : PropertyValidator
|
|
{
|
|
public ValidDailyEpisodeFormatValidator()
|
|
: base("Must contain Air Date or Season and Episode")
|
|
{
|
|
|
|
}
|
|
|
|
protected override bool IsValid(PropertyValidatorContext context)
|
|
{
|
|
var value = context.PropertyValue as String;
|
|
|
|
if (!FileNameBuilder.SeasonEpisodePatternRegex.IsMatch(value) &&
|
|
!FileNameBuilder.AirDateRegex.IsMatch(value))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public class ValidAnimeEpisodeFormatValidator : PropertyValidator
|
|
{
|
|
public ValidAnimeEpisodeFormatValidator()
|
|
: base("Must contain Absolute Episode number or Season and Episode")
|
|
{
|
|
|
|
}
|
|
|
|
protected override bool IsValid(PropertyValidatorContext context)
|
|
{
|
|
var value = context.PropertyValue as String;
|
|
|
|
if (!FileNameBuilder.SeasonEpisodePatternRegex.IsMatch(value) &&
|
|
!FileNameBuilder.AbsoluteEpisodePatternRegex.IsMatch(value))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|