mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 22:07:13 -04:00
Allow playlist to be created by query string
This commit is contained in:
parent
a56ac65449
commit
0d2106a272
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -17,6 +18,7 @@ using MediaBrowser.Model.Querying;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
|
|
||||||
namespace Jellyfin.Api.Controllers
|
namespace Jellyfin.Api.Controllers
|
||||||
{
|
{
|
||||||
@ -53,6 +55,13 @@ namespace Jellyfin.Api.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new playlist.
|
/// Creates a new playlist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// For backwards compatibility parameters can be sent via Query or Body, with Query having higher precedence.
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="name">The playlist name.</param>
|
||||||
|
/// <param name="ids">The item ids.</param>
|
||||||
|
/// <param name="userId">The user id.</param>
|
||||||
|
/// <param name="mediaType">The media type.</param>
|
||||||
/// <param name="createPlaylistRequest">The create playlist payload.</param>
|
/// <param name="createPlaylistRequest">The create playlist payload.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// A <see cref="Task" /> that represents the asynchronous operation to create a playlist.
|
/// A <see cref="Task" /> that represents the asynchronous operation to create a playlist.
|
||||||
@ -61,14 +70,23 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public async Task<ActionResult<PlaylistCreationResult>> CreatePlaylist(
|
public async Task<ActionResult<PlaylistCreationResult>> CreatePlaylist(
|
||||||
[FromBody, Required] CreatePlaylistDto createPlaylistRequest)
|
[FromQuery] string? name,
|
||||||
|
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] IReadOnlyList<Guid> ids,
|
||||||
|
[FromQuery] Guid? userId,
|
||||||
|
[FromQuery] string? mediaType,
|
||||||
|
[FromBody(EmptyBodyBehavior = EmptyBodyBehavior.Allow)] CreatePlaylistDto? createPlaylistRequest)
|
||||||
{
|
{
|
||||||
|
if (ids.Count == 0)
|
||||||
|
{
|
||||||
|
ids = createPlaylistRequest?.Ids ?? Array.Empty<Guid>();
|
||||||
|
}
|
||||||
|
|
||||||
var result = await _playlistManager.CreatePlaylist(new PlaylistCreationRequest
|
var result = await _playlistManager.CreatePlaylist(new PlaylistCreationRequest
|
||||||
{
|
{
|
||||||
Name = createPlaylistRequest.Name,
|
Name = name ?? createPlaylistRequest?.Name,
|
||||||
ItemIdList = createPlaylistRequest.Ids,
|
ItemIdList = ids,
|
||||||
UserId = createPlaylistRequest.UserId,
|
UserId = userId ?? createPlaylistRequest?.UserId ?? default,
|
||||||
MediaType = createPlaylistRequest.MediaType
|
MediaType = mediaType ?? createPlaylistRequest?.MediaType
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -24,7 +24,7 @@ namespace Jellyfin.Api.Models.PlaylistDtos
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the user id.
|
/// Gets or sets the user id.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Guid UserId { get; set; }
|
public Guid? UserId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the media type.
|
/// Gets or sets the media type.
|
||||||
|
Loading…
Reference in New Issue
Block a user