private async void Form1_Load(object sender, EventArgs e) { radProgressBar1.Visible = true; if (Directory.Exists(@"C:\Program Files\Google\Chrome\Application")) { Properties.Settings.Default.chromepath = @"C:\Program Files\Google\Chrome\Application\" + "chrome.exe"; } if (Directory.Exists(@"C:\Program Files (x86)\Google\Chrome\Application")) { Properties.Settings.Default.chromepath = @"C:\Program Files (x86)\Google\Chrome\Application\" + "chrome.exe"; } Properties.Settings.Default.Save(); radProgressBar1.Value1 = 5; label4.Text = "Les musiques publié sur FuviClan du : \n" + radDateTimePicker1.Text + " au " + radDateTimePicker2.Text + " \nseront ajouter a vos listes de lecture."; string[] arg = { "--window-size=1000,1400" }; if (File.Exists("cookies.json")) { DateTime modification = File.GetLastWriteTime(@"cookies.json"); var Compare = DateTime.Now.Subtract(modification); if (Compare.TotalDays > 7) { File.Delete("cookies.json"); USERLOG UL = new USERLOG(); UL.ShowDialog(); } } else { USERLOG UL = new USERLOG(); UL.ShowDialog(); } radProgressBar1.Value1 = 10; while (!File.Exists("cookies.json")) { await Task.Delay(100); } radProgressBar1.Value1 = 15; browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = Properties.Settings.Default.headless, DefaultViewport = new ViewPortOptions { Height = 1080, Width = 1400 }, Args = arg, ExecutablePath = Properties.Settings.Default.chromepath }); radProgressBar1.Value1 = 30; var page = browser.PagesAsync().Result[0]; var cookiesfile = File.ReadAllText("cookies.json"); var cookiesdata = JsonConvert.DeserializeObject <List <CookieParam> >(cookiesfile); await page.SetCookieAsync(cookiesdata[0]); radProgressBar1.Value1 = 35; await page.GoToAsync("https://www.fuvi-clan.com/"); radProgressBar1.Value1 = 45; var NbCat = await page.EvaluateFunctionAsync( "()=>document.querySelector(\"#custom_cat\").length" ); for (int i = 2; i <= Convert.ToInt32(NbCat); i++) { if (i % 2 == 0) { radProgressBar1.Value1++; } var CatName = await page.EvaluateFunctionAsync( "()=>document.querySelector(\"#custom_cat > option:nth-child(" + i + ")\").textContent" ); var CatUrl = await page.EvaluateFunctionAsync( "()=>document.querySelector(\"#custom_cat > option:nth-child(" + i + ")\").value" ); if (CatName.ToString().Contains("(")) { radCheckedListBox1.Items.Add(new ListViewDataItem { Enabled = true, Text = CatName.ToString(), Tag = CatUrl.ToString() }); } else { radCheckedListBox1.Items.Add(new ListViewDataItem { Enabled = false, Text = CatName.ToString() }); } } // Récupération listes de lectures StringBuilder sb = new StringBuilder(); await page.WaitForSelectorAsync("#menu-menu-principal > li.menu-item.menu-item-type-fuvilist.menu-item-type-fuvilist-cart.nav-item.dropdown > a > img", new WaitForSelectorOptions { Visible = true }); await page.EvaluateFunctionAsync("()=>document.querySelector(\"#menu-menu-principal > li.menu-item.menu-item-type-fuvilist.menu-item-type-fuvilist-cart.nav-item.dropdown > a > img\").click()"); await page.WaitForSelectorAsync("#btn_create_fuvilist", new WaitForSelectorOptions { Visible = true }); radProgressBar1.Value1 = 75; try { var nblist = await page.EvaluateFunctionAsync("()=>document.querySelector(\"#menu-menu-principal > li.menu-item.menu-item-type-fuvilist.menu-item-type-fuvilist-cart.nav-item.dropdown.show > ul > li > div > div.col-12.col-xl-4 > div > select\").length"); for (int l = 2; l <= Convert.ToInt32(nblist); l++) { var select_name = await page.EvaluateFunctionAsync("()=>document.querySelector(\"#menu-menu-principal > li.menu-item.menu-item-type-fuvilist.menu-item-type-fuvilist-cart.nav-item.dropdown.show > ul > li > div > div.col-12.col-xl-4 > div > select > option:nth-child(" + l + ")\").textContent"); sb.AppendLine(select_name.ToString().Trim()); } } catch { } radProgressBar1.Value1 = 90; Properties.Settings.Default.ListesLecture = sb.ToString(); Properties.Settings.Default.Save(); radProgressBar1.Value1 = 100; pictureBox1.Visible = false; await browser.CloseAsync(); radCheckedListBox1.SelectedIndex = 0; mesListesDeLecturesToolStripMenuItem.Enabled = true; radProgressBar1.Visible = false; }
private void seConnecterToolStripMenuItem_Click(object sender, EventArgs e) { USERLOG UL = new USERLOG(); UL.ShowDialog(); }