using System.Collections.Generic;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Model.Entities;
namespace Jellyfin.Api.Extensions;
///
/// Dto Extensions.
///
public static class DtoExtensions
{
///
/// Gets the BaseItemKind values associated with the specified CollectionType.
///
/// The collection type to map to BaseItemKind values.
/// An array of BaseItemKind values that correspond to the collection type.
public static BaseItemKind[] GetBaseItemKindsForCollectionType(CollectionType? collectionType)
{
switch (collectionType)
{
case CollectionType.movies:
return [BaseItemKind.Movie];
case CollectionType.tvshows:
return [BaseItemKind.Series];
case CollectionType.music:
return [BaseItemKind.MusicAlbum, BaseItemKind.MusicArtist];
case CollectionType.musicvideos:
return [BaseItemKind.MusicVideo];
case CollectionType.books:
return [BaseItemKind.Book, BaseItemKind.AudioBook];
case CollectionType.boxsets:
return [BaseItemKind.BoxSet];
case CollectionType.homevideos:
case CollectionType.photos:
return [BaseItemKind.Video, BaseItemKind.Photo];
default:
return [BaseItemKind.Video, BaseItemKind.Audio, BaseItemKind.Photo, BaseItemKind.Movie, BaseItemKind.Series];
}
}
///
/// Add additional DtoOptions.
///
///
/// Converted from IHasDtoOptions.
/// Legacy order: 3.
///
/// DtoOptions object.
/// Enable images.
/// Enable user data.
/// Image type limit.
/// Enable image types.
/// Modified DtoOptions object.
internal static DtoOptions AddAdditionalDtoOptions(
this DtoOptions dtoOptions,
bool? enableImages,
bool? enableUserData,
int? imageTypeLimit,
IReadOnlyList enableImageTypes)
{
dtoOptions.EnableImages = enableImages ?? true;
if (imageTypeLimit.HasValue)
{
dtoOptions.ImageTypeLimit = imageTypeLimit.Value;
}
if (enableUserData.HasValue)
{
dtoOptions.EnableUserData = enableUserData.Value;
}
if (enableImageTypes.Count != 0)
{
dtoOptions.ImageTypes = enableImageTypes;
}
return dtoOptions;
}
}