mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-11-02 02:27:17 -05:00
37 lines
766 B
C#
37 lines
766 B
C#
using System.Threading.Tasks;
|
|
using Kyoo.Controllers;
|
|
using Kyoo.Models;
|
|
using Kyoo.Models.Exceptions;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Kyoo.Api
|
|
{
|
|
[Route("api/watch")]
|
|
[ApiController]
|
|
public class WatchApi : ControllerBase
|
|
{
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
public WatchApi(ILibraryManager libraryManager)
|
|
{
|
|
_libraryManager = libraryManager;
|
|
}
|
|
|
|
[HttpGet("{slug}")]
|
|
[Authorize(Policy="Read")]
|
|
public async Task<ActionResult<WatchItem>> GetWatchItem(string slug)
|
|
{
|
|
try
|
|
{
|
|
Episode item = await _libraryManager.Get<Episode>(slug);
|
|
return await WatchItem.FromEpisode(item, _libraryManager);
|
|
}
|
|
catch (ItemNotFound)
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
}
|
|
}
|