예제 #1
0
 public static void dumpMovie_db(Bunifu.Framework.UI.BunifuCheckbox UpdateCheck, Movie movie, List <string> streams, string table_db, Bunifu.Framework.UI.BunifuCustomDataGrid dataGrid)
 {
     if (!DataExist_db(movie.id.ToString(), table_db))
     {
         //---- insertion
         Console.WriteLine("insert");
         insertMovie(movie, table_db, streams);
         if (dataGrid.InvokeRequired)
         {
             dataGrid.Invoke(new Action(() => dataGrid.Rows.Add(movie.title, "INSERTED")));
         }
     }
     else
     {
         if (UpdateCheck.Checked)
         {
             //---- update
             Console.WriteLine("update");
             UpdateMovie(streams, movie.id, table_db);
             if (dataGrid.InvokeRequired)
             {
                 dataGrid.Invoke(new Action(() => dataGrid.Rows.Add(movie.title, "UPDATED")));
             }
         }
     }
 }
예제 #2
0
        private static void dumpIntodb(Bunifu.Framework.UI.BunifuCustomDataGrid dataGrid, Anime anime)
        {
            MySqlConnection con     = new MySqlConnection("server=127.0.0.1;uid=root;pwd=;database=anime_db");
            string          idAnime = "";

            try
            {
                //---- dump anime info

                con.Open();
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection  = con;
                cmd.CommandText = $"INSERT INTO animes (Uniq,Title,Type,Status,Aired,Summary,Image) values ('{anime.Unique.Trim()}','{anime.Title.Trim()}','{anime.Type.Trim()}','{anime.Status.Trim()}','{anime.Aired.Trim()}','{anime.Summary.Trim().Replace(@"'",@"\'")}','{anime.Image}')";
                cmd.ExecuteNonQuery();

                //--------- get Anime Id_anime
                cmd.CommandText = "SELECT id_anime FROM animes ORDER BY id_anime DESC LIMIT 1";
                idAnime         = cmd.ExecuteScalar().ToString();
                //--------- dump anime genres
                foreach (string item in anime.Genres)
                {
                    cmd.CommandText = $"select id_genre from genres where genre_desc = '{item}'";
                    string idGenre = cmd.ExecuteScalar().ToString();
                    //Console.WriteLine(cmd.CommandText);
                    cmd.CommandText = $"INSERT INTO anime_genre (id_anime,id_genre) values({idAnime},{idGenre})";
                    cmd.ExecuteNonQuery();
                }
                //------- dump animes episodes
                foreach (KeyValuePair <string, List <string> > item in anime.Streams)
                {
                    cmd.CommandText = $"INSERT INTO episodes (id_anime,ep_number,streams) values ({idAnime},{item.Key},'{string.Join(",", item.Value)}')";
                    cmd.ExecuteNonQuery();
                }

                dataGrid.Invoke(new Action(() => dataGrid.Rows.Add(anime.Title, anime.Type, anime.Aired, anime.Status)));
            }
            catch (MySqlException e) {
                Console.WriteLine(e.Message);
                MySqlCommand cmd = new MySqlCommand();
                cmd.Connection  = con;
                cmd.CommandText = $"DELETE FROM animes WHERE id_anime = {idAnime}";
                cmd.ExecuteNonQuery();
                cmd.CommandText = $"DELETE FROM anime_genre WHERE id_anime = {idAnime}";
                cmd.ExecuteNonQuery();
                cmd.CommandText = $"DELETE FROM episodes WHERE id_anime = {idAnime}";
                cmd.ExecuteNonQuery();
            }
            finally
            {
                con.Close();
            }
        }
예제 #3
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);
                }
            }
        }