using System;
using System.Net.Mime;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace ConfusedPolarBear.Plugin.IntroSkipper.Controllers;
///
/// Skip intro controller.
///
[Authorize]
[ApiController]
[Produces(MediaTypeNames.Application.Json)]
public class SkipIntroController : ControllerBase
{
///
/// Constructor.
///
public SkipIntroController()
{
}
///
/// Returns the timestamps of the introduction in a television episode.
///
/// ID of the episode. Required.
/// Episode contains an intro.
/// Failed to find an intro in the provided episode.
[HttpGet("Episode/{id}/IntroTimestamps")]
public ActionResult GetIntroTimestamps([FromRoute] Guid id)
{
if (!Plugin.Instance!.Intros.ContainsKey(id))
{
return NotFound();
}
var intro = Plugin.Instance!.Intros[id];
// Check that the episode was analyzed successfully.
if (!intro.Valid)
{
return NotFound();
}
return intro;
}
}