Extend playlist creation capabilities

pull/11220/head
Shadowghost 3 months ago
parent 88b3490d17
commit f1dc1610a2

@ -85,12 +85,7 @@ namespace Emby.Server.Implementations.Playlists
{ {
foreach (var itemId in options.ItemIdList) foreach (var itemId in options.ItemIdList)
{ {
var item = _libraryManager.GetItemById(itemId); var item = _libraryManager.GetItemById(itemId) ?? throw new ArgumentException("No item exists with the supplied Id");
if (item is null)
{
throw new ArgumentException("No item exists with the supplied Id");
}
if (item.MediaType != MediaType.Unknown) if (item.MediaType != MediaType.Unknown)
{ {
options.MediaType = item.MediaType; options.MediaType = item.MediaType;
@ -139,7 +134,8 @@ namespace Emby.Server.Implementations.Playlists
Name = name, Name = name,
Path = path, Path = path,
OwnerUserId = options.UserId, OwnerUserId = options.UserId,
Shares = options.Shares ?? Array.Empty<Share>() Shares = options.Shares ?? [],
OpenAccess = options.OpenAccess ?? false
}; };
playlist.SetMediaType(options.MediaType); playlist.SetMediaType(options.MediaType);

@ -92,7 +92,9 @@ public class PlaylistsController : BaseJellyfinApiController
Name = name ?? createPlaylistRequest?.Name, Name = name ?? createPlaylistRequest?.Name,
ItemIdList = ids, ItemIdList = ids,
UserId = userId.Value, UserId = userId.Value,
MediaType = mediaType ?? createPlaylistRequest?.MediaType MediaType = mediaType ?? createPlaylistRequest?.MediaType,
Shares = createPlaylistRequest?.Shares.ToArray(),
OpenAccess = createPlaylistRequest?.OpenAccess
}).ConfigureAwait(false); }).ConfigureAwait(false);
return result; return result;

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
using Jellyfin.Extensions.Json.Converters; using Jellyfin.Extensions.Json.Converters;
using MediaBrowser.Model.Entities;
namespace Jellyfin.Api.Models.PlaylistDtos; namespace Jellyfin.Api.Models.PlaylistDtos;
@ -20,7 +21,7 @@ public class CreatePlaylistDto
/// Gets or sets item ids to add to the playlist. /// Gets or sets item ids to add to the playlist.
/// </summary> /// </summary>
[JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))] [JsonConverter(typeof(JsonCommaDelimitedArrayConverterFactory))]
public IReadOnlyList<Guid> Ids { get; set; } = Array.Empty<Guid>(); public IReadOnlyList<Guid> Ids { get; set; } = [];
/// <summary> /// <summary>
/// Gets or sets the user id. /// Gets or sets the user id.
@ -31,4 +32,14 @@ public class CreatePlaylistDto
/// Gets or sets the media type. /// Gets or sets the media type.
/// </summary> /// </summary>
public MediaType? MediaType { get; set; } public MediaType? MediaType { get; set; }
/// <summary>
/// Gets or sets the shares.
/// </summary>
public IReadOnlyList<Share> Shares { get; set; } = [];
/// <summary>
/// Gets or sets a value indicating whether open access is enabled.
/// </summary>
public bool OpenAccess { get; set; }
} }

@ -33,5 +33,10 @@ public class PlaylistCreationRequest
/// <summary> /// <summary>
/// Gets or sets the shares. /// Gets or sets the shares.
/// </summary> /// </summary>
public Share[]? Shares { get; set; } public IReadOnlyList<Share>? Shares { get; set; }
/// <summary>
/// Gets or sets a value indicating whether open access is enabled.
/// </summary>
public bool? OpenAccess { get; set; }
} }

Loading…
Cancel
Save