< Summary - Jellyfin

Information
Class: Emby.Naming.TV.SeriesResolver
Assembly: Emby.Naming
File(s): /srv/git/jellyfin/Emby.Naming/TV/SeriesResolver.cs
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 71
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 9/14/2025 - 12:09:49 AM Line coverage: 100% (11/11) Branch coverage: 100% (6/6) Total lines: 5011/28/2025 - 12:11:11 AM Line coverage: 100% (19/19) Branch coverage: 100% (10/10) Total lines: 71 9/14/2025 - 12:09:49 AM Line coverage: 100% (11/11) Branch coverage: 100% (6/6) Total lines: 5011/28/2025 - 12:11:11 AM Line coverage: 100% (19/19) Branch coverage: 100% (10/10) Total lines: 71

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Resolve(...)100%1010100%

File(s)

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

#LineLine coverage
 1using System.IO;
 2using System.Text.RegularExpressions;
 3using Emby.Naming.Common;
 4
 5namespace Emby.Naming.TV
 6{
 7    /// <summary>
 8    /// Used to resolve information about series from path.
 9    /// </summary>
 10    public static partial class SeriesResolver
 11    {
 12        /// <summary>
 13        /// Regex that matches strings of at least 2 characters separated by a dot or underscore.
 14        /// Used for removing separators between words, i.e turns "The_show" into "The show" while
 15        /// preserving names like "S.H.O.W".
 16        /// </summary>
 17        [GeneratedRegex(@"((?<a>[^\._]{2,})[\._]*)|([\._](?<b>[^\._]{2,}))")]
 18        private static partial Regex SeriesNameRegex();
 19
 20        /// <summary>
 21        /// Regex that matches titles with year in parentheses. Captures the title (which may be
 22        /// numeric) before the year, i.e. turns "1923 (2022)" into "1923".
 23        /// </summary>
 24        [GeneratedRegex(@"(?<title>.+?)\s*\(\d{4}\)")]
 25        private static partial Regex TitleWithYearRegex();
 26
 27        /// <summary>
 28        /// Resolve information about series from path.
 29        /// </summary>
 30        /// <param name="options"><see cref="NamingOptions"/> object passed to <see cref="SeriesPathParser"/>.</param>
 31        /// <param name="path">Path to series.</param>
 32        /// <returns>SeriesInfo.</returns>
 33        public static SeriesInfo Resolve(NamingOptions options, string path)
 34        {
 1135            string seriesName = Path.GetFileName(path);
 36
 37            // First check if the filename matches a title with year pattern (handles numeric titles)
 1138            if (!string.IsNullOrEmpty(seriesName))
 39            {
 1140                var titleWithYearMatch = TitleWithYearRegex().Match(seriesName);
 1141                if (titleWithYearMatch.Success)
 42                {
 143                    seriesName = titleWithYearMatch.Groups["title"].Value.Trim();
 144                    return new SeriesInfo(path)
 145                    {
 146                        Name = seriesName
 147                    };
 48                }
 49            }
 50
 1051            SeriesPathParserResult result = SeriesPathParser.Parse(options, path);
 1052            if (result.Success)
 53            {
 854                if (!string.IsNullOrEmpty(result.SeriesName))
 55                {
 856                    seriesName = result.SeriesName;
 57                }
 58            }
 59
 1060            if (!string.IsNullOrEmpty(seriesName))
 61            {
 1062                seriesName = SeriesNameRegex().Replace(seriesName, "${a} ${b}").Trim();
 63            }
 64
 1065            return new SeriesInfo(path)
 1066            {
 1067                Name = seriesName
 1068            };
 69        }
 70    }
 71}