| | 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.Data.Enums; |
| | 9 | | using Jellyfin.Database.Implementations.Enums; |
| | 10 | | using MediaBrowser.Common.Configuration; |
| | 11 | | using MediaBrowser.Controller.Drawing; |
| | 12 | | using MediaBrowser.Controller.Dto; |
| | 13 | | using MediaBrowser.Controller.Entities; |
| | 14 | | using MediaBrowser.Controller.Providers; |
| | 15 | | using MediaBrowser.Model.Entities; |
| | 16 | | using MediaBrowser.Model.IO; |
| | 17 | | using MediaBrowser.Model.Querying; |
| | 18 | |
|
| | 19 | | namespace Emby.Server.Implementations.Images |
| | 20 | | { |
| | 21 | | public class CollectionFolderImageProvider : BaseDynamicImageProvider<CollectionFolder> |
| | 22 | | { |
| 21 | 23 | | public CollectionFolderImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths |
| | 24 | | { |
| 21 | 25 | | } |
| | 26 | |
|
| | 27 | | protected override IReadOnlyList<BaseItem> GetItemsWithImages(BaseItem item) |
| | 28 | | { |
| 16 | 29 | | var view = (CollectionFolder)item; |
| 16 | 30 | | var viewType = view.CollectionType; |
| | 31 | |
|
| | 32 | | BaseItemKind[] includeItemTypes; |
| | 33 | |
|
| | 34 | | switch (viewType) |
| | 35 | | { |
| | 36 | | case CollectionType.movies: |
| 0 | 37 | | includeItemTypes = new[] { BaseItemKind.Movie }; |
| 0 | 38 | | break; |
| | 39 | | case CollectionType.tvshows: |
| 0 | 40 | | includeItemTypes = new[] { BaseItemKind.Series }; |
| 0 | 41 | | break; |
| | 42 | | case CollectionType.music: |
| 0 | 43 | | includeItemTypes = new[] { BaseItemKind.MusicAlbum }; |
| 0 | 44 | | break; |
| | 45 | | case CollectionType.musicvideos: |
| 0 | 46 | | includeItemTypes = new[] { BaseItemKind.MusicVideo }; |
| 0 | 47 | | break; |
| | 48 | | case CollectionType.books: |
| 0 | 49 | | includeItemTypes = new[] { BaseItemKind.Book, BaseItemKind.AudioBook }; |
| 0 | 50 | | break; |
| | 51 | | case CollectionType.boxsets: |
| 0 | 52 | | includeItemTypes = new[] { BaseItemKind.BoxSet }; |
| 0 | 53 | | break; |
| | 54 | | case CollectionType.homevideos: |
| | 55 | | case CollectionType.photos: |
| 0 | 56 | | includeItemTypes = new[] { BaseItemKind.Video, BaseItemKind.Photo }; |
| 0 | 57 | | break; |
| | 58 | | default: |
| 16 | 59 | | includeItemTypes = new[] { BaseItemKind.Video, BaseItemKind.Audio, BaseItemKind.Photo, BaseItemKind. |
| | 60 | | break; |
| | 61 | | } |
| | 62 | |
|
| 16 | 63 | | var recursive = viewType != CollectionType.playlists; |
| | 64 | |
|
| 16 | 65 | | return view.GetItemList(new InternalItemsQuery |
| 16 | 66 | | { |
| 16 | 67 | | CollapseBoxSetItems = false, |
| 16 | 68 | | Recursive = recursive, |
| 16 | 69 | | DtoOptions = new DtoOptions(false), |
| 16 | 70 | | ImageTypes = new[] { ImageType.Primary }, |
| 16 | 71 | | Limit = 8, |
| 16 | 72 | | OrderBy = new[] |
| 16 | 73 | | { |
| 16 | 74 | | (ItemSortBy.Random, SortOrder.Ascending) |
| 16 | 75 | | }, |
| 16 | 76 | | IncludeItemTypes = includeItemTypes |
| 16 | 77 | | }); |
| | 78 | | } |
| | 79 | |
|
| | 80 | | protected override bool Supports(BaseItem item) |
| | 81 | | { |
| 30 | 82 | | return item is CollectionFolder; |
| | 83 | | } |
| | 84 | |
|
| | 85 | | protected override string CreateImage(BaseItem item, IReadOnlyCollection<BaseItem> itemsWithImages, string outpu |
| | 86 | | { |
| 16 | 87 | | var outputPath = Path.ChangeExtension(outputPathWithoutExtension, ".png"); |
| | 88 | |
|
| 16 | 89 | | if (imageType == ImageType.Primary) |
| | 90 | | { |
| 16 | 91 | | if (itemsWithImages.Count == 0) |
| | 92 | | { |
| 16 | 93 | | return null; |
| | 94 | | } |
| | 95 | |
|
| 0 | 96 | | return CreateThumbCollage(item, itemsWithImages, outputPath, 960, 540); |
| | 97 | | } |
| | 98 | |
|
| 0 | 99 | | return base.CreateImage(item, itemsWithImages, outputPath, imageType, imageIndex); |
| | 100 | | } |
| | 101 | | } |
| | 102 | | } |