private async void tSMi_FetchAllEpisodes_Click(object sender, EventArgs e) { try { if (SelectedSeries.SiteType != SiteType._9Anime) { MessageBox.Show("This feature only works with 9Anime.to!"); return; } var items = cBL_Episodes.Items.Cast<EpisodeInfo>(); cancelationToken.Reset(); int i = 1; int length = items.Count(); await Task.Run(() => { cancelationToken.Reset(true); Parallel.ForEach(items, (item, loopstate) => { if (cancelationToken.IsStopped) loopstate.Break(); var lang = item.GetBest().GetBest(); if (lang.HasVideo == VideoType.None) { var url = SeriesLoader.FetchUrl(lang).Result; if (!string.IsNullOrEmpty(url)) { lang.Video_URL = url; item.GetName().Wait(); } } else { item.GetName().Wait(); } downloadInfo(i, i + "/" + length, item.Name, length); i++; }); }); items.First().Season.Series.Save(); downloadInfo(); cBL_Episodes.Refresh(); } catch (Exception x) { } finally { cancelationToken.Reset(); } }
private async void button2_Click(object sender, EventArgs e) { try { if (cancelationToken.IsRunning) { cancelationToken.Stop(); } else if (cBL_Languages.SelectedItem is LanguageInfo lang) { if (lang.HasVideo == VideoType.None) { var url = await SeriesLoader.FetchUrl(lang); if (!string.IsNullOrEmpty(url)) { await lang.Hoster.Episode.GetName(); txtB_HosterUrl.Text = url; txtB_DirectUrl.Text = url; lang.Hoster.Episode.Season.Series.Save(); btn_FetchVideo.ForeColor = Color.LimeGreen; btn_FetchVideo.Text = "Play Video"; cBL_Episodes.Refresh(); cBL_Hoster.Refresh(); cBL_Languages.Refresh(); } else { MessageBox.Show("Couldn't fetch Video-URL, please try another Hoster."); } } else { if (await lang.Play(cancelationToken, downloadInfo)) { cBL_Episodes.Refresh(); } else { MessageBox.Show("Couldn't fetch Video-URL, please try another Hoster."); } } } } catch (Exception x) { MessageBox.Show(x.ToString()); } }