using Microsoft.AspNetCore.Mvc; using Microsoft.Playwright; using Shared.Models.Online.Settings; using Shared.PlaywrightCore; namespace Online.Controllers { public class Zetflix : BaseOnlineController { public Zetflix() : base(AppInit.conf.Zetflix) { } static string PHPSESSID = null; [HttpGet] [Route("lite/zetflix")] async public Task Index(long id, int serial, long kinopoisk_id, string title, string original_title, string t, int s = -1, bool orightml = false, bool origsource = false, bool rjson = false) { if (kinopoisk_id == 0) return OnError(); if (PlaywrightBrowser.Status == PlaywrightStatus.disabled) return OnError(); if (await IsRequestBlocked(rch: false)) return badInitMsg; string ztfhost = await goHost(init.host); string log = $"{HttpContext.Request.Path.Value}\n\nstart init\n"; var oninvk = new ZetflixInvoke ( host, ztfhost, init.hls, (url, head) => httpHydra.Get(url, addheaders: head), onstreamtofile => HostStreamProxy(onstreamtofile) //AppInit.log ); int rs = serial == 1 ? (s == -1 ? 1 : s) : s; string html = await InvokeCache($"zetfix:view:{kinopoisk_id}:{rs}:{proxyManager?.CurrentProxyIp}", 20, async () => { string uri = $"{ztfhost}/iplayer/videodb.php?kp={kinopoisk_id}" + (rs > 0 ? $"&season={rs}" : ""); var headers = HeadersModel.Init(Chromium.baseContextOptions.ExtraHTTPHeaders.ToDictionary(), ("Referer", "https://www.google.com/")); string result = string.IsNullOrEmpty(PHPSESSID) ? null : await Http.Get(uri, proxy: proxy, cookie: $"PHPSESSID={PHPSESSID}", headers: headers); if (result != null && !result.StartsWith("").Groups[1].Value; if (!string.IsNullOrEmpty(ztfhost)) { ztfhost = $"https://{ztfhost}"; hybridCache.Set(memkey, ztfhost, DateTime.Now.AddMinutes(20)); return ztfhost; } } else { hybridCache.Set(memkey, string.Empty, DateTime.Now.AddMinutes(1)); } return backhost; } } }