mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-06 03:26:07 +02:00
Fix docs, params, return values
This commit is contained in:
parent
3d5f89ebf9
commit
4bb1e1c292
1 changed files with 69 additions and 71 deletions
|
@ -1,6 +1,5 @@
|
||||||
#nullable enable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Emby.Dlna;
|
using Emby.Dlna;
|
||||||
|
@ -10,8 +9,6 @@ using MediaBrowser.Controller.Dlna;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
#pragma warning disable CA1801
|
|
||||||
|
|
||||||
namespace Jellyfin.Api.Controllers
|
namespace Jellyfin.Api.Controllers
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -42,37 +39,33 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get Description Xml.
|
/// Get Description Xml.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <returns>Description Xml.</returns>
|
/// <response code="200">Description xml returned.</response>
|
||||||
[HttpGet("{Uuid}/description.xml")]
|
/// <returns>An <see cref="OkResult"/> containing the description xml.</returns>
|
||||||
[HttpGet("{Uuid}/description")]
|
[HttpGet("{serverId}/description.xml")]
|
||||||
|
[HttpGet("{serverId}/description")]
|
||||||
[Produces(XMLContentType)]
|
[Produces(XMLContentType)]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public ActionResult GetDescriptionXml([FromRoute] string uuid)
|
public ActionResult GetDescriptionXml([FromRoute] string serverId)
|
||||||
{
|
{
|
||||||
var url = GetAbsoluteUri();
|
var url = GetAbsoluteUri();
|
||||||
var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase));
|
var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase));
|
||||||
var xml = _dlnaManager.GetServerDescriptionXml(Request.Headers, uuid, serverAddress);
|
var xml = _dlnaManager.GetServerDescriptionXml(Request.Headers, serverId, serverAddress);
|
||||||
|
|
||||||
// TODO GetStaticResult doesn't do anything special?
|
|
||||||
/*
|
|
||||||
var cacheLength = TimeSpan.FromDays(1);
|
|
||||||
var cacheKey = Request.Path.Value.GetMD5();
|
|
||||||
var bytes = Encoding.UTF8.GetBytes(xml);
|
|
||||||
*/
|
|
||||||
return Ok(xml);
|
return Ok(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets Dlna content directory xml.
|
/// Gets Dlna content directory xml.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <returns>Dlna content directory xml.</returns>
|
/// <response code="200">Dlna content directory returned.</response>
|
||||||
[HttpGet("{Uuid}/ContentDirectory/ContentDirectory.xml")]
|
/// <returns>An <see cref="OkResult"/> containing the dlna content directory xml.</returns>
|
||||||
[HttpGet("{Uuid}/ContentDirectory/ContentDirectory")]
|
[HttpGet("{serverId}/ContentDirectory/ContentDirectory.xml")]
|
||||||
|
[HttpGet("{serverId}/ContentDirectory/ContentDirectory")]
|
||||||
[Produces(XMLContentType)]
|
[Produces(XMLContentType)]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public ActionResult GetContentDirectory([FromRoute] string uuid)
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
||||||
|
public ActionResult GetContentDirectory([FromRoute] string serverId)
|
||||||
{
|
{
|
||||||
return Ok(_contentDirectory.GetServiceXml());
|
return Ok(_contentDirectory.GetServiceXml());
|
||||||
}
|
}
|
||||||
|
@ -80,13 +73,14 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets Dlna media receiver registrar xml.
|
/// Gets Dlna media receiver registrar xml.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <returns>Dlna media receiver registrar xml.</returns>
|
/// <returns>Dlna media receiver registrar xml.</returns>
|
||||||
[HttpGet("{Uuid}/MediaReceiverRegistrar/MediaReceiverRegistrar.xml")]
|
[HttpGet("{serverId}/MediaReceiverRegistrar/MediaReceiverRegistrar.xml")]
|
||||||
[HttpGet("{Uuid}/MediaReceiverRegistrar/MediaReceiverRegistrar")]
|
[HttpGet("{serverId}/MediaReceiverRegistrar/MediaReceiverRegistrar")]
|
||||||
[Produces(XMLContentType)]
|
[Produces(XMLContentType)]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public ActionResult GetMediaReceiverRegistrar([FromRoute] string uuid)
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
||||||
|
public ActionResult GetMediaReceiverRegistrar([FromRoute] string serverId)
|
||||||
{
|
{
|
||||||
return Ok(_mediaReceiverRegistrar.GetServiceXml());
|
return Ok(_mediaReceiverRegistrar.GetServiceXml());
|
||||||
}
|
}
|
||||||
|
@ -94,13 +88,14 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets Dlna media receiver registrar xml.
|
/// Gets Dlna media receiver registrar xml.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <returns>Dlna media receiver registrar xml.</returns>
|
/// <returns>Dlna media receiver registrar xml.</returns>
|
||||||
[HttpGet("{Uuid}/ConnectionManager/ConnectionManager.xml")]
|
[HttpGet("{serverId}/ConnectionManager/ConnectionManager.xml")]
|
||||||
[HttpGet("{Uuid}/ConnectionManager/ConnectionManager")]
|
[HttpGet("{serverId}/ConnectionManager/ConnectionManager")]
|
||||||
[Produces(XMLContentType)]
|
[Produces(XMLContentType)]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
public ActionResult GetConnectionManager([FromRoute] string uuid)
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
||||||
|
public ActionResult GetConnectionManager([FromRoute] string serverId)
|
||||||
{
|
{
|
||||||
return Ok(_connectionManager.GetServiceXml());
|
return Ok(_connectionManager.GetServiceXml());
|
||||||
}
|
}
|
||||||
|
@ -108,100 +103,103 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process a content directory control request.
|
/// Process a content directory control request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <returns>Control response.</returns>
|
/// <returns>Control response.</returns>
|
||||||
[HttpPost("{Uuid}/ContentDirectory/Control")]
|
[HttpPost("{serverId}/ContentDirectory/Control")]
|
||||||
public async Task<ActionResult<ControlResponse>> ProcessContentDirectoryControlRequest([FromRoute] string uuid)
|
public async Task<ActionResult<ControlResponse>> ProcessContentDirectoryControlRequest([FromRoute] string serverId)
|
||||||
{
|
{
|
||||||
var response = await PostAsync(uuid, Request.Body, _contentDirectory).ConfigureAwait(false);
|
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _contentDirectory).ConfigureAwait(false);
|
||||||
return Ok(response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process a connection manager control request.
|
/// Process a connection manager control request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <returns>Control response.</returns>
|
/// <returns>Control response.</returns>
|
||||||
[HttpPost("{Uuid}/ConnectionManager/Control")]
|
[HttpPost("{serverId}/ConnectionManager/Control")]
|
||||||
public async Task<ActionResult<ControlResponse>> ProcessConnectionManagerControlRequest([FromRoute] string uuid)
|
public async Task<ActionResult<ControlResponse>> ProcessConnectionManagerControlRequest([FromRoute] string serverId)
|
||||||
{
|
{
|
||||||
var response = await PostAsync(uuid, Request.Body, _connectionManager).ConfigureAwait(false);
|
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _connectionManager).ConfigureAwait(false);
|
||||||
return Ok(response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Process a media receiver registrar control request.
|
/// Process a media receiver registrar control request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <returns>Control response.</returns>
|
/// <returns>Control response.</returns>
|
||||||
[HttpPost("{Uuid}/MediaReceiverRegistrar/Control")]
|
[HttpPost("{serverId}/MediaReceiverRegistrar/Control")]
|
||||||
public async Task<ActionResult<ControlResponse>> ProcessMediaReceiverRegistrarControlRequest([FromRoute] string uuid)
|
public async Task<ActionResult<ControlResponse>> ProcessMediaReceiverRegistrarControlRequest([FromRoute] string serverId)
|
||||||
{
|
{
|
||||||
var response = await PostAsync(uuid, Request.Body, _mediaReceiverRegistrar).ConfigureAwait(false);
|
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _mediaReceiverRegistrar).ConfigureAwait(false);
|
||||||
return Ok(response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processes an event subscription request.
|
/// Processes an event subscription request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <returns>Event subscription response.</returns>
|
/// <returns>Event subscription response.</returns>
|
||||||
[HttpSubscribe("{Uuid}/MediaReceiverRegistrar/Events")]
|
[HttpSubscribe("{serverId}/MediaReceiverRegistrar/Events")]
|
||||||
[HttpUnsubscribe("{Uuid}/MediaReceiverRegistrar/Events")]
|
[HttpUnsubscribe("{serverId}/MediaReceiverRegistrar/Events")]
|
||||||
public ActionResult<EventSubscriptionResponse> ProcessMediaReceiverRegistrarEventRequest(string uuid)
|
[ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs
|
||||||
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
||||||
|
public ActionResult<EventSubscriptionResponse> ProcessMediaReceiverRegistrarEventRequest(string serverId)
|
||||||
{
|
{
|
||||||
return Ok(ProcessEventRequest(_mediaReceiverRegistrar));
|
return ProcessEventRequest(_mediaReceiverRegistrar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processes an event subscription request.
|
/// Processes an event subscription request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <returns>Event subscription response.</returns>
|
/// <returns>Event subscription response.</returns>
|
||||||
[HttpSubscribe("{Uuid}/ContentDirectory/Events")]
|
[HttpSubscribe("{serverId}/ContentDirectory/Events")]
|
||||||
[HttpUnsubscribe("{Uuid}/ContentDirectory/Events")]
|
[HttpUnsubscribe("{serverId}/ContentDirectory/Events")]
|
||||||
public ActionResult<EventSubscriptionResponse> ProcessContentDirectoryEventRequest(string uuid)
|
[ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs
|
||||||
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
||||||
|
public ActionResult<EventSubscriptionResponse> ProcessContentDirectoryEventRequest(string serverId)
|
||||||
{
|
{
|
||||||
return Ok(ProcessEventRequest(_contentDirectory));
|
return ProcessEventRequest(_contentDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processes an event subscription request.
|
/// Processes an event subscription request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <returns>Event subscription response.</returns>
|
/// <returns>Event subscription response.</returns>
|
||||||
[HttpSubscribe("{Uuid}/ConnectionManager/Events")]
|
[HttpSubscribe("{serverId}/ConnectionManager/Events")]
|
||||||
[HttpUnsubscribe("{Uuid}/ConnectionManager/Events")]
|
[HttpUnsubscribe("{serverId}/ConnectionManager/Events")]
|
||||||
public ActionResult<EventSubscriptionResponse> ProcessConnectionManagerEventRequest(string uuid)
|
[ApiExplorerSettings(IgnoreApi = true)] // Ignore in openapi docs
|
||||||
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
||||||
|
public ActionResult<EventSubscriptionResponse> ProcessConnectionManagerEventRequest(string serverId)
|
||||||
{
|
{
|
||||||
return Ok(ProcessEventRequest(_connectionManager));
|
return ProcessEventRequest(_connectionManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a server icon.
|
/// Gets a server icon.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
/// <param name="serverId">Server UUID.</param>
|
||||||
/// <param name="fileName">The icon filename.</param>
|
/// <param name="fileName">The icon filename.</param>
|
||||||
/// <returns>Icon stream.</returns>
|
/// <returns>Icon stream.</returns>
|
||||||
[HttpGet("{Uuid}/icons/{Filename}")]
|
[HttpGet("{serverId}/icons/{filename}")]
|
||||||
public ActionResult<FileStreamResult> GetIconId([FromRoute] string uuid, [FromRoute] string fileName)
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
||||||
|
public ActionResult GetIconId([FromRoute] string serverId, [FromRoute] string fileName)
|
||||||
{
|
{
|
||||||
return GetIcon(fileName);
|
return GetIconInternal(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a server icon.
|
/// Gets a server icon.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Server UUID.</param>
|
|
||||||
/// <param name="fileName">The icon filename.</param>
|
/// <param name="fileName">The icon filename.</param>
|
||||||
/// <returns>Icon stream.</returns>
|
/// <returns>Icon stream.</returns>
|
||||||
[HttpGet("icons/{Filename}")]
|
[HttpGet("icons/{filename}")]
|
||||||
public ActionResult<FileStreamResult> GetIcon([FromQuery] string uuid, [FromRoute] string fileName)
|
public ActionResult GetIcon([FromRoute] string fileName)
|
||||||
{
|
{
|
||||||
return GetIcon(fileName);
|
return GetIconInternal(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionResult<FileStreamResult> GetIcon(string fileName)
|
private ActionResult GetIconInternal(string fileName)
|
||||||
{
|
{
|
||||||
var icon = _dlnaManager.GetIcon(fileName);
|
var icon = _dlnaManager.GetIcon(fileName);
|
||||||
if (icon == null)
|
if (icon == null)
|
||||||
|
@ -213,7 +211,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
.TrimStart('.')
|
.TrimStart('.')
|
||||||
.ToLowerInvariant();
|
.ToLowerInvariant();
|
||||||
|
|
||||||
return new FileStreamResult(icon.Stream, contentType);
|
return File(icon.Stream, contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetAbsoluteUri()
|
private string GetAbsoluteUri()
|
||||||
|
@ -221,7 +219,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
return $"{Request.Scheme}://{Request.Host}{Request.Path}";
|
return $"{Request.Scheme}://{Request.Host}{Request.Path}";
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task<ControlResponse> PostAsync(string id, Stream requestStream, IUpnpService service)
|
private Task<ControlResponse> ProcessControlRequestInternalAsync(string id, Stream requestStream, IUpnpService service)
|
||||||
{
|
{
|
||||||
return service.ProcessControlRequestAsync(new ControlRequest
|
return service.ProcessControlRequestAsync(new ControlRequest
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue