| | | 1 | | #nullable disable |
| | | 2 | | |
| | | 3 | | #pragma warning disable CS1591 |
| | | 4 | | |
| | | 5 | | using System; |
| | | 6 | | using System.Collections.Generic; |
| | | 7 | | using System.IO; |
| | | 8 | | using Jellyfin.Api.Extensions; |
| | | 9 | | using Jellyfin.Data.Enums; |
| | | 10 | | using Jellyfin.Database.Implementations.Enums; |
| | | 11 | | using MediaBrowser.Common.Configuration; |
| | | 12 | | using MediaBrowser.Controller.Drawing; |
| | | 13 | | using MediaBrowser.Controller.Dto; |
| | | 14 | | using MediaBrowser.Controller.Entities; |
| | | 15 | | using MediaBrowser.Controller.Providers; |
| | | 16 | | using MediaBrowser.Model.Entities; |
| | | 17 | | using MediaBrowser.Model.IO; |
| | | 18 | | |
| | | 19 | | namespace Emby.Server.Implementations.Images |
| | | 20 | | { |
| | | 21 | | public class CollectionFolderImageProvider : BaseDynamicImageProvider<CollectionFolder> |
| | | 22 | | { |
| | 22 | 23 | | public CollectionFolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths |
| | | 24 | | { |
| | 22 | 25 | | } |
| | | 26 | | |
| | | 27 | | protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item) |
| | | 28 | | { |
| | 14 | 29 | | var view = (CollectionFolder)item; |
| | 14 | 30 | | var viewType = view.CollectionType; |
| | 14 | 31 | | var includeItemTypes = DtoExtensions.GetBaseItemKindsForCollectionType(viewType); |
| | 14 | 32 | | var recursive = viewType != CollectionType.playlists; |
| | | 33 | | |
| | 14 | 34 | | return view.GetItemList(new InternalItemsQuery |
| | 14 | 35 | | { |
| | 14 | 36 | | CollapseBoxSetItems = false, |
| | 14 | 37 | | Recursive = recursive, |
| | 14 | 38 | | DtoOptions = new DtoOptions(false), |
| | 14 | 39 | | ImageTypes = [ImageType.Primary], |
| | 14 | 40 | | Limit = 8, |
| | 14 | 41 | | OrderBy = [(ItemSortBy.Random, SortOrder.Ascending)], |
| | 14 | 42 | | IncludeItemTypes = includeItemTypes |
| | 14 | 43 | | }); |
| | | 44 | | } |
| | | 45 | | |
| | | 46 | | protected override bool Supports(BaseItem item) |
| | | 47 | | { |
| | 14 | 48 | | return item is CollectionFolder; |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | protected override string CreateImage(BaseItem item, IReadOnlyCollection<BaseItem> itemsWithImages, string outpu |
| | | 52 | | { |
| | 2 | 53 | | var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png"); |
| | | 54 | | |
| | 2 | 55 | | if (imageType == ImageType.Primary) |
| | | 56 | | { |
| | 2 | 57 | | if (itemsWithImages.Count == 0) |
| | | 58 | | { |
| | 2 | 59 | | return null; |
| | | 60 | | } |
| | | 61 | | |
| | 0 | 62 | | return CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540); |
| | | 63 | | } |
| | | 64 | | |
| | 0 | 65 | | return base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex); |
| | | 66 | | } |
| | | 67 | | |
| | | 68 | | protected override bool HasChangedByDate(BaseItem item, ItemImageInfo image) |
| | | 69 | | { |
| | 0 | 70 | | var age = DateTime.UtcNow - image.DateModified; |
| | 0 | 71 | | return age.TotalDays > 7; |
| | | 72 | | } |
| | | 73 | | } |
| | | 74 | | } |