示例#1
0
 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(@"\(.*\)");
             string       title    = doc.DocumentNode.SelectSingleNode("//h2[@class='heading']").InnerText.Trim();
             title = pattern0.Replace(title, "").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(title, "UPDATED")));
             }
             preview.ImageLocation = "https://image.tmdb.org/t/p/w300_and_h450_bestv2" + tv.poster_path;
             //-- get seasons episodes <Season,<Episode,Streams>>
             Dictionary <int, Dictionary <int, List <string> > > tvData = getTVData(URL);
             // ---- save into db ------
             Information.dumpSeasonsEpisodes_db(tv, tvData, seasons_db, stream_db, "fr-FR", UpdateCheck);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     }
 }
        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);
                }
            }
        }