check if episodes exists and update function docs
This commit is contained in:
parent
3117db57c5
commit
71f1148f07
@ -54,11 +54,19 @@ public class SkipIntroController : ControllerBase
|
|||||||
/// <param name="id">Episode ID to update timestamps for.</param>
|
/// <param name="id">Episode ID to update timestamps for.</param>
|
||||||
/// <param name="timestamps">New timestamps Introduction/Credits start and end times.</param>
|
/// <param name="timestamps">New timestamps Introduction/Credits start and end times.</param>
|
||||||
/// <response code="204">New timestamps saved.</response>
|
/// <response code="204">New timestamps saved.</response>
|
||||||
|
/// <response code="404">Given ID is not an Episode.</response>
|
||||||
/// <returns>No content.</returns>
|
/// <returns>No content.</returns>
|
||||||
[Authorize(Policy = Policies.RequiresElevation)]
|
[Authorize(Policy = Policies.RequiresElevation)]
|
||||||
[HttpPost("Episode/{Id}/Timestamps")]
|
[HttpPost("Episode/{Id}/Timestamps")]
|
||||||
public ActionResult UpdateTimestamps([FromRoute] Guid id, [FromBody] TimeStamps timestamps)
|
public ActionResult UpdateTimestamps([FromRoute] Guid id, [FromBody] TimeStamps timestamps)
|
||||||
{
|
{
|
||||||
|
// only update existing episodes
|
||||||
|
var rawItem = Plugin.Instance!.GetItem(id);
|
||||||
|
if (rawItem == null || rawItem is not Episode episode)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
|
|
||||||
if (timestamps?.Introduction.IntroEnd > 0.0)
|
if (timestamps?.Introduction.IntroEnd > 0.0)
|
||||||
{
|
{
|
||||||
var tr = new TimeRange(timestamps.Introduction.IntroStart, timestamps.Introduction.IntroEnd);
|
var tr = new TimeRange(timestamps.Introduction.IntroStart, timestamps.Introduction.IntroEnd);
|
||||||
@ -80,7 +88,8 @@ public class SkipIntroController : ControllerBase
|
|||||||
/// Gets the timestamps for the provided episode.
|
/// Gets the timestamps for the provided episode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">Episode ID.</param>
|
/// <param name="id">Episode ID.</param>
|
||||||
/// <response code="204">Sucess.</response>
|
/// <response code="200">Sucess.</response>
|
||||||
|
/// <response code="404">Given ID is not an Episode.</response>
|
||||||
/// <returns>Episode Timestamps.</returns>
|
/// <returns>Episode Timestamps.</returns>
|
||||||
[HttpGet("Episode/{Id}/Timestamps")]
|
[HttpGet("Episode/{Id}/Timestamps")]
|
||||||
[ActionName("UpdateTimestamps")]
|
[ActionName("UpdateTimestamps")]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user