private void SeriesFound() { string seriesName = seriesDriver.GetSeriesName(); string[] seasonsNames = seriesDriver.GetSeasonsNames(); Invoke((MethodInvoker) delegate { SeriesName_Label.Text = seriesName; FirstEpisodeSeason_ComboBox.Items.Clear(); FirstEpisodeSeason_ComboBox.Items.AddRange(seasonsNames); FirstEpisodeSeason_ComboBox.SelectedIndex = 0; DownloadEpisodes_RadioButton.Checked = true; EpisodesAmount_NumericUpDown.Value = 1; Download_Panel.Enabled = true; Info(""); }); }
private void DownloadEpisodes() { try { int downloaded = 0; string[] seasons = webDriver.GetSeasonsNames(); string seriesDir = Path.Combine(downloadLocation, SanitizePath(webDriver.GetSeriesName())); for (int season = seasonIndex; season < seasons.Length && downloaded < episodeAmount; season++) { string seasonNumber = seasons[season].PadLeft(2, '0'); string seasonDir = Path.Combine(seriesDir, "Season " + seasonNumber); string[] currSeasonEpisodesNames = webDriver.GetSeasonEpisodesNames(season); for (int episode = episodeIndex; episode < currSeasonEpisodesNames.Length && downloaded < episodeAmount; episode++) { string episodeNumber = currSeasonEpisodesNames[episode].PadLeft(2, '0'); episodePath = Path.Combine(seasonDir, "Episode S" + seasonNumber + "E" + episodeNumber + ".mp4"); Invoke((MethodInvoker) delegate { EpisodeNumber_Label.Text = $"S{seasonNumber} E{episodeNumber}"; DownloadLocation_Label.Text = Utils.TruncateString(seasonDir, Consts.MAX_PATH_CHARS); EpisodeLoad_ProgressBar.Value = 0; EpisodeDownload_ProgressBar.Value = 0; EpisodeLoad_Label.Text = ""; EpisodeDonwload_Label.Text = ""; }); Directory.CreateDirectory(Path.GetDirectoryName(episodePath)); DownloadEpisode(new Episode(season, episode, currSeasonEpisodesNames[episode]), episodePath); downloaded++; Invoke((MethodInvoker) delegate { Overall_ProgressBar.Value = downloaded; OverallProgress_Label.Text = Utils.GetProgressString(downloaded, episodeAmount); }); } episodeIndex = 0; } Invoke((MethodInvoker) delegate { Close(); }); } catch { } }