public override void GenerateHeaders() { whc = new WebHeaderCollection(); whc.Add("DNT", "1"); whc.Add("Sec-Fetch-Dest", "document"); whc.Add("Sec-Fetch-Site", "none"); whc.Add("Accept", "video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5"); //Get anime slug to use for api ADLUpdates.CallLogUpdate("Getting anime title and episode list from api.twist.moe"); string k = ao.term.TrimToSlash(keepSlash: false).SkipCharSequence("https://twist.moe/a/".ToCharArray()); string uri = $"https://api.twist.moe/api/anime/{k}"; wRequest = (HttpWebRequest)WebRequest.Create(uri); wRequestSet(); WebResponse wb = wRequest.GetResponse(); string decodedContent = M3U.DecryptBrotliStream(wb.GetResponseStream()); info = JsonSerializer.Deserialize <TwistMoeAnimeInfo>(decodedContent); wRequest = (HttpWebRequest)WebRequest.Create($"https://api.twist.moe/api/anime/{k}/sources"); wRequestSet(); wb = wRequest.GetResponse(); decodedContent = M3U.DecryptBrotliStream(wb.GetResponseStream()); info.episodes = JsonSerializer.Deserialize <List <Episode> >(decodedContent); }
private void GenerateTwistCache(bool exportToDisk = false) { string data = string.Empty; wRequest = (HttpWebRequest)WebRequest.Create("https://api.twist.moe/api/anime"); wRequestSet(); WebResponse wb = wRequest.GetResponse(); string decodedContent = M3U.DecryptBrotliStream(wb.GetResponseStream()); if (exportToDisk) { Byte[] bytes = Encoding.UTF8.GetBytes(decodedContent); using (FileStream fs = new FileStream($"{Directory.GetCurrentDirectory()}{Path.DirectorySeparatorChar}twistIndex.json", FileMode.Create)) fs.Write(bytes, 0, bytes.Length); } LoadTwistCache(decodedContent); }