< Summary - Jellyfin

Information
Class: Jellyfin.LiveTv.Listings.EpgChannelData
Assembly: Jellyfin.LiveTv
File(s): /srv/git/jellyfin/src/Jellyfin.LiveTv/Listings/EpgChannelData.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 54
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
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
.ctor(...)0%7280%
GetChannelById(...)100%210%
GetChannelByNumber(...)100%210%
GetChannelByName(...)100%210%
NormalizeName(...)100%210%

File(s)

/srv/git/jellyfin/src/Jellyfin.LiveTv/Listings/EpgChannelData.cs

#LineLine coverage
 1#pragma warning disable CS1591
 2
 3using System;
 4using System.Collections.Generic;
 5using MediaBrowser.Controller.LiveTv;
 6
 7namespace Jellyfin.LiveTv.Listings
 8{
 9    internal class EpgChannelData
 10    {
 11        private readonly Dictionary<string, ChannelInfo> _channelsById;
 12
 13        private readonly Dictionary<string, ChannelInfo> _channelsByNumber;
 14
 15        private readonly Dictionary<string, ChannelInfo> _channelsByName;
 16
 17        public EpgChannelData(IEnumerable<ChannelInfo> channels)
 18        {
 019            _channelsById = new Dictionary<string, ChannelInfo>(StringComparer.OrdinalIgnoreCase);
 020            _channelsByNumber = new Dictionary<string, ChannelInfo>(StringComparer.OrdinalIgnoreCase);
 021            _channelsByName = new Dictionary<string, ChannelInfo>(StringComparer.OrdinalIgnoreCase);
 22
 023            foreach (var channel in channels)
 24            {
 025                _channelsById[channel.Id] = channel;
 26
 027                if (!string.IsNullOrEmpty(channel.Number))
 28                {
 029                    _channelsByNumber[channel.Number] = channel;
 30                }
 31
 032                var normalizedName = NormalizeName(channel.Name ?? string.Empty);
 033                if (!string.IsNullOrWhiteSpace(normalizedName))
 34                {
 035                    _channelsByName[normalizedName] = channel;
 36                }
 37            }
 038        }
 39
 40        public ChannelInfo? GetChannelById(string id)
 041            => _channelsById.GetValueOrDefault(id);
 42
 43        public ChannelInfo? GetChannelByNumber(string number)
 044            => _channelsByNumber.GetValueOrDefault(number);
 45
 46        public ChannelInfo? GetChannelByName(string name)
 047            => _channelsByName.GetValueOrDefault(name);
 48
 49        public static string NormalizeName(string value)
 50        {
 051            return value.Replace(" ", string.Empty, StringComparison.Ordinal).Replace("-", string.Empty, StringCompariso
 52        }
 53    }
 54}