//
// Copyright (c) PlaceholderCompany. All rights reserved.
//
namespace Emby.Naming.Common
{
using System;
using System.Text.RegularExpressions;
///
/// Regular expressions for parsing TV Episodes.
///
public class EpisodeExpression
{
private string _expression;
private Regex? _regex;
///
/// Initializes a new instance of the class.
///
/// Regular expressions.
/// True if date is expected.
public EpisodeExpression(string expression, bool byDate = false)
{
this._expression = expression;
this.IsByDate = byDate;
this.DateTimeFormats = Array.Empty();
this.SupportsAbsoluteEpisodeNumbers = true;
}
///
/// Gets or sets raw expressions string.
///
public string Expression
{
get => this._expression;
set
{
this._expression = value;
this._regex = null;
}
}
///
/// Gets or sets a value indicating whether gets or sets property indicating if date can be find in expression.
///
public bool IsByDate { get; set; }
///
/// Gets or sets a value indicating whether gets or sets property indicating if expression is optimistic.
///
public bool IsOptimistic { get; set; }
///
/// Gets or sets a value indicating whether gets or sets property indicating if expression is named.
///
public bool IsNamed { get; set; }
///
/// Gets or sets a value indicating whether gets or sets property indicating if expression supports episodes with absolute numbers.
///
public bool SupportsAbsoluteEpisodeNumbers { get; set; }
///
/// Gets or sets optional list of date formats used for date parsing.
///
public string[] DateTimeFormats { get; set; }
///
/// Gets a expressions objects (creates it if null).
///
public Regex Regex => this._regex ??= new Regex(this.Expression, RegexOptions.IgnoreCase | RegexOptions.Compiled);
}
}