mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-15 22:41:28 +00:00
Add SceneSearchController.cs
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using MediaBrowser.Common.Api;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Jellyfin.Plugin.SceneSearch.Api;
|
||||
|
||||
[ApiController]
|
||||
[Authorize(Policy = Policies.RequiresElevation)]
|
||||
[Route("Plugins/SceneSearch")]
|
||||
[Produces("application/json")]
|
||||
public sealed class SceneSearchController : ControllerBase
|
||||
{
|
||||
private readonly SceneSearchClient _client;
|
||||
|
||||
public SceneSearchController(SceneSearchClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
[HttpGet("Libraries")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<SceneSearchLibraryListResponse>> Libraries()
|
||||
{
|
||||
return Ok(await _client.GetLibrariesAsync(HttpContext.RequestAborted).ConfigureAwait(false));
|
||||
}
|
||||
|
||||
[HttpPost("Index")]
|
||||
[ProducesResponseType(StatusCodes.Status202Accepted)]
|
||||
public async Task<ActionResult<SceneSearchIndexStatus>> Index([FromBody] SceneSearchIndexRequest request)
|
||||
{
|
||||
if (request.LibraryIds.Count == 0)
|
||||
{
|
||||
return BadRequest("Select at least one library.");
|
||||
}
|
||||
|
||||
var result = await _client.StartIndexAsync(request, HttpContext.RequestAborted).ConfigureAwait(false);
|
||||
return Accepted(result);
|
||||
}
|
||||
|
||||
[HttpGet("IndexStatus")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ActionResult<SceneSearchIndexStatus>> IndexStatus()
|
||||
{
|
||||
return Ok(await _client.GetIndexStatusAsync(HttpContext.RequestAborted).ConfigureAwait(false));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user