< 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: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 72
Line coverage: 100%
Branch coverage
75%
Covered branches: 9
Total branches: 12
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 3/26/2026 - 12:14:14 AM Line coverage: 100% (19/19) Branch coverage: 100% (10/10) Total lines: 715/20/2026 - 12:15:44 AM Line coverage: 100% (19/19) Branch coverage: 80% (8/10) Total lines: 716/19/2026 - 12:16:12 AM Line coverage: 100% (20/20) Branch coverage: 75% (9/12) Total lines: 72 3/26/2026 - 12:14:14 AM Line coverage: 100% (19/19) Branch coverage: 100% (10/10) Total lines: 715/20/2026 - 12:15:44 AM Line coverage: 100% (19/19) Branch coverage: 80% (8/10) Total lines: 716/19/2026 - 12:16:12 AM Line coverage: 100% (20/20) Branch coverage: 75% (9/12) Total lines: 72

Coverage delta

Coverage delta 20 -20

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Resolve(...)75%1212100%

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*\((?<year>[0-9]{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        {
 2635            string seriesName = Path.GetFileName(path);
 36
 37            // First check if the filename matches a title with year pattern (handles numeric titles)
 2638            if (!string.IsNullOrEmpty(seriesName))
 39            {
 2640                var titleWithYearMatch = TitleWithYearRegex().Match(seriesName);
 2641                if (titleWithYearMatch.Success)
 42                {
 143                    seriesName = titleWithYearMatch.Groups["title"].Value.Trim();
 144                    return new SeriesInfo(path)
 145                    {
 146                        Name = seriesName,
 147                        Year = int.TryParse(titleWithYearMatch.Groups["year"].ValueSpan, out var year) ? year : null
 148                    };
 49                }
 50            }
 51
 2552            SeriesPathParserResult result = SeriesPathParser.Parse(options, path);
 2553            if (result.Success)
 54            {
 855                if (!string.IsNullOrEmpty(result.SeriesName))
 56                {
 857                    seriesName = result.SeriesName;
 58                }
 59            }
 60
 2561            if (!string.IsNullOrEmpty(seriesName))
 62            {
 2563                seriesName = SeriesNameRegex().Replace(seriesName, "${a} ${b}").Trim();
 64            }
 65
 2566            return new SeriesInfo(path)
 2567            {
 2568                Name = seriesName
 2569            };
 70        }
 71    }
 72}