mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-20 10:08:04 +00:00
Some checks failed
CodeQL / Analyze (csharp) (push) Has been cancelled
OpenAPI / OpenAPI - HEAD (push) Has been cancelled
OpenAPI / OpenAPI - BASE (push) Has been cancelled
OpenAPI / OpenAPI - Difference (push) Has been cancelled
OpenAPI / OpenAPI - Publish Unstable Spec (push) Has been cancelled
OpenAPI / OpenAPI - Publish Stable Spec (push) Has been cancelled
Tests / run-tests (macos-latest) (push) Has been cancelled
Tests / run-tests (ubuntu-latest) (push) Has been cancelled
Tests / run-tests (windows-latest) (push) Has been cancelled
Project Automation / Project board (push) Has been cancelled
Merge Conflict Labeler / Labeling (push) Has been cancelled
Stale PR Check / Check PRs with merge conflicts (push) Has been cancelled
Restore weekly refresh for library folder images
Original-merge: 338b480217
Merged-by: cvium <cvium@users.noreply.github.com>
Backported-by: Bond_009 <bond.009@outlook.com>
109 lines
4.0 KiB
C#
109 lines
4.0 KiB
C#
#nullable disable
|
|
|
|
#pragma warning disable CS1591
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
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;
|
|
using MediaBrowser.Model.Querying;
|
|
|
|
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;
|
|
|
|
BaseItemKind[] includeItemTypes;
|
|
|
|
switch (viewType)
|
|
{
|
|
case CollectionType.movies:
|
|
includeItemTypes = new[] { BaseItemKind.Movie };
|
|
break;
|
|
case CollectionType.tvshows:
|
|
includeItemTypes = new[] { BaseItemKind.Series };
|
|
break;
|
|
case CollectionType.music:
|
|
includeItemTypes = new[] { BaseItemKind.MusicAlbum };
|
|
break;
|
|
case CollectionType.musicvideos:
|
|
includeItemTypes = new[] { BaseItemKind.MusicVideo };
|
|
break;
|
|
case CollectionType.books:
|
|
includeItemTypes = new[] { BaseItemKind.Book, BaseItemKind.AudioBook };
|
|
break;
|
|
case CollectionType.boxsets:
|
|
includeItemTypes = new[] { BaseItemKind.BoxSet };
|
|
break;
|
|
case CollectionType.homevideos:
|
|
case CollectionType.photos:
|
|
includeItemTypes = new[] { BaseItemKind.Video, BaseItemKind.Photo };
|
|
break;
|
|
default:
|
|
includeItemTypes = new[] { BaseItemKind.Video, BaseItemKind.Audio, BaseItemKind.Photo, BaseItemKind.Movie, BaseItemKind.Series };
|
|
break;
|
|
}
|
|
|
|
var recursive = viewType != CollectionType.playlists;
|
|
|
|
return view.GetItemList(new InternalItemsQuery
|
|
{
|
|
CollapseBoxSetItems = false,
|
|
Recursive = recursive,
|
|
DtoOptions = new DtoOptions(false),
|
|
ImageTypes = new[] { ImageType.Primary },
|
|
Limit = 8,
|
|
OrderBy = new[]
|
|
{
|
|
(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;
|
|
}
|
|
}
|
|
}
|