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 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 playlists, int total_pages)>($"BongaCams:list:{sort}:{pg}", 5, async e => { string url = BongaCamsTo.Uri(init.corsHost(), sort, pg); int total_pages = 1; List 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 ); } } }