2021-05-20 12:28:18 -07:00
|
|
|
#nullable disable
|
|
|
|
|
2020-05-29 02:28:19 -07:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 12:54:44 -07:00
|
|
|
using System;
|
2015-07-26 22:03:34 -07:00
|
|
|
using System.Collections.Generic;
|
2015-10-25 22:29:32 -07:00
|
|
|
using System.IO;
|
2020-06-30 18:44:41 -07:00
|
|
|
using Jellyfin.Data.Enums;
|
2019-01-13 12:23:38 -07:00
|
|
|
using MediaBrowser.Common.Configuration;
|
|
|
|
using MediaBrowser.Controller.Drawing;
|
2017-05-21 00:25:49 -07:00
|
|
|
using MediaBrowser.Controller.Dto;
|
2019-01-13 12:23:38 -07:00
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
using MediaBrowser.Model.IO;
|
2016-09-05 13:07:36 -07:00
|
|
|
using MediaBrowser.Model.Querying;
|
2015-07-26 22:03:34 -07:00
|
|
|
|
2019-12-13 23:27:03 -07:00
|
|
|
namespace Emby.Server.Implementations.Images
|
2015-07-26 22:03:34 -07:00
|
|
|
{
|
|
|
|
public class CollectionFolderImageProvider : BaseDynamicImageProvider<CollectionFolder>
|
|
|
|
{
|
|
|
|
public CollectionFolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths, IImageProcessor imageProcessor) : base(fileSystem, providerManager, applicationPaths, imageProcessor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-03-07 07:54:30 -07:00
|
|
|
protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item)
|
2015-07-26 22:03:34 -07:00
|
|
|
{
|
|
|
|
var view = (CollectionFolder)item;
|
2018-09-12 10:26:21 -07:00
|
|
|
var viewType = view.CollectionType;
|
2015-07-26 22:03:34 -07:00
|
|
|
|
2021-12-11 19:31:30 -07:00
|
|
|
BaseItemKind[] includeItemTypes;
|
2015-07-26 22:03:34 -07:00
|
|
|
|
2021-08-28 15:32:50 -07:00
|
|
|
if (string.Equals(viewType, CollectionType.Movies, StringComparison.Ordinal))
|
2015-07-26 22:03:34 -07:00
|
|
|
{
|
2021-12-11 19:31:30 -07:00
|
|
|
includeItemTypes = new[] { BaseItemKind.Movie };
|
2018-09-12 10:26:21 -07:00
|
|
|
}
|
2021-08-28 15:32:50 -07:00
|
|
|
else if (string.Equals(viewType, CollectionType.TvShows, StringComparison.Ordinal))
|
2015-07-26 22:03:34 -07:00
|
|
|
{
|
2021-12-11 19:31:30 -07:00
|
|
|
includeItemTypes = new[] { BaseItemKind.Series };
|
2018-09-12 10:26:21 -07:00
|
|
|
}
|
2021-08-28 15:32:50 -07:00
|
|
|
else if (string.Equals(viewType, CollectionType.Music, StringComparison.Ordinal))
|
2015-07-26 22:03:34 -07:00
|
|
|
{
|
2021-12-11 19:31:30 -07:00
|
|
|
includeItemTypes = new[] { BaseItemKind.MusicAlbum };
|
2018-09-12 10:26:21 -07:00
|
|
|
}
|
2022-01-18 18:46:03 -07:00
|
|
|
else if (string.Equals(viewType, CollectionType.MusicVideos, StringComparison.Ordinal))
|
|
|
|
{
|
|
|
|
includeItemTypes = new[] { BaseItemKind.MusicVideo };
|
|
|
|
}
|
2021-08-28 15:32:50 -07:00
|
|
|
else if (string.Equals(viewType, CollectionType.Books, StringComparison.Ordinal))
|
2018-09-12 10:26:21 -07:00
|
|
|
{
|
2021-12-11 19:31:30 -07:00
|
|
|
includeItemTypes = new[] { BaseItemKind.Book, BaseItemKind.AudioBook };
|
2018-09-12 10:26:21 -07:00
|
|
|
}
|
2021-08-28 15:32:50 -07:00
|
|
|
else if (string.Equals(viewType, CollectionType.BoxSets, StringComparison.Ordinal))
|
2018-09-12 10:26:21 -07:00
|
|
|
{
|
2021-12-11 19:31:30 -07:00
|
|
|
includeItemTypes = new[] { BaseItemKind.BoxSet };
|
2018-09-12 10:26:21 -07:00
|
|
|
}
|
2021-08-28 15:32:50 -07:00
|
|
|
else if (string.Equals(viewType, CollectionType.HomeVideos, StringComparison.Ordinal) || string.Equals(viewType, CollectionType.Photos, StringComparison.Ordinal))
|
2018-09-12 10:26:21 -07:00
|
|
|
{
|
2021-12-11 19:31:30 -07:00
|
|
|
includeItemTypes = new[] { BaseItemKind.Video, BaseItemKind.Photo };
|
2018-09-12 10:26:21 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-11 19:31:30 -07:00
|
|
|
includeItemTypes = new[] { BaseItemKind.Video, BaseItemKind.Audio, BaseItemKind.Photo, BaseItemKind.Movie, BaseItemKind.Series };
|
2015-07-26 22:03:34 -07:00
|
|
|
}
|
|
|
|
|
2019-03-07 07:54:30 -07:00
|
|
|
var recursive = !string.Equals(CollectionType.Playlists, viewType, StringComparison.OrdinalIgnoreCase);
|
2016-09-05 13:07:36 -07:00
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
return view.GetItemList(new InternalItemsQuery
|
2016-09-05 13:07:36 -07:00
|
|
|
{
|
2018-09-12 10:26:21 -07:00
|
|
|
CollapseBoxSetItems = false,
|
2016-09-05 13:07:36 -07:00
|
|
|
Recursive = recursive,
|
2018-09-12 10:26:21 -07:00
|
|
|
DtoOptions = new DtoOptions(false),
|
|
|
|
ImageTypes = new ImageType[] { ImageType.Primary },
|
|
|
|
Limit = 8,
|
2021-12-24 14:18:24 -07:00
|
|
|
OrderBy = new[]
|
2018-09-12 10:26:21 -07:00
|
|
|
{
|
2021-12-24 14:18:24 -07:00
|
|
|
(ItemSortBy.Random, SortOrder.Ascending)
|
2018-09-12 10:26:21 -07:00
|
|
|
},
|
|
|
|
IncludeItemTypes = includeItemTypes
|
2019-03-07 07:54:30 -07:00
|
|
|
});
|
2016-09-05 13:07:36 -07:00
|
|
|
}
|
|
|
|
|
2018-09-12 10:26:21 -07:00
|
|
|
protected override bool Supports(BaseItem item)
|
2016-09-05 13:07:36 -07:00
|
|
|
{
|
2018-09-12 10:26:21 -07:00
|
|
|
return item is CollectionFolder;
|
2016-09-05 13:07:36 -07:00
|
|
|
}
|
|
|
|
|
2019-03-07 07:54:30 -07:00
|
|
|
protected override string CreateImage(BaseItem item, IReadOnlyCollection<BaseItem> itemsWithImages, string outputPathWithoutExtension, ImageType imageType, int imageIndex)
|
2016-09-05 13:07:36 -07:00
|
|
|
{
|
|
|
|
var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png");
|
|
|
|
|
|
|
|
if (imageType == ImageType.Primary)
|
|
|
|
{
|
|
|
|
if (itemsWithImages.Count == 0)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-05-19 10:09:37 -07:00
|
|
|
return CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540);
|
2016-09-05 13:07:36 -07:00
|
|
|
}
|
|
|
|
|
2017-05-19 10:09:37 -07:00
|
|
|
return base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex);
|
2016-09-05 13:07:36 -07:00
|
|
|
}
|
|
|
|
}
|
2015-07-26 22:03:34 -07:00
|
|
|
}
|