47 lines
1.3 KiB
C#
47 lines
1.3 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using System.Runtime.InteropServices;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Jellyfin.Plugin.Cinema;
|
|
|
|
/// <summary>
|
|
/// The artists controller.
|
|
/// </summary>
|
|
[Route("Cinema")]
|
|
[ApiController]
|
|
public class CinemaMediaSourceController : ControllerBase
|
|
{
|
|
private readonly CinemaMediaSourceManager _mediaManager;
|
|
|
|
public CinemaMediaSourceController(IServiceProvider svc)
|
|
{
|
|
_mediaManager = svc.GetRequiredService<CinemaMediaSourceManager>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Generates a download link using the given provider and its identifier.
|
|
/// </summary>
|
|
/// <param name="itemId">Item id.</param>
|
|
/// <response code="302">External resource redirect.</response>
|
|
/// <response code="404">Link not found.</response>
|
|
[HttpGet("{provider}/{ident}/link/{name?}")]
|
|
[ProducesResponseType(StatusCodes.Status302Found)]
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
public async Task<ActionResult> GenerateCinemaLink(
|
|
[FromRoute, Required] string provider,
|
|
[FromRoute, Required] string ident,
|
|
[FromRoute, Optional] string? name,
|
|
CancellationToken cancel)
|
|
{
|
|
try
|
|
{
|
|
return Redirect((await _mediaManager.GenerateLink(provider, ident, name, cancel)).ToString());
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return NotFound();
|
|
}
|
|
}
|
|
} |