< 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: 75
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 5/31/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: 7210/29/2026 - 12:17:11 AM Line coverage: 100% (20/20) Branch coverage: 75% (9/12) Total lines: 75 5/31/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: 7210/29/2026 - 12:17:11 AM Line coverage: 100% (20/20) Branch coverage: 75% (9/12) Total lines: 75

Coverage delta

Coverage delta 5 -5

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 a run of dots or underscores that separates two words, where a word is
 14        /// at least 2 characters long. Used for removing separators between words, i.e turns
 15        /// "The_show" into "The show" while preserving acronyms like "S.H.O.W", whose single letters
 16        /// are a word on neither side. Whitespace bounds a word too, so the dot in
 17        /// "Marvel's Agents of S.H.I.E.L.D." is read against the "S" beside it rather than against
 18        /// the whole run of words before it.
 19        /// </summary>
 20        [GeneratedRegex(@"(?<=[^\s\._]{2})[\._]+|[\._]+(?=[^\s\._]{2})")]
 21        private static partial Regex SeriesNameRegex();
 22
 23        /// <summary>
 24        /// Regex that matches titles with year in parentheses. Captures the title (which may be
 25        /// numeric) before the year, i.e. turns "1923 (2022)" into "1923".
 26        /// </summary>
 27        [GeneratedRegex(@"(?<title>.+?)\s*\((?<year>[0-9]{4})\)")]
 28        private static partial Regex TitleWithYearRegex();
 29
 30        /// <summary>
 31        /// Resolve information about series from path.
 32        /// </summary>
 33        /// <param name="options"><see cref="NamingOptions"/> object passed to <see cref="SeriesPathParser"/>.</param>
 34        /// <param name="path">Path to series.</param>
 35        /// <returns>SeriesInfo.</returns>
 36        public static SeriesInfo Resolve(NamingOptions options, string path)
 37        {
 3238            string seriesName = Path.GetFileName(path);
 39
 40            // First check if the filename matches a title with year pattern (handles numeric titles)
 3241            if (!string.IsNullOrEmpty(seriesName))
 42            {
 3243                var titleWithYearMatch = TitleWithYearRegex().Match(seriesName);
 3244                if (titleWithYearMatch.Success)
 45                {
 146                    seriesName = titleWithYearMatch.Groups["title"].Value.Trim();
 147                    return new SeriesInfo(path)
 148                    {
 149                        Name = seriesName,
 150                        Year = int.TryParse(titleWithYearMatch.Groups["year"].ValueSpan, out var year) ? year : null
 151                    };
 52                }
 53            }
 54
 3155            SeriesPathParserResult result = SeriesPathParser.Parse(options, path);
 3156            if (result.Success)
 57            {
 1058                if (!string.IsNullOrEmpty(result.SeriesName))
 59                {
 1060                    seriesName = result.SeriesName;
 61                }
 62            }
 63
 3164            if (!string.IsNullOrEmpty(seriesName))
 65            {
 3166                seriesName = SeriesNameRegex().Replace(seriesName, " ").Trim();
 67            }
 68
 3169            return new SeriesInfo(path)
 3170            {
 3171                Name = seriesName
 3172            };
 73        }
 74    }
 75}