mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-30 03:13:17 +01:00
Added static method GetBaseItemKindsForCollectionType in ItemsController (moved from ContentFolderImageProvider to be shared) Added AudioBook to GetRepresentativeItemTypes for CollectionType.books for consistency Added GetBooks to GetUserItems for CollectionType.books which gets BaseItemKind.Book and BaseItemKind.AudioBook Move GetBaseItemKindsForCollectionType to DtoExtensions Cleaned up the missing null checks and used new collection expressions. Associate Person to Book and AudioBook for related items.
75 lines
2.6 KiB
C#
75 lines
2.6 KiB
C#
#nullable disable
|
|
|
|
#pragma warning disable CS1591
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using Jellyfin.Api.Extensions;
|
|
using Jellyfin.Data.Enums;
|
|
using Jellyfin.Database.Implementations.Enums;
|
|
using MediaBrowser.Common.Configuration;
|
|
using MediaBrowser.Controller.Drawing;
|
|
using MediaBrowser.Controller.Dto;
|
|
using MediaBrowser.Controller.Entities;
|
|
using MediaBrowser.Controller.Providers;
|
|
using MediaBrowser.Model.Entities;
|
|
using MediaBrowser.Model.IO;
|
|
|
|
namespace Emby.Server.Implementations.Images
|
|
{
|
|
public class CollectionFolderImageProvider : BaseDynamicImageProvider<CollectionFolder>
|
|
{
|
|
public CollectionFolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
|
{
|
|
}
|
|
|
|
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
|
{
|
|
var view = (CollectionFolder)item;
|
|
var viewType = view.CollectionType;
|
|
var includeItemTypes = DtoExtensions.GetBaseItemKindsForCollectionType(viewType);
|
|
var recursive = viewType != CollectionType.playlists;
|
|
|
|
return view.GetItemList(new InternalItemsQuery
|
|
{
|
|
CollapseBoxSetItems = false,
|
|
Recursive = recursive,
|
|
DtoOptions = new DtoOptions(false),
|
|
ImageTypes = [ImageType.Primary],
|
|
Limit = 8,
|
|
OrderBy = [(ItemSortBy.Random, SortOrder.Ascending)],
|
|
IncludeItemTypes = includeItemTypes
|
|
});
|
|
}
|
|
|
|
protected override bool Supports(BaseItem item)
|
|
{
|
|
return item is CollectionFolder;
|
|
}
|
|
|
|
protected override string CreateImage(BaseItem item, IReadOnlyCollection<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
|
{
|
|
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png");
|
|
|
|
if (imageType == ImageType.Primary)
|
|
{
|
|
if (itemsWithImages.Count == 0)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540);
|
|
}
|
|
|
|
return base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex);
|
|
}
|
|
|
|
protected override bool HasChangedByDate(BaseItem item, ItemImageInfo image)
|
|
{
|
|
var age = DateTime.UtcNow - image.DateModified;
|
|
return age.TotalDays > 7;
|
|
}
|
|
}
|
|
}
|