< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.UserView
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/UserView.cs
Line coverage
28%
Covered lines: 15
Uncovered lines: 37
Coverable lines: 52
Total lines: 192
Line coverage: 28.8%
Branch coverage
0%
Covered branches: 0
Total branches: 18
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

File(s)

/srv/git/jellyfin/MediaBrowser.Controller/Entities/UserView.cs

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591
 4
 5using System;
 6using System.Collections.Generic;
 7using System.Linq;
 8using System.Text.Json.Serialization;
 9using System.Threading;
 10using System.Threading.Tasks;
 11using Jellyfin.Data.Enums;
 12using Jellyfin.Database.Implementations.Entities;
 13using Jellyfin.Extensions;
 14using MediaBrowser.Controller.Providers;
 15using MediaBrowser.Controller.TV;
 16using MediaBrowser.Model.Querying;
 17
 18namespace MediaBrowser.Controller.Entities
 19{
 20    public class UserView : Folder, IHasCollectionType
 21    {
 122        private static readonly CollectionType?[] _viewTypesEligibleForGrouping =
 123        {
 124            Jellyfin.Data.Enums.CollectionType.movies,
 125            Jellyfin.Data.Enums.CollectionType.tvshows,
 126            null
 127        };
 28
 129        private static readonly CollectionType?[] _originalFolderViewTypes =
 130        {
 131            Jellyfin.Data.Enums.CollectionType.books,
 132            Jellyfin.Data.Enums.CollectionType.musicvideos,
 133            Jellyfin.Data.Enums.CollectionType.homevideos,
 134            Jellyfin.Data.Enums.CollectionType.photos,
 135            Jellyfin.Data.Enums.CollectionType.music,
 136            Jellyfin.Data.Enums.CollectionType.boxsets
 137        };
 38
 39        public static ITVSeriesManager TVSeriesManager { get; set; }
 40
 41        /// <summary>
 42        /// Gets or sets the view type.
 43        /// </summary>
 44        public CollectionType? ViewType { get; set; }
 45
 46        /// <summary>
 47        /// Gets or sets the display parent id.
 48        /// </summary>
 49        public new Guid DisplayParentId { get; set; }
 50
 51        /// <summary>
 52        /// Gets or sets the user id.
 53        /// </summary>
 54        public Guid? UserId { get; set; }
 55
 56        /// <inheritdoc />
 57        [JsonIgnore]
 058        public CollectionType? CollectionType => ViewType;
 59
 60        /// <inheritdoc />
 61        [JsonIgnore]
 062        public override bool SupportsInheritedParentImages => false;
 63
 64        /// <inheritdoc />
 65        [JsonIgnore]
 066        public override bool SupportsPlayedStatus => false;
 67
 68        /// <inheritdoc />
 69        [JsonIgnore]
 070        public override bool SupportsPeople => false;
 71
 72        /// <inheritdoc />
 73        public override IEnumerable<Guid> GetIdsForAncestorQuery()
 74        {
 75            if (!DisplayParentId.IsEmpty())
 76            {
 77                yield return DisplayParentId;
 78            }
 79            else if (!ParentId.IsEmpty())
 80            {
 81                yield return ParentId;
 82            }
 83            else
 84            {
 85                yield return Id;
 86            }
 87        }
 88
 89        /// <inheritdoc />
 90        public override int GetChildCount(User user)
 91        {
 092            return GetChildren(user, true, null).Count;
 93        }
 94
 95        /// <inheritdoc />
 96        protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query)
 97        {
 098            var parent = this as Folder;
 99
 0100            if (!DisplayParentId.IsEmpty())
 101            {
 0102                parent = LibraryManager.GetItemById(DisplayParentId) as Folder ?? parent;
 103            }
 0104            else if (!ParentId.IsEmpty())
 105            {
 0106                parent = LibraryManager.GetItemById(ParentId) as Folder ?? parent;
 107            }
 108
 0109            return new UserViewBuilder(UserViewManager, LibraryManager, Logger, UserDataManager, TVSeriesManager)
 0110                .GetUserItems(parent, this, CollectionType, query);
 111        }
 112
 113        /// <inheritdoc />
 114        public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren, InternalItemsQuery query)
 115        {
 0116            query ??= new InternalItemsQuery(user);
 117
 0118            query.EnableTotalRecordCount = false;
 0119            var result = GetItemList(query);
 120
 0121            return result.ToList();
 122        }
 123
 124        /// <inheritdoc />
 125        public override bool CanDelete()
 126        {
 0127            return false;
 128        }
 129
 130        /// <inheritdoc />
 131        public override bool IsSaveLocalMetadataEnabled()
 132        {
 0133            return true;
 134        }
 135
 136        /// <inheritdoc />
 137        public override IReadOnlyList<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query, out int totalC
 138        {
 0139            query.SetUser(user);
 0140            query.Recursive = true;
 0141            query.EnableTotalRecordCount = false;
 0142            query.ForceDirect = true;
 0143            var data = GetItemList(query);
 0144            totalCount = data.Count;
 145
 0146            return data;
 147        }
 148
 149        /// <inheritdoc />
 150        protected override IReadOnlyList<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
 151        {
 0152            return GetChildren(user, false, null);
 153        }
 154
 155        public static bool IsUserSpecific(Folder folder)
 156        {
 0157            if (folder is not ICollectionFolder collectionFolder)
 158            {
 0159                return false;
 160            }
 161
 0162            if (folder is ISupportsUserSpecificView supportsUserSpecific
 0163                && supportsUserSpecific.EnableUserSpecificView)
 164            {
 0165                return true;
 166            }
 167
 0168            return collectionFolder.CollectionType == Jellyfin.Data.Enums.CollectionType.playlists;
 169        }
 170
 171        public static bool IsEligibleForGrouping(Folder folder)
 172        {
 0173            return folder is ICollectionFolder collectionFolder
 0174                    && IsEligibleForGrouping(collectionFolder.CollectionType);
 175        }
 176
 177        public static bool IsEligibleForGrouping(CollectionType? viewType)
 178        {
 0179            return _viewTypesEligibleForGrouping.Contains(viewType);
 180        }
 181
 182        public static bool EnableOriginalFolder(CollectionType? viewType)
 183        {
 0184            return _originalFolderViewTypes.Contains(viewType);
 185        }
 186
 187        protected override Task ValidateChildrenInternal(IProgress<double> progress, bool recursive, bool refreshChildMe
 188        {
 0189            return Task.CompletedTask;
 190        }
 191    }
 192}