Fix some request parameters

This commit is contained in:
crobibero 2020-08-03 13:33:43 -06:00
parent 8bb510a9f6
commit 1535f363b2
7 changed files with 61 additions and 45 deletions

View File

@ -1,5 +1,4 @@
using System.Net; using System.Security.Claims;
using System.Security.Claims;
using Jellyfin.Api.Helpers; using Jellyfin.Api.Helpers;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
using MediaBrowser.Common.Net; using MediaBrowser.Common.Net;

View File

@ -249,7 +249,7 @@ namespace Jellyfin.Api.Controllers
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult UpdateMediaPath( public ActionResult UpdateMediaPath(
[FromQuery] string? name, [FromQuery] string? name,
[FromQuery] MediaPathInfo? pathInfo) [FromBody] MediaPathInfo? pathInfo)
{ {
if (string.IsNullOrWhiteSpace(name)) if (string.IsNullOrWhiteSpace(name))
{ {
@ -320,7 +320,7 @@ namespace Jellyfin.Api.Controllers
[ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(StatusCodes.Status204NoContent)]
public ActionResult UpdateLibraryOptions( public ActionResult UpdateLibraryOptions(
[FromQuery] string? id, [FromQuery] string? id,
[FromQuery] LibraryOptions? libraryOptions) [FromBody] LibraryOptions? libraryOptions)
{ {
var collectionFolder = (CollectionFolder)_libraryManager.GetItemById(id); var collectionFolder = (CollectionFolder)_libraryManager.GetItemById(id);

View File

@ -23,7 +23,6 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Dto; using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Net; using MediaBrowser.Model.Net;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;

View File

@ -7,6 +7,7 @@ using System.Text.Json;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Jellyfin.Api.Constants; using Jellyfin.Api.Constants;
using Jellyfin.Api.Models.MediaInfoDtos;
using Jellyfin.Api.Models.VideoDtos; using Jellyfin.Api.Models.VideoDtos;
using Jellyfin.Data.Entities; using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
@ -91,7 +92,7 @@ namespace Jellyfin.Api.Controllers
[ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status200OK)]
public async Task<ActionResult<PlaybackInfoResponse>> GetPlaybackInfo([FromRoute] Guid itemId, [FromQuery] Guid? userId) public async Task<ActionResult<PlaybackInfoResponse>> GetPlaybackInfo([FromRoute] Guid itemId, [FromQuery] Guid? userId)
{ {
return await GetPlaybackInfoInternal(itemId, userId, null, null).ConfigureAwait(false); return await GetPlaybackInfoInternal(itemId, userId).ConfigureAwait(false);
} }
/// <summary> /// <summary>
@ -231,8 +232,7 @@ namespace Jellyfin.Api.Controllers
/// <param name="subtitleStreamIndex">The subtitle stream index.</param> /// <param name="subtitleStreamIndex">The subtitle stream index.</param>
/// <param name="maxAudioChannels">The maximum number of audio channels.</param> /// <param name="maxAudioChannels">The maximum number of audio channels.</param>
/// <param name="itemId">The item id.</param> /// <param name="itemId">The item id.</param>
/// <param name="deviceProfile">The device profile.</param> /// <param name="openLiveStreamDto">The open live stream dto.</param>
/// <param name="directPlayProtocols">The direct play protocols. Default: <see cref="MediaProtocol.Http"/>.</param>
/// <param name="enableDirectPlay">Whether to enable direct play. Default: true.</param> /// <param name="enableDirectPlay">Whether to enable direct play. Default: true.</param>
/// <param name="enableDirectStream">Whether to enable direct stream. Default: true.</param> /// <param name="enableDirectStream">Whether to enable direct stream. Default: true.</param>
/// <response code="200">Media source opened.</response> /// <response code="200">Media source opened.</response>
@ -249,8 +249,7 @@ namespace Jellyfin.Api.Controllers
[FromQuery] int? subtitleStreamIndex, [FromQuery] int? subtitleStreamIndex,
[FromQuery] int? maxAudioChannels, [FromQuery] int? maxAudioChannels,
[FromQuery] Guid? itemId, [FromQuery] Guid? itemId,
[FromQuery] DeviceProfile? deviceProfile, [FromBody] OpenLiveStreamDto openLiveStreamDto,
[FromQuery] MediaProtocol[] directPlayProtocols,
[FromQuery] bool enableDirectPlay = true, [FromQuery] bool enableDirectPlay = true,
[FromQuery] bool enableDirectStream = true) [FromQuery] bool enableDirectStream = true)
{ {
@ -265,10 +264,10 @@ namespace Jellyfin.Api.Controllers
SubtitleStreamIndex = subtitleStreamIndex, SubtitleStreamIndex = subtitleStreamIndex,
MaxAudioChannels = maxAudioChannels, MaxAudioChannels = maxAudioChannels,
ItemId = itemId ?? Guid.Empty, ItemId = itemId ?? Guid.Empty,
DeviceProfile = deviceProfile, DeviceProfile = openLiveStreamDto?.DeviceProfile,
EnableDirectPlay = enableDirectPlay, EnableDirectPlay = enableDirectPlay,
EnableDirectStream = enableDirectStream, EnableDirectStream = enableDirectStream,
DirectPlayProtocols = directPlayProtocols ?? new[] { MediaProtocol.Http } DirectPlayProtocols = openLiveStreamDto?.DirectPlayProtocols ?? new[] { MediaProtocol.Http }
}; };
return await OpenMediaSource(request).ConfigureAwait(false); return await OpenMediaSource(request).ConfigureAwait(false);
} }

View File

@ -5,7 +5,6 @@ using System.Net;
using Jellyfin.Data.Enums; using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session; using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying; using MediaBrowser.Model.Querying;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;

View File

@ -0,0 +1,24 @@
using System.Diagnostics.CodeAnalysis;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.MediaInfo;
namespace Jellyfin.Api.Models.MediaInfoDtos
{
/// <summary>
/// Open live stream dto.
/// </summary>
public class OpenLiveStreamDto
{
/// <summary>
/// Gets or sets the device profile.
/// </summary>
public DeviceProfile? DeviceProfile { get; set; }
/// <summary>
/// Gets or sets the device play protocols.
/// </summary>
[SuppressMessage("Microsoft.Performance", "CA1819:DontReturnArrays", MessageId = "DevicePlayProtocols", Justification = "Imported from ServiceStack")]
[SuppressMessage("Microsoft.Performance", "SA1011:ClosingBracketsSpace", MessageId = "DevicePlayProtocols", Justification = "Imported from ServiceStack")]
public MediaProtocol[]? DirectPlayProtocols { get; set; }
}
}

View File

@ -12,20 +12,13 @@ namespace Jellyfin.Api.WebSocketListeners
/// </summary> /// </summary>
public class SessionInfoWebSocketListener : BasePeriodicWebSocketListener<IEnumerable<SessionInfo>, WebSocketListenerState> public class SessionInfoWebSocketListener : BasePeriodicWebSocketListener<IEnumerable<SessionInfo>, WebSocketListenerState>
{ {
/// <summary>
/// Gets the name.
/// </summary>
/// <value>The name.</value>
protected override string Name => "Sessions";
/// <summary>
/// The _kernel.
/// </summary>
private readonly ISessionManager _sessionManager; private readonly ISessionManager _sessionManager;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SessionInfoWebSocketListener"/> class. /// Initializes a new instance of the <see cref="SessionInfoWebSocketListener"/> class.
/// </summary> /// </summary>
/// <param name="logger">Instance of the <see cref="ILogger{SessionInfoWebSocketListener}"/> interface.</param>
/// <param name="sessionManager">Instance of the <see cref="ISessionManager"/> interface.</param>
public SessionInfoWebSocketListener(ILogger<SessionInfoWebSocketListener> logger, ISessionManager sessionManager) public SessionInfoWebSocketListener(ILogger<SessionInfoWebSocketListener> logger, ISessionManager sessionManager)
: base(logger) : base(logger)
{ {
@ -40,6 +33,32 @@ namespace Jellyfin.Api.WebSocketListeners
_sessionManager.SessionActivity += OnSessionManagerSessionActivity; _sessionManager.SessionActivity += OnSessionManagerSessionActivity;
} }
/// <inheritdoc />
protected override string Name => "Sessions";
/// <summary>
/// Gets the data to send.
/// </summary>
/// <returns>Task{SystemInfo}.</returns>
protected override Task<IEnumerable<SessionInfo>> GetDataToSend()
{
return Task.FromResult(_sessionManager.Sessions);
}
/// <inheritdoc />
protected override void Dispose(bool dispose)
{
_sessionManager.SessionStarted -= OnSessionManagerSessionStarted;
_sessionManager.SessionEnded -= OnSessionManagerSessionEnded;
_sessionManager.PlaybackStart -= OnSessionManagerPlaybackStart;
_sessionManager.PlaybackStopped -= OnSessionManagerPlaybackStopped;
_sessionManager.PlaybackProgress -= OnSessionManagerPlaybackProgress;
_sessionManager.CapabilitiesChanged -= OnSessionManagerCapabilitiesChanged;
_sessionManager.SessionActivity -= OnSessionManagerSessionActivity;
base.Dispose(dispose);
}
private async void OnSessionManagerSessionActivity(object sender, SessionEventArgs e) private async void OnSessionManagerSessionActivity(object sender, SessionEventArgs e)
{ {
await SendData(false).ConfigureAwait(false); await SendData(false).ConfigureAwait(false);
@ -74,28 +93,5 @@ namespace Jellyfin.Api.WebSocketListeners
{ {
await SendData(true).ConfigureAwait(false); await SendData(true).ConfigureAwait(false);
} }
/// <summary>
/// Gets the data to send.
/// </summary>
/// <returns>Task{SystemInfo}.</returns>
protected override Task<IEnumerable<SessionInfo>> GetDataToSend()
{
return Task.FromResult(_sessionManager.Sessions);
}
/// <inheritdoc />
protected override void Dispose(bool dispose)
{
_sessionManager.SessionStarted -= OnSessionManagerSessionStarted;
_sessionManager.SessionEnded -= OnSessionManagerSessionEnded;
_sessionManager.PlaybackStart -= OnSessionManagerPlaybackStart;
_sessionManager.PlaybackStopped -= OnSessionManagerPlaybackStopped;
_sessionManager.PlaybackProgress -= OnSessionManagerPlaybackProgress;
_sessionManager.CapabilitiesChanged -= OnSessionManagerCapabilitiesChanged;
_sessionManager.SessionActivity -= OnSessionManagerSessionActivity;
base.Dispose(dispose);
}
} }
} }