< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Channels.Channel
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Channels/Channel.cs
Line coverage
4%
Covered lines: 1
Uncovered lines: 20
Coverable lines: 21
Total lines: 86
Line coverage: 4.7%
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
get_SupportsInheritedParentImages()100%210%
get_SourceType()100%11100%
IsVisible(...)0%7280%
GetItemsInternal(...)100%210%
GetInternalMetadataPath(...)100%210%
GetInternalMetadataPath(...)100%210%
CanDelete()100%210%
IsChannelVisible(...)100%210%

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Channels/Channel.cs

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591
 4
 5using System;
 6using System.Globalization;
 7using System.Linq;
 8using System.Text.Json.Serialization;
 9using System.Threading;
 10using Jellyfin.Data.Entities;
 11using Jellyfin.Data.Enums;
 12using MediaBrowser.Controller.Entities;
 13using MediaBrowser.Model.Querying;
 14
 15namespace MediaBrowser.Controller.Channels
 16{
 17    public class Channel : Folder
 18    {
 19        [JsonIgnore]
 020        public override bool SupportsInheritedParentImages => false;
 21
 22        [JsonIgnore]
 123        public override SourceType SourceType => SourceType.Channel;
 24
 25        public override bool IsVisible(User user)
 26        {
 027            var blockedChannelsPreference = user.GetPreferenceValues<Guid>(PreferenceKind.BlockedChannels);
 028            if (blockedChannelsPreference.Length != 0)
 29            {
 030                if (blockedChannelsPreference.Contains(Id))
 31                {
 032                    return false;
 33                }
 34            }
 35            else
 36            {
 037                if (!user.HasPermission(PermissionKind.EnableAllChannels)
 038                    && !user.GetPreferenceValues<Guid>(PreferenceKind.EnabledChannels).Contains(Id))
 39                {
 040                    return false;
 41                }
 42            }
 43
 044            return base.IsVisible(user);
 45        }
 46
 47        protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
 48        {
 49            try
 50            {
 051                query.Parent = this;
 052                query.ChannelIds = new Guid[] { Id };
 53
 54                // Don't blow up here because it could cause parent screens with other content to fail
 055                return ChannelManager.GetChannelItemsInternal(query, new Progress<double>(), CancellationToken.None).Get
 56            }
 057            catch
 58            {
 59                // Already logged at lower levels
 060                return new QueryResult<BaseItem>();
 61            }
 062        }
 63
 64        protected override string GetInternalMetadataPath(string basePath)
 65        {
 066            return GetInternalMetadataPath(basePath, Id);
 67        }
 68
 69        public static string GetInternalMetadataPath(string basePath, Guid id)
 70        {
 071            return System.IO.Path.Combine(basePath, "channels", id.ToString("N", CultureInfo.InvariantCulture), "metadat
 72        }
 73
 74        public override bool CanDelete()
 75        {
 076            return false;
 77        }
 78
 79        internal static bool IsChannelVisible(BaseItem channelItem, User user)
 80        {
 081            var channel = ChannelManager.GetChannel(channelItem.ChannelId.ToString(string.Empty));
 82
 083            return channel.IsVisible(user);
 84        }
 85    }
 86}