lampac/SISI/Controllers/BongaCams/ListController.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

63 lines
2.0 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Shared.PlaywrightCore;
namespace SISI.Controllers.BongaCams
{
public class ListController : BaseSisiController
{
public ListController() : base(AppInit.conf.BongaCams) { }
[HttpGet]
[Route("bgs")]
async public Task<ActionResult> Index(string search, string sort, int pg = 1)
{
if (!string.IsNullOrEmpty(search))
return OnError("no search", false);
if (await IsRequestBlocked(rch: true, rch_keepalive: -1))
return badInitMsg;
rhubFallback:
var cache = await InvokeCacheResult<(List<PlaylistItem> playlists, int total_pages)>($"BongaCams:list:{sort}:{pg}", 5, async e =>
{
string url = BongaCamsTo.Uri(init.corsHost(), sort, pg);
int total_pages = 1;
List<PlaylistItem> playlists = null;
if (rch?.enable == true || init.priorityBrowser == "http")
{
await httpHydra.GetSpan(url, span =>
{
playlists = BongaCamsTo.Playlist(span, out total_pages);
});
}
else
{
string html = await PlaywrightBrowser.Get(init, url, httpHeaders(init), proxy_data);
playlists = BongaCamsTo.Playlist(html, out total_pages);
}
if (playlists == null || playlists.Count == 0)
return e.Fail("playlists", refresh_proxy: true);
return e.Success((playlists, total_pages));
});
if (IsRhubFallback(cache))
goto rhubFallback;
if (!cache.IsSuccess)
return OnError(cache.ErrorMsg);
return await PlaylistResult(
cache.Value.playlists,
cache.ISingleCache,
BongaCamsTo.Menu(host, sort),
total_pages: cache.Value.total_pages
);
}
}
}