static void getTVPerPage(System.Windows.Forms.PictureBox preview, List <string> URLs, string table_db, string seasons_db, string stream_db, Bunifu.Framework.UI.BunifuCustomDataGrid dataGrid, Bunifu.Framework.UI.BunifuCheckbox UpdateCheck) { foreach (string URL in URLs) { HtmlWeb browser = new HtmlWeb(); try { Console.WriteLine(URL); HtmlDocument doc = browser.Load(URL); Regex pattern0 = new Regex(@"\(.*\)"); //Regex p = new Regex("Saison ([0-9]+)"); Regex t = new Regex("- Saison [0-9]+"); string info = doc.DocumentNode.SelectSingleNode("//h1[@id='s-title']").InnerText.Trim(); info = pattern0.Replace(info, "").Trim(); //string season = p.Match(info).Groups[1].Value; string title = t.Replace(info, "").Trim(); TV tv = Information.getTMDB_TV(Information.getTMDBId_TV(title), "fr-FR"); if (tv == null) { continue; } if (!Information.DataExist_db(tv.id.ToString(), table_db)) { Information.insertTV(tv, table_db); if (dataGrid.InvokeRequired) { dataGrid.Invoke(new Action(() => dataGrid.Rows.Add(tv.name, "INSERTED"))); } } else { if (UpdateCheck.Checked) { if (dataGrid.InvokeRequired) { dataGrid.Invoke(new Action(() => dataGrid.Rows.Add(tv.name, "UPDATED"))); } } else if (dataGrid.InvokeRequired) { dataGrid.Invoke(new Action(() => dataGrid.Rows.Add(tv.name, "SEARCHING NEW EPs"))); } } preview.ImageLocation = "https://image.tmdb.org/t/p/w300_and_h450_bestv2" + tv.poster_path; string seasonsURL = "https://french-serie.co" + doc.DocumentNode.SelectSingleNode(".//div[@class='fmeta icon-l']") .SelectSingleNode(".//strong").ParentNode.ParentNode.Attributes["href"].Value; seasonsURL = Uri.EscapeUriString(seasonsURL); //-- get seasons episodes <Season,<Episode,Streams>> Dictionary <int, Dictionary <int, List <string> > > tvData = getTVData(seasonsURL); // ---- save into db ------ Information.dumpSeasonsEpisodes_db(tv, tvData, seasons_db, stream_db, "fr-FR", UpdateCheck); } catch (Exception e) { Console.WriteLine(e.Message); } } }
static Dictionary <int, Dictionary <int, List <string> > > getTVData(string URL) { Dictionary <int, Dictionary <int, List <string> > > Data = new Dictionary <int, Dictionary <int, List <string> > >(); // GET Seasons HttpClient browser = Information.getClient(); foreach (String sURL in getSeasonsURLs(URL)) { try { HtmlDocument doc = Information.getPageData(browser, sURL); Regex p = new Regex("Saison ([0-9]+)"); Regex e = new Regex("pisode ([0-9]+)"); string info = doc.DocumentNode.SelectSingleNode(".//h1[@id='s-title']").InnerText.Trim(); string season = p.Match(info).Groups[1].Value; int SE = int.Parse(season); Console.WriteLine("Season : " + SE); HtmlNode container = doc.DocumentNode.SelectSingleNode("//div[@class='series-center']"); if (container == null) { continue; } Dictionary <int, List <string> > EPISODES = new Dictionary <int, List <string> >(); foreach (HtmlNode divParent in container.SelectNodes(".//div[@class='selink']")) { try { if (divParent.SelectSingleNode(".//span").InnerText.Contains("VOSTFR")) { continue; } string EPI = e.Match(divParent.SelectSingleNode(".//span").InnerText).Groups[1].Value; int EP = int.Parse(EPI); string realS = ""; List <string> streams = new List <string>(); foreach (HtmlNode links in divParent.SelectSingleNode(".//ul[@class='btnss']").SelectNodes(".//a")) { try { if (links.InnerText.Contains("Lecteur")) { if (!links.Attributes["href"].Value.Contains("hqq") && links.Attributes["href"].Value.Contains("http")) { realS = getRealStream(links.Attributes["href"].Value); if (!realS.Contains("google")) { streams.Add(realS); } } } } catch { } } EPISODES.Add(EP, streams); Console.WriteLine($"{SE}x{EP} --> {string.Join(" , ", streams)}"); } catch (Exception z) { Console.WriteLine(z.Message); } } Data.Add(SE, EPISODES); } catch { } } return(Data); }