lampac/Online/Controllers/Redheadsound.cs
lampac-talks f843f04fd4 chore: initial commit 154.3
Signed-off-by: lampac-talks <lampac-talks@users.noreply.github.com>
2026-01-30 16:23:09 +03:00

41 lines
1.3 KiB
C#

using Microsoft.AspNetCore.Mvc;
namespace Online.Controllers
{
public class Redheadsound : BaseOnlineController
{
public Redheadsound() : base(AppInit.conf.Redheadsound) { }
[HttpGet]
[Route("lite/redheadsound")]
async public Task<ActionResult> Index(string title, string original_title, int year, int clarification, bool rjson = false)
{
if (string.IsNullOrWhiteSpace(title) || year == 0)
return OnError();
if (await IsRequestBlocked(rch: true))
return badInitMsg;
var oninvk = new RedheadsoundInvoke
(
host,
init.corsHost(),
ongettourl => httpHydra.Get(ongettourl),
(url, data) => httpHydra.Post(url, data),
streamfile => HostStreamProxy(streamfile),
requesterror: () => proxyManager?.Refresh()
);
rhubFallback:
var cache = await InvokeCacheResult($"redheadsound:view:{title}:{year}", 30,
() => oninvk.Embed(title, year)
);
if (IsRhubFallback(cache))
goto rhubFallback;
return await ContentTpl(cache, () => oninvk.Tpl(cache.Value, title, vast: init.vast, rjson: rjson));
}
}
}