| | | 1 | | using System.Collections.Generic; |
| | | 2 | | using Jellyfin.Data.Enums; |
| | | 3 | | using MediaBrowser.Controller.Dto; |
| | | 4 | | using MediaBrowser.Model.Entities; |
| | | 5 | | |
| | | 6 | | namespace Jellyfin.Api.Extensions; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Dto Extensions. |
| | | 10 | | /// </summary> |
| | | 11 | | public static class DtoExtensions |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Gets the BaseItemKind values associated with the specified CollectionType. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <param name="collectionType">The collection type to map to BaseItemKind values.</param> |
| | | 17 | | /// <returns>An array of BaseItemKind values that correspond to the collection type.</returns> |
| | | 18 | | public static BaseItemKind[] GetBaseItemKindsForCollectionType(CollectionType? collectionType) |
| | | 19 | | { |
| | | 20 | | switch (collectionType) |
| | | 21 | | { |
| | | 22 | | case CollectionType.movies: |
| | 0 | 23 | | return [BaseItemKind.Movie]; |
| | | 24 | | case CollectionType.tvshows: |
| | 0 | 25 | | return [BaseItemKind.Series]; |
| | | 26 | | case CollectionType.music: |
| | 0 | 27 | | return [BaseItemKind.MusicAlbum, BaseItemKind.MusicArtist]; |
| | | 28 | | case CollectionType.musicvideos: |
| | 0 | 29 | | return [BaseItemKind.MusicVideo]; |
| | | 30 | | case CollectionType.books: |
| | 0 | 31 | | return [BaseItemKind.Book, BaseItemKind.AudioBook]; |
| | | 32 | | case CollectionType.boxsets: |
| | 0 | 33 | | return [BaseItemKind.BoxSet]; |
| | | 34 | | case CollectionType.homevideos: |
| | | 35 | | case CollectionType.photos: |
| | 0 | 36 | | return [BaseItemKind.Video, BaseItemKind.Photo]; |
| | | 37 | | case CollectionType.folders: |
| | 0 | 38 | | return []; |
| | | 39 | | default: |
| | 14 | 40 | | return [BaseItemKind.Video, BaseItemKind.Audio, BaseItemKind.Photo, BaseItemKind.Movie, BaseItemKind.Ser |
| | | 41 | | } |
| | | 42 | | } |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// Add additional DtoOptions. |
| | | 46 | | /// </summary> |
| | | 47 | | /// <remarks> |
| | | 48 | | /// Converted from IHasDtoOptions. |
| | | 49 | | /// Legacy order: 3. |
| | | 50 | | /// </remarks> |
| | | 51 | | /// <param name="dtoOptions">DtoOptions object.</param> |
| | | 52 | | /// <param name="enableImages">Enable images.</param> |
| | | 53 | | /// <param name="enableUserData">Enable user data.</param> |
| | | 54 | | /// <param name="imageTypeLimit">Image type limit.</param> |
| | | 55 | | /// <param name="enableImageTypes">Enable image types.</param> |
| | | 56 | | /// <returns>Modified DtoOptions object.</returns> |
| | | 57 | | internal static DtoOptions AddAdditionalDtoOptions( |
| | | 58 | | this DtoOptions dtoOptions, |
| | | 59 | | bool? enableImages, |
| | | 60 | | bool? enableUserData, |
| | | 61 | | int? imageTypeLimit, |
| | | 62 | | IReadOnlyList<ImageType> enableImageTypes) |
| | | 63 | | { |
| | 4 | 64 | | dtoOptions.EnableImages = enableImages ?? true; |
| | | 65 | | |
| | 4 | 66 | | if (imageTypeLimit.HasValue) |
| | | 67 | | { |
| | 0 | 68 | | dtoOptions.ImageTypeLimit = imageTypeLimit.Value; |
| | | 69 | | } |
| | | 70 | | |
| | 4 | 71 | | if (enableUserData.HasValue) |
| | | 72 | | { |
| | 0 | 73 | | dtoOptions.EnableUserData = enableUserData.Value; |
| | | 74 | | } |
| | | 75 | | |
| | 4 | 76 | | if (enableImageTypes.Count != 0) |
| | | 77 | | { |
| | 0 | 78 | | dtoOptions.ImageTypes = enableImageTypes; |
| | | 79 | | } |
| | | 80 | | |
| | 4 | 81 | | return dtoOptions; |
| | | 82 | | } |
| | | 83 | | } |