< Summary - Jellyfin

Information
Class: Jellyfin.LiveTv.Recordings.RecordingHelper
Assembly: Jellyfin.LiveTv
File(s): /srv/git/jellyfin/src/Jellyfin.LiveTv/Recordings/RecordingHelper.cs
Line coverage
100%
Covered lines: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 76
Line coverage: 100%
Branch coverage
100%
Covered branches: 20
Total branches: 20
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
GetRecordingName(...)100%2020100%
GetDateString(...)100%11100%

File(s)

/srv/git/jellyfin/src/Jellyfin.LiveTv/Recordings/RecordingHelper.cs

#LineLine coverage
 1using System;
 2using System.Globalization;
 3using System.Text;
 4using MediaBrowser.Controller.LiveTv;
 5
 6namespace Jellyfin.LiveTv.Recordings
 7{
 8    internal static class RecordingHelper
 9    {
 10        public static string GetRecordingName(TimerInfo info)
 11        {
 912            var name = info.Name;
 13
 914            if (info.IsProgramSeries)
 15            {
 716                var addHyphen = true;
 17
 718                if (info.SeasonNumber.HasValue && info.EpisodeNumber.HasValue)
 19                {
 220                    name += string.Format(
 221                        CultureInfo.InvariantCulture,
 222                        " S{0}E{1}",
 223                        info.SeasonNumber.Value.ToString("00", CultureInfo.InvariantCulture),
 224                        info.EpisodeNumber.Value.ToString("00", CultureInfo.InvariantCulture));
 225                    addHyphen = false;
 26                }
 527                else if (info.OriginalAirDate.HasValue)
 28                {
 429                    if (info.OriginalAirDate.Value.Date.Equals(info.StartDate.Date))
 30                    {
 231                        name += " " + GetDateString(info.StartDate);
 32                    }
 33                    else
 34                    {
 235                        name += " " + info.OriginalAirDate.Value.ToLocalTime().ToString("yyyy-MM-dd", CultureInfo.Invari
 36                    }
 37                }
 38                else
 39                {
 140                    name += " " + GetDateString(info.StartDate);
 41                }
 42
 743                if (!string.IsNullOrWhiteSpace(info.EpisodeTitle))
 44                {
 445                    var tmpName = name;
 446                    if (addHyphen)
 47                    {
 348                        tmpName += " -";
 49                    }
 50
 451                    tmpName += " " + info.EpisodeTitle;
 52                    // Since the filename will be used with file ext. (.mp4, .ts, etc)
 453                    if (Encoding.UTF8.GetByteCount(tmpName) < 250)
 54                    {
 355                        name = tmpName;
 56                    }
 57                }
 58            }
 259            else if (info.IsMovie && info.ProductionYear is not null)
 60            {
 161                name += " (" + info.ProductionYear + ")";
 62            }
 63            else
 64            {
 165                name += " " + GetDateString(info.StartDate);
 66            }
 67
 968            return name;
 69        }
 70
 71        private static string GetDateString(DateTime date)
 72        {
 473            return date.ToLocalTime().ToString("yyyy_MM_dd_HH_mm_ss", CultureInfo.InvariantCulture);
 74        }
 75    }
 76}