/// <summary> /// Scrapes the desktop site for web info. Currently only supports the lewd URL /// </summary> /// <param name="animeurlname"></param> /// <param name="name"></param> /// <param name="attributeName"></param> /// <returns></returns> public static string RunViaDesktop(string animeUrl, string animeurlname, string name, string attributeName) { var endpoint = $"http://{VariablesClass.MasterURL}{(VariablesClass.MasterURL == VariablesClass.KissLewdURL ? "/Hentai/" : "/Anime/")}{animeurlname}/{name.Replace(" ", "-")}?id={attributeName}&s=beta"; var value = ""; PhantomJSInstance.Navigate().GoToUrl(endpoint); if (PhantomJSInstance.Title == "Are You Human") // Robot can't do this, YET! :P { AreYouHumanHelpFrm HelpFrm = new AreYouHumanHelpFrm(PhantomJSInstance); HelpFrm.ShowDialog(); } if (VariablesClass.MasterURL == VariablesClass.KissLewdURL) { PhantomJSInstance.ExecuteScript("$('#selectServer').val('openload').change();"); //PhantomJSInstance.ExecuteScript("$(\"#selectServer\").find(\"option[text=\"Beta Server\"]\").attr(\"selected\", true);"); Thread.Sleep(1000); } var xo = PhantomJSInstance.FindElementsByTagName("a").FirstOrDefault(x => x.Text.Contains("CLICK HERE")); if (xo != null) { if (VariablesClass.MasterURL == VariablesClass.KissLewdURL) { value = StaticsClass.GetOpenloadLink(xo.GetAttribute("href")); } else { value = xo.GetAttribute("href"); } } PhantomJSInstance.Navigate().GoToUrl(animeUrl); return(value); }
private async Task <string> GetGoogleLink(string attributeNumber) { _tryCount++; if (_clicked == false) { _phantomObject.Navigate().Refresh(); var runTheScript = _phantomObject.FindElementsByClassName("episode").First(x => x.GetAttribute("data-value") == attributeNumber); runTheScript.Click(); _clicked = true; } var firstpreval = _phantomObject.FindElementsByTagName("a"); var secondspreval = firstpreval.Where(x => x.Text != "").Select(x => x).ToList(); var val = secondspreval.FirstOrDefault(x => x.Text.Contains("mp4")); var alternativeSourceUrl = ""; try { alternativeSourceUrl = _phantomObject.FindElementById("mVideo").GetAttribute("src"); } catch (Exception) { } if (!string.IsNullOrWhiteSpace(alternativeSourceUrl)) { string value; if (alternativeSourceUrl.Contains("openload")) { value = StaticsClass.GetOpenloadLink(alternativeSourceUrl); } else if (alternativeSourceUrl.Contains("rapidvideo")) { value = await WebDriverClass.GetRapidVideoLink(alternativeSourceUrl); } else { value = alternativeSourceUrl; // its the google link. weird. } _phantomObject.Navigate().GoToUrl(AnimeUrl); _clicked = false; return(value); } if (val == null) { if (_tryCount <= 5) { await Task.Delay(300); return((await GetGoogleLink(attributeNumber)).Replace("&", "&"));; } MessageBox.Show("Video is unavailable, please try again later.", "Otaku Time", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); _tryCount = 0; return("no"); } _tryCount = 0; var retval = val.GetAttribute("href"); _clicked = false; return(retval); }