< 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: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 50
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
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
Resolve(...)100%66100%

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 namings like "S.H.O.W".
 16        /// </summary>
 17        [GeneratedRegex(@"((?<a>[^\._]{2,})[\._]*)|([\._](?<b>[^\._]{2,}))")]
 18        private static partial Regex SeriesNameRegex();
 19
 20        /// <summary>
 21        /// Resolve information about series from path.
 22        /// </summary>
 23        /// <param name="options"><see cref="NamingOptions"/> object passed to <see cref="SeriesPathParser"/>.</param>
 24        /// <param name="path">Path to series.</param>
 25        /// <returns>SeriesInfo.</returns>
 26        public static SeriesInfo Resolve(NamingOptions options, string path)
 27        {
 1028            string seriesName = Path.GetFileName(path);
 29
 1030            SeriesPathParserResult result = SeriesPathParser.Parse(options, path);
 1031            if (result.Success)
 32            {
 833                if (!string.IsNullOrEmpty(result.SeriesName))
 34                {
 835                    seriesName = result.SeriesName;
 36                }
 37            }
 38
 1039            if (!string.IsNullOrEmpty(seriesName))
 40            {
 1041                seriesName = SeriesNameRegex().Replace(seriesName, "${a} ${b}").Trim();
 42            }
 43
 1044            return new SeriesInfo(path)
 1045            {
 1046                Name = seriesName
 1047            };
 48        }
 49    }
 50}