< Summary - Jellyfin

Information
Class: Emby.Server.Implementations.Images.CollectionFolderImageProvider
Assembly: Emby.Server.Implementations
File(s): /srv/git/jellyfin/Emby.Server.Implementations/Images/CollectionFolderImageProvider.cs
Line coverage
60%
Covered lines: 24
Uncovered lines: 16
Coverable lines: 40
Total lines: 102
Line coverage: 60%
Branch coverage
31%
Covered branches: 5
Total branches: 16
Branch coverage: 31.2%
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(...)100%11100%
GetItemsWithImages(...)25%251254.83%
Supports(...)100%11100%
CreateImage(...)50%5466.66%

File(s)

/srv/git/jellyfin/Emby.Server.Implementations/Images/CollectionFolderImageProvider.cs

#LineLine coverage
 1#nullable disable
 2
 3#pragma warning disable CS1591
 4
 5using System;
 6using System.Collections.Generic;
 7using System.IO;
 8using Jellyfin.Data.Enums;
 9using Jellyfin.Database.Implementations.Enums;
 10using MediaBrowser.Common.Configuration;
 11using MediaBrowser.Controller.Drawing;
 12using MediaBrowser.Controller.Dto;
 13using MediaBrowser.Controller.Entities;
 14using MediaBrowser.Controller.Providers;
 15using MediaBrowser.Model.Entities;
 16using MediaBrowser.Model.IO;
 17using MediaBrowser.Model.Querying;
 18
 19namespace Emby.Server.Implementations.Images
 20{
 21    public class CollectionFolderImageProvider : BaseDynamicImageProvider<CollectionFolder>
 22    {
 2123        public CollectionFolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths
 24        {
 2125        }
 26
 27        protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
 28        {
 1629            var view = (CollectionFolder)item;
 1630            var viewType = view.CollectionType;
 31
 32            BaseItemKind[] includeItemTypes;
 33
 34            switch (viewType)
 35            {
 36                case CollectionType.movies:
 037                    includeItemTypes = new[] { BaseItemKind.Movie };
 038                    break;
 39                case CollectionType.tvshows:
 040                    includeItemTypes = new[] { BaseItemKind.Series };
 041                    break;
 42                case CollectionType.music:
 043                    includeItemTypes = new[] { BaseItemKind.MusicAlbum };
 044                    break;
 45                case CollectionType.musicvideos:
 046                    includeItemTypes = new[] { BaseItemKind.MusicVideo };
 047                    break;
 48                case CollectionType.books:
 049                    includeItemTypes = new[] { BaseItemKind.Book, BaseItemKind.AudioBook };
 050                    break;
 51                case CollectionType.boxsets:
 052                    includeItemTypes = new[] { BaseItemKind.BoxSet };
 053                    break;
 54                case CollectionType.homevideos:
 55                case CollectionType.photos:
 056                    includeItemTypes = new[] { BaseItemKind.Video, BaseItemKind.Photo };
 057                    break;
 58                default:
 1659                    includeItemTypes = new[] { BaseItemKind.Video, BaseItemKind.Audio, BaseItemKind.Photo, BaseItemKind.
 60                    break;
 61            }
 62
 1663            var recursive = viewType != CollectionType.playlists;
 64
 1665            return view.GetItemList(new InternalItemsQuery
 1666            {
 1667                CollapseBoxSetItems = false,
 1668                Recursive = recursive,
 1669                DtoOptions = new DtoOptions(false),
 1670                ImageTypes = new[] { ImageType.Primary },
 1671                Limit = 8,
 1672                OrderBy = new[]
 1673                {
 1674                    (ItemSortBy.Random, SortOrder.Ascending)
 1675                },
 1676                IncludeItemTypes = includeItemTypes
 1677            });
 78        }
 79
 80        protected override bool Supports(BaseItem item)
 81        {
 3082            return item is CollectionFolder;
 83        }
 84
 85        protected override string CreateImage(BaseItem item, IReadOnlyCollection<BaseItem> itemsWithImages, string outpu
 86        {
 1687            var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png");
 88
 1689            if (imageType == ImageType.Primary)
 90            {
 1691                if (itemsWithImages.Count == 0)
 92                {
 1693                    return null;
 94                }
 95
 096                return CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540);
 97            }
 98
 099            return base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex);
 100        }
 101    }
 102}