Esempio n. 1
0
        private void ReloadEpisodesList()
        {
            int seasonIndex = 0;

            Invoke((MethodInvoker) delegate
            {
                seasonIndex = FirstEpisodeSeason_ComboBox.SelectedIndex;
            });
            string[] episodesNames = seriesDriver.GetSeasonEpisodesNames(seasonIndex);
            Invoke((MethodInvoker) delegate
            {
                FirstEpisodeEpisode_ComboBox.Items.Clear();
                FirstEpisodeEpisode_ComboBox.Items.AddRange(episodesNames);
                FirstEpisodeEpisode_ComboBox.SelectedIndex = 0;
            });
        }
 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
     {
     }
 }