aboutsummaryrefslogtreecommitdiff
path: root/Emby.Naming/Common/EpisodeExpression.cs
blob: 3b9687c60b8002dd7f8d9a8528ba78e8f3810bd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Text.RegularExpressions;
using System;

namespace Emby.Naming.Common
{
    public class EpisodeExpression
    {
        private string _expression;
        public string Expression { get { return _expression; } set { _expression = value; _regex = null; } }

        public bool IsByDate { get; set; }
        public bool IsOptimistic { get; set; }
        public bool IsNamed { get; set; }
        public bool SupportsAbsoluteEpisodeNumbers { get; set; }

        public string[] DateTimeFormats { get; set; }

        private Regex _regex;
        public Regex Regex
        {
            get
            {
                return _regex ?? (_regex = new Regex(Expression, RegexOptions.IgnoreCase | RegexOptions.Compiled));
            }
        }

        public EpisodeExpression(string expression, bool byDate)
        {
            Expression = expression;
            IsByDate = byDate;
            DateTimeFormats = Array.Empty<string>();
            SupportsAbsoluteEpisodeNumbers = true;
        }

        public EpisodeExpression(string expression)
            : this(expression, false)
        {
        }

        public EpisodeExpression()
            : this(null)
        {
        }
    }
}