예제 #1
0
        private void btnBatchDownloadStartStopExit_Click(object sender, EventArgs e)
        {
            if (Program.IsDebug)
            {
                Batch.Default.SelectedType = cbBatchDownloadType.SelectedIndex;
                if (cbBatchDownloadType.SelectedIndex == 0)
                {
                    Batch.Default.DownloadVideoSound   = chkBatchDownloaderSoundVBR.Checked;
                    Batch.Default.SelectedVideoQuality = cbBatchQuality.SelectedIndex;
                    Batch.Default.SelectedVideoFormat  = cbBatchFormat.SelectedIndex;
                }
                else if (cbBatchDownloadType.SelectedIndex == 1)
                {
                    if (chkBatchDownloaderSoundVBR.Checked)
                    {
                        Batch.Default.DownloadAudioVBR        = true;
                        Batch.Default.SelectedAudioQualityVBR = cbBatchQuality.SelectedIndex;
                    }
                    else
                    {
                        Batch.Default.DownloadAudioVBR     = false;
                        Batch.Default.SelectedAudioQuality = cbBatchQuality.SelectedIndex;
                    }
                    Batch.Default.SelectedAudioFormat = cbBatchFormat.SelectedIndex;
                }
                else if (cbBatchDownloadType.SelectedIndex == 2)
                {
                    Batch.Default.CustomArguments = txtBatchDownloadVideoSpecificArgument.Text;
                }
                if (!Program.IsPortable)
                {
                    Batch.Default.Save();
                }
            }

            if (DownloadUrls.Count == 0)
            {
                return;
            }
            if (InProgress)
            {
                Downloader.Dispose();
            }
            else if (lvBatchDownloadQueue.Items.Count > 0)
            {
                btnBatchDownloadRemoveSelected.Enabled = false;
                btnBatchDownloadStartStopExit.Text     = lang.btnBatchDownloadStop;
                InProgress = true;
                string BatchTime = "\\# Batch Downloads #" + BatchDownloader.CurrentTime();
                for (int i = 0; i < DownloadUrls.Count; i++)
                {
                    CurrentItem = i;
                    Downloader  = new frmDownloader();
                    Downloader.BatchDownload = true;
                    Downloader.BatchTime    += BatchTime;
                    Downloader.DownloadUrl   = DownloadUrls[i];
                    Downloader.DownloadPath  = Downloads.Default.downloadPath;
                    if (DownloadTypes[i] != 2)
                    {
                        Downloader.DownloadQuality = DownloadQuality[i];
                        Downloader.DownloadFormat  = DownloadFormat[i];
                    }
                    switch (DownloadTypes[i])
                    {
                    case 0:
                        Downloader.DownloadVideoAudio = DownloadSoundVBR[i];
                        Downloader.DownloadType       = 0;
                        break;

                    case 1:
                        Downloader.DownloadType = 1;
                        Downloader.UseVBR       = DownloadSoundVBR[i];
                        break;

                    case 2:
                        Downloader.DownloadArguments = DownloadArgs[i];
                        Downloader.DownloadType      = 2;
                        break;

                    default:
                        continue;
                    }
                    lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Downloading;

                    bool AbortDownload = false;
                    sbBatchDownloader.Text = lang.sbBatchDownloaderDownloading;
                    switch (Downloader.ShowDialog())
                    {
                    case System.Windows.Forms.DialogResult.Yes:
                        lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Finished;
                        break;

                    case System.Windows.Forms.DialogResult.No:
                        lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Errored;
                        break;

                    case System.Windows.Forms.DialogResult.Abort:
                        lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Waiting;
                        break;

                    case System.Windows.Forms.DialogResult.Ignore:
                        lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Waiting;
                        AbortDownload = true;
                        break;

                    default:
                        lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Finished;
                        break;
                    }
                    if (AbortDownload)
                    {
                        break;
                    }
                }
                InProgress = false;
                System.Media.SystemSounds.Exclamation.Play();
                sbBatchDownloader.Text             = lang.sbBatchDownloaderFinished;
                btnBatchDownloadStartStopExit.Text = lang.btnBatchDownloadStart;
            }
        }
예제 #2
0
        private void StartDownload()
        {
            if (string.IsNullOrEmpty(txtUrl.Text))
            {
                return;
            }
            frmDownloader Downloader = new frmDownloader();

            if (rbVideo.Checked)
            {
                Downloader.DownloadPath       = Downloads.Default.downloadPath;
                Downloader.DownloadQuality    = cbQuality.SelectedIndex;
                Downloader.DownloadFormat     = cbFormat.SelectedIndex;
                Downloader.DownloadType       = 0;
                Downloader.Set60FPS           = cbQuality.GetItemText(cbQuality.SelectedItem).EndsWith("p60");
                Downloader.DownloadVideoAudio = chkDownloadSound.Checked;
                Downloader.DownloadUrl        = txtUrl.Text;
                Downloader.Show();
                Saved.Default.downloadType           = 0;
                Saved.Default.videoQuality           = cbQuality.SelectedIndex;
                Saved.Default.VideoFormat            = cbFormat.SelectedIndex;
                Downloads.Default.VideoDownloadSound = chkDownloadSound.Checked;
            }
            else if (rbAudio.Checked)
            {
                Downloader.DownloadType    = 1;
                Downloader.DownloadPath    = Downloads.Default.downloadPath;
                Downloader.DownloadQuality = cbQuality.SelectedIndex;
                Downloader.UseVBR          = chkDownloadSound.Checked;
                Downloader.DownloadFormat  = cbFormat.SelectedIndex;
                Downloader.DownloadUrl     = txtUrl.Text;
                Downloader.Show();
                Saved.Default.downloadType           = 1;
                Saved.Default.audioQuality           = cbQuality.SelectedIndex;
                Saved.Default.AudioFormat            = cbFormat.SelectedIndex;
                Downloads.Default.AudioDownloadAsVBR = chkDownloadSound.Checked;
            }
            else if (rbCustom.Checked)
            {
                Downloader.DownloadType      = 2;
                Downloader.DownloadArguments = txtArgs.Text;
                Downloader.DownloadPath      = Downloads.Default.downloadPath;
                Downloader.DownloadQuality   = -1;
                Downloader.DownloadUrl       = txtUrl.Text;
                Downloader.Show();
                Saved.Default.downloadType = 2;
                Saved.Default.downloadArgs = txtArgs.Text;
            }
            else
            {
                Downloader.Dispose();
                try {
                    throw new Exception("Video, Audio, or Custom was not selected in the form, please select an actual download option to proceed.");
                }
                catch (Exception ex) {
                    ErrorLog.ReportException(ex);
                }
            }

            if (Downloads.Default.SaveFormatQuality && !Program.IsPortable)
            {
                Saved.Default.Save();
            }

            if (General.Default.ClearURLOnDownload)
            {
                txtUrl.Clear();
            }
            if (General.Default.ClearClipboardOnDownload)
            {
                Clipboard.Clear();
            }

            if (!Program.IsPortable)
            {
                Downloads.Default.Save();
            }
        }
        private void btnBatchDownloadStartStopExit_Click(object sender, EventArgs e)
        {
            if (DownloadUrls.Count == 0)
            {
                return;
            }
            if (InProgress)
            {
                Downloader.Dispose();
            }
            else if (lvBatchDownloadQueue.Items.Count > 0)
            {
                btnBatchDownloadRemoveSelected.Enabled = false;
                btnBatchDownloadStartStopExit.Text     = lang.btnBatchDownloadStop;
                InProgress = true;
                string BatchTime = BatchDownloader.CurrentTime();
                for (int i = 0; i < DownloadUrls.Count; i++)
                {
                    CurrentItem           = i;
                    Downloader            = new frmDownloader();
                    NewInfo               = new DownloadInfo();
                    NewInfo.BatchDownload = true;
                    NewInfo.BatchTime     = BatchTime;
                    NewInfo.DownloadURL   = DownloadUrls[i];
                    switch (DownloadTypes[i])
                    {
                    case 0:
                        NewInfo.Type               = DownloadType.Video;
                        NewInfo.VideoQuality       = (VideoQualityType)DownloadQuality[i];
                        NewInfo.VideoFormat        = (VideoFormatType)DownloadFormat[i];
                        NewInfo.SkipAudioForVideos = !DownloadSoundVBR[i];
                        break;

                    case 1:
                        NewInfo.Type = DownloadType.Audio;
                        if (DownloadSoundVBR[i])
                        {
                            NewInfo.UseVBR          = true;
                            NewInfo.AudioVBRQuality = (AudioVBRQualityType)DownloadQuality[i];
                        }
                        else
                        {
                            NewInfo.UseVBR          = false;
                            NewInfo.AudioCBRQuality = (AudioCBRQualityType)DownloadQuality[i];
                        }
                        NewInfo.AudioFormat = (AudioFormatType)DownloadFormat[i];
                        break;

                    case 2:
                        NewInfo.Type = DownloadType.Custom;
                        NewInfo.DownloadArguments = DownloadArgs[i];
                        break;

                    default:
                        continue;
                    }
                    lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Downloading;

                    bool AbortDownload = false;
                    sbBatchDownloader.Text = lang.sbBatchDownloaderDownloading;
                    switch (Downloader.ShowDialog())
                    {
                    case System.Windows.Forms.DialogResult.Yes:
                        lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Finished;
                        break;

                    case System.Windows.Forms.DialogResult.No:
                        lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Errored;
                        break;

                    case System.Windows.Forms.DialogResult.Abort:
                        lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Waiting;
                        break;

                    case System.Windows.Forms.DialogResult.Ignore:
                        lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Waiting;
                        AbortDownload = true;
                        break;

                    default:
                        lvBatchDownloadQueue.Items[i].ImageIndex = (int)BatchDownloader.ConversionIcon.Finished;
                        break;
                    }
                    if (AbortDownload)
                    {
                        break;
                    }
                }
                InProgress = false;
                System.Media.SystemSounds.Exclamation.Play();
                sbBatchDownloader.Text             = lang.sbBatchDownloaderFinished;
                btnBatchDownloadStartStopExit.Text = lang.btnBatchDownloadStart;
            }
        }