< Summary - Jellyfin

Information
Class: Emby.Naming.TV.SeriesPathParser
Assembly: Emby.Naming
File(s): /srv/git/jellyfin/Emby.Naming/TV/SeriesPathParser.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 60
Line coverage: 100%
Branch coverage
94%
Covered branches: 17
Total branches: 18
Branch coverage: 94.4%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Parse(...)100%1010100%
Parse(...)87.5%88100%

File(s)

/srv/git/jellyfin/Emby.Naming/TV/SeriesPathParser.cs

#LineLine coverage
 1using Emby.Naming.Common;
 2
 3namespace Emby.Naming.TV
 4{
 5    /// <summary>
 6    /// Used to parse information about series from paths containing more information that only the series name.
 7    /// Uses the same regular expressions as the EpisodePathParser but have different success criteria.
 8    /// </summary>
 9    public static class SeriesPathParser
 10    {
 11        /// <summary>
 12        /// Parses information about series from path.
 13        /// </summary>
 14        /// <param name="options"><see cref="NamingOptions"/> object containing EpisodeExpressions and MultipleEpisodeEx
 15        /// <param name="path">Path.</param>
 16        /// <returns>Returns <see cref="SeriesPathParserResult"/> object.</returns>
 17        public static SeriesPathParserResult Parse(NamingOptions options, string path)
 18        {
 1919            SeriesPathParserResult? result = null;
 20
 83521            foreach (var expression in options.EpisodeExpressions)
 22            {
 40723                var currentResult = Parse(path, expression);
 40724                if (currentResult.Success)
 25                {
 1726                    result = currentResult;
 1727                    break;
 28                }
 29            }
 30
 1931            if (result is not null)
 32            {
 1733                if (!string.IsNullOrEmpty(result.SeriesName))
 34                {
 1735                    result.SeriesName = result.SeriesName.Trim(' ', '_', '.', '-');
 36                }
 37            }
 38
 1939            return result ?? new SeriesPathParserResult();
 40        }
 41
 42        private static SeriesPathParserResult Parse(string name, EpisodeExpression expression)
 43        {
 40744            var result = new SeriesPathParserResult();
 45
 40746            var match = expression.Regex.Match(name);
 47
 40748            if (match.Success && match.Groups.Count >= 3)
 49            {
 1950                if (expression.IsNamed)
 51                {
 1952                    result.SeriesName = match.Groups["seriesname"].Value;
 1953                    result.Success = !string.IsNullOrEmpty(result.SeriesName) && !match.Groups["seasonnumber"].ValueSpan
 54                }
 55            }
 56
 40757            return result;
 58        }
 59    }
 60}