示例#1
0
        static bool CheckArgs(string[] args)
        {
            if (args[0].StartsWith("ytdl:"))
            {
                string        url        = args[0].Substring(5);
                frmDownloader Downloader = new frmDownloader();
                DownloadInfo  NewInfo    = new DownloadInfo();

                switch (args[1])
                {
                case "0":
                    NewInfo.Type         = DownloadType.Video;
                    NewInfo.VideoQuality = (VideoQualityType)Saved.Default.videoQuality;
                    NewInfo.DownloadURL  = url;
                    Downloader.ShowDialog();
                    break;

                case "1":
                    NewInfo.Type = DownloadType.Audio;
                    if (Downloads.Default.AudioDownloadAsVBR)
                    {
                        NewInfo.AudioVBRQuality = (AudioVBRQualityType)Saved.Default.audioQuality;
                    }
                    else
                    {
                        NewInfo.AudioCBRQuality = (AudioCBRQualityType)Saved.Default.audioQuality;
                    }
                    NewInfo.DownloadURL = url;
                    Downloader.ShowDialog();
                    break;
                }

                return(true);
            }

            return(false);
        }
        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;
            }
        }