< Summary - Jellyfin

Information
Class: MediaBrowser.Controller.Entities.UserView
Assembly: MediaBrowser.Controller
File(s): /srv/git/jellyfin/MediaBrowser.Controller/Entities/UserView.cs
Line coverage
30%
Covered lines: 15
Uncovered lines: 35
Coverable lines: 50
Total lines: 190
Line coverage: 30%
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.Entities;
 12using Jellyfin.Data.Enums;
 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).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 IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query)
 138        {
 0139            query.SetUser(user);
 0140            query.Recursive = true;
 0141            query.EnableTotalRecordCount = false;
 0142            query.ForceDirect = true;
 143
 0144            return GetItemList(query);
 145        }
 146
 147        /// <inheritdoc />
 148        protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)
 149        {
 0150            return GetChildren(user, false);
 151        }
 152
 153        public static bool IsUserSpecific(Folder folder)
 154        {
 0155            if (folder is not ICollectionFolder collectionFolder)
 156            {
 0157                return false;
 158            }
 159
 0160            if (folder is ISupportsUserSpecificView supportsUserSpecific
 0161                && supportsUserSpecific.EnableUserSpecificView)
 162            {
 0163                return true;
 164            }
 165
 0166            return collectionFolder.CollectionType == Jellyfin.Data.Enums.CollectionType.playlists;
 167        }
 168
 169        public static bool IsEligibleForGrouping(Folder folder)
 170        {
 0171            return folder is ICollectionFolder collectionFolder
 0172                    && IsEligibleForGrouping(collectionFolder.CollectionType);
 173        }
 174
 175        public static bool IsEligibleForGrouping(CollectionType? viewType)
 176        {
 0177            return _viewTypesEligibleForGrouping.Contains(viewType);
 178        }
 179
 180        public static bool EnableOriginalFolder(CollectionType? viewType)
 181        {
 0182            return _originalFolderViewTypes.Contains(viewType);
 183        }
 184
 185        protected override Task ValidateChildrenInternal(IProgress<double> progress, bool recursive, bool refreshChildMe
 186        {
 0187            return Task.CompletedTask;
 188        }
 189    }
 190}