mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-31 12:14:46 -04:00
37 lines
827 B
C#
37 lines
827 B
C#
using System.Threading.Tasks;
|
|
using Kyoo.Abstractions.Controllers;
|
|
using Kyoo.Abstractions.Models;
|
|
using Kyoo.Abstractions.Models.Exceptions;
|
|
using Kyoo.Abstractions.Models.Permissions;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Kyoo.Core.Api
|
|
{
|
|
[Route("api/watch")]
|
|
[ApiController]
|
|
public class WatchApi : ControllerBase
|
|
{
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
public WatchApi(ILibraryManager libraryManager)
|
|
{
|
|
_libraryManager = libraryManager;
|
|
}
|
|
|
|
[HttpGet("{slug}")]
|
|
[Permission("video", Kind.Read)]
|
|
public async Task<ActionResult<WatchItem>> GetWatchItem(string slug)
|
|
{
|
|
try
|
|
{
|
|
Episode item = await _libraryManager.Get<Episode>(slug);
|
|
return await WatchItem.FromEpisode(item, _libraryManager);
|
|
}
|
|
catch (ItemNotFoundException)
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
}
|
|
}
|