< 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: 87
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;
 11using Jellyfin.Database.Implementations.Entities;
 12using Jellyfin.Database.Implementations.Enums;
 13using MediaBrowser.Controller.Entities;
 14using MediaBrowser.Model.Querying;
 15
 16namespace MediaBrowser.Controller.Channels
 17{
 18    public class Channel : Folder
 19    {
 20        [JsonIgnore]
 021        public override bool SupportsInheritedParentImages => false;
 22
 23        [JsonIgnore]
 124        public override SourceType SourceType => SourceType.Channel;
 25
 26        public override bool IsVisible(User user, bool skipAllowedTagsCheck = false)
 27        {
 028            var blockedChannelsPreference = user.GetPreferenceValues<Guid>(PreferenceKind.BlockedChannels);
 029            if (blockedChannelsPreference.Length != 0)
 30            {
 031                if (blockedChannelsPreference.Contains(Id))
 32                {
 033                    return false;
 34                }
 35            }
 36            else
 37            {
 038                if (!user.HasPermission(PermissionKind.EnableAllChannels)
 039                    && !user.GetPreferenceValues<Guid>(PreferenceKind.EnabledChannels).Contains(Id))
 40                {
 041                    return false;
 42                }
 43            }
 44
 045            return base.IsVisible(user, skipAllowedTagsCheck);
 46        }
 47
 48        protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
 49        {
 50            try
 51            {
 052                query.Parent = this;
 053                query.ChannelIds = new Guid[] { Id };
 54
 55                // Don't blow up here because it could cause parent screens with other content to fail
 056                return ChannelManager.GetChannelItemsInternal(query, new Progress<double>(), CancellationToken.None).Get
 57            }
 058            catch
 59            {
 60                // Already logged at lower levels
 061                return new QueryResult<BaseItem>();
 62            }
 063        }
 64
 65        protected override string GetInternalMetadataPath(string basePath)
 66        {
 067            return GetInternalMetadataPath(basePath, Id);
 68        }
 69
 70        public static string GetInternalMetadataPath(string basePath, Guid id)
 71        {
 072            return System.IO.Path.Combine(basePath, "channels", id.ToString("N", CultureInfo.InvariantCulture), "metadat
 73        }
 74
 75        public override bool CanDelete()
 76        {
 077            return false;
 78        }
 79
 80        internal static bool IsChannelVisible(BaseItem channelItem, User user)
 81        {
 082            var channel = ChannelManager.GetChannel(channelItem.ChannelId.ToString(string.Empty));
 83
 084            return channel.IsVisible(user);
 85        }
 86    }
 87}