Exemplo n.º 1
0
        private void cmTrayDownloadCustomTxt_Click(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsText())
            {
                return;
            }

            if (!System.IO.File.Exists(Environment.CurrentDirectory + "\\args.txt"))
            {
                MessageBox.Show("args.txt does not exist, create it and put in arguments to use this command");
                return;
            }
            else if (string.IsNullOrEmpty(System.IO.File.ReadAllText(Environment.CurrentDirectory + "\\args.txt")))
            {
                MessageBox.Show("args.txt is empty, save arguments to the file to use this command");
                return;
            }
            else
            {
                frmDownloader Downloader = new frmDownloader();
                Downloader.DownloadArguments = System.IO.File.ReadAllText(Environment.CurrentDirectory + "\\args.txt");
                Downloader.DownloadPath      = Downloads.Default.downloadPath;
                Downloader.DownloadQuality   = -1;
                Downloader.DownloadType      = 2;
                Downloader.DownloadUrl       = Clipboard.GetText();
                Downloader.Show();
            }
        }
Exemplo n.º 2
0
        private void cmTrayDownloadBestAudio_Click(object sender, EventArgs e)
        {
            frmDownloader Downloader = new frmDownloader();

            Downloader.DownloadPath    = Downloads.Default.downloadPath;
            Downloader.DownloadQuality = Saved.Default.audioQuality;
            Downloader.DownloadType    = 1;
            Downloader.DownloadUrl     = Clipboard.GetText();
            Downloader.Show();
        }
Exemplo n.º 3
0
        private void cmTrayDownloadBestVideo_Click(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsText())
            {
                return;
            }
            frmDownloader Downloader = new frmDownloader();

            Downloader.DownloadPath    = Downloads.Default.downloadPath;
            Downloader.DownloadQuality = Saved.Default.videoQuality;
            Downloader.DownloadType    = 0;
            Downloader.DownloadUrl     = Clipboard.GetText();
            Downloader.Show();
        }
Exemplo n.º 4
0
        private void btnDebugDownloadArgs_Click(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsText())
            {
                return;
            }
            frmDownloader Downloader = new frmDownloader();

            Downloader.DownloadPath    = Downloads.Default.downloadPath;
            Downloader.DownloadQuality = Saved.Default.videoQuality;
            Downloader.DownloadType    = 0;
            Downloader.DownloadUrl     = Clipboard.GetText();
            Downloader.Debugging       = true;
            Downloader.BatchDownload   = true;
            Downloader.Show();
        }
Exemplo n.º 5
0
 private void cmTrayDownloadCustomSettings_Click(object sender, EventArgs e)
 {
     if (!Clipboard.ContainsText())
     {
         return;
     }
     if (string.IsNullOrEmpty(Saved.Default.downloadArgs))
     {
         MessageBox.Show("No arguments are saved in the application settings, save arguments to the settings to use this command");
         return;
     }
     else
     {
         frmDownloader Downloader = new frmDownloader();
         Downloader.DownloadArguments = Saved.Default.downloadArgs;
         Downloader.DownloadPath      = Downloads.Default.downloadPath;
         Downloader.DownloadQuality   = -1;
         Downloader.DownloadType      = 2;
         Downloader.DownloadUrl       = Clipboard.GetText();
         Downloader.Show();
     }
 }
Exemplo n.º 6
0
        private void cmTrayDownloadCustomTxtBox_Click(object sender, EventArgs e)
        {
            if (!Clipboard.ContainsText())
            {
                return;
            }

            if (string.IsNullOrEmpty(txtArgs.Text))
            {
                MessageBox.Show("No arguments are currently in memory. Enter in custom arguments in the arguments text box on the main form.");
                return;
            }
            else
            {
                frmDownloader Downloader = new frmDownloader();
                Downloader.DownloadArguments = txtArgs.Text;
                Downloader.DownloadPath      = Downloads.Default.downloadPath;
                Downloader.DownloadQuality   = -1;
                Downloader.DownloadType      = 2;
                Downloader.DownloadUrl       = Clipboard.GetText();
                Downloader.Show();
            }
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
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();
            }
        }
Exemplo n.º 9
0
        private void mBatchDownloadFromFile_Click(object sender, EventArgs e)
        {
            // Todo: translation

            if (!Downloads.Default.SkipBatchTip)
            {
                switch (MessageBox.Show("Create a text file and put all the video links you want to download into it, separated as one per line.\nDo you want to skip seeing this message when batch downloading?", "youtube-dl-gui", MessageBoxButtons.YesNoCancel))
                {
                case System.Windows.Forms.DialogResult.Cancel:
                    return;

                case System.Windows.Forms.DialogResult.Yes:
                    Downloads.Default.SkipBatchTip = true;
                    if (!Program.IsPortable)
                    {
                        Downloads.Default.Save();
                    }
                    else
                    {
                        CheckSettings.SavePortableSettings();
                    }
                    break;
                }
            }

            string TextFile = string.Empty;

            using (OpenFileDialog ofd = new OpenFileDialog()){
                ofd.Filter          = "Text Document (*.txt)|*.txt";
                ofd.Title           = "Select a file with URLs...";
                ofd.Multiselect     = false;
                ofd.CheckFileExists = true;
                ofd.CheckPathExists = true;
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    TextFile = ofd.FileName;
                }
                else
                {
                    return;
                }
            }

            Thread BatchThread = new Thread(() => {
                string videoArguments = string.Empty;
                int DownloadType      = 0;
                int BatchQuality      = 0;

                this.BeginInvoke(new MethodInvoker(() => {
                    if (!chkDownloadSound.Checked)
                    {
                        videoArguments += "-nosound";
                    }
                    BatchQuality = cbQuality.SelectedIndex;
                    if (rbVideo.Checked)
                    {
                        DownloadType = 0;
                    }
                    else if (rbAudio.Checked)
                    {
                        DownloadType = 1;
                    }
                    else if (rbCustom.Checked)
                    {
                        DownloadType = 2;
                    }
                    else
                    {
                        DownloadType = 3;
                    }
                }));

                if (System.IO.File.Exists(TextFile))
                {
                    string[] ReadFile = System.IO.File.ReadAllLines(TextFile);
                    if (ReadFile.Length == 0)
                    {
                        return;
                    }
                    for (int i = 0; i < ReadFile.Length; i++)
                    {
                        using (frmDownloader Downloader = new frmDownloader()) {
                            Downloader.BatchDownload = true;
                            switch (DownloadType)
                            {
                            case 0:
                                Downloader.DownloadArguments = videoArguments;
                                Downloader.DownloadPath      = Downloads.Default.downloadPath;
                                Downloader.DownloadQuality   = BatchQuality;
                                Downloader.DownloadType      = 0;
                                Downloader.DownloadUrl       = ReadFile[i].Trim(' ');
                                Downloader.ShowDialog();
                                break;

                            case 1:
                                Downloader.DownloadPath    = Downloads.Default.downloadPath;
                                Downloader.DownloadQuality = BatchQuality;
                                Downloader.DownloadType    = 1;
                                Downloader.DownloadUrl     = ReadFile[i].Trim(' ');
                                Downloader.ShowDialog();
                                break;

                            case 2:
                                Downloader.DownloadArguments = txtArgs.Text;
                                Downloader.DownloadPath      = Downloads.Default.downloadPath;
                                Downloader.DownloadQuality   = 0;
                                Downloader.DownloadType      = 2;
                                Downloader.DownloadUrl       = ReadFile[i].Trim(' ');
                                Downloader.ShowDialog();
                                break;

                            case 3:
                                Downloader.DownloadPath    = Downloads.Default.downloadPath;
                                Downloader.DownloadQuality = 0;
                                Downloader.DownloadType    = 0;
                                Downloader.DownloadUrl     = ReadFile[i].Trim(' ');
                                Downloader.ShowDialog();
                                break;
                            }
                        }
                    }
                }
            });

            BatchThread.Start();
        }
Exemplo n.º 10
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;
            }
        }
        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;
            }
        }
Exemplo n.º 12
0
        private void mBatchDownloadFromFile_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Create a text file and put all the videos you want to download into it.\nOne URL per line.");
            string TextFile = string.Empty;

            using (OpenFileDialog ofd = new OpenFileDialog()){
                ofd.Filter          = "Text Document (*.txt)|*.txt";
                ofd.Title           = "Select a file with URLs...";
                ofd.Multiselect     = false;
                ofd.CheckFileExists = true;
                ofd.CheckPathExists = true;
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    TextFile = ofd.FileName;
                }
                else
                {
                    return;
                }
            }
            MessageBox.Show("Batch download will now begin. It may take some time.\nyoutube-dl-gui will reappear when it's finished.");

            Thread BatchThread = new Thread(() => {
                string videoArguments = string.Empty;
                int DownloadType      = 0;
                int BatchQuality      = 0;

                this.BeginInvoke(new MethodInvoker(() => {
                    if (!chkDownloadSound.Checked)
                    {
                        videoArguments += "-nosound";
                    }
                    BatchQuality = cbQuality.SelectedIndex;
                    if (rbVideo.Checked)
                    {
                        DownloadType = 0;
                    }
                    else if (rbAudio.Checked)
                    {
                        DownloadType = 1;
                    }
                    else if (rbCustom.Checked)
                    {
                        DownloadType = 2;
                    }
                    else
                    {
                        DownloadType = 3;
                    }
                }));

                if (System.IO.File.Exists(TextFile))
                {
                    string[] ReadFile = System.IO.File.ReadAllLines(TextFile);
                    if (ReadFile.Length == 0)
                    {
                        return;
                    }
                    for (int i = 0; i < ReadFile.Length; i++)
                    {
                        using (frmDownloader Downloader = new frmDownloader()) {
                            Downloader.BatchDownload = true;
                            switch (DownloadType)
                            {
                            case 0:
                                Downloader.DownloadArguments = videoArguments;
                                Downloader.DownloadPath      = Downloads.Default.downloadPath;
                                Downloader.DownloadQuality   = BatchQuality;
                                Downloader.DownloadType      = 0;
                                Downloader.DownloadUrl       = ReadFile[i].Trim(' ');
                                Downloader.ShowDialog();
                                break;

                            case 1:
                                Downloader.DownloadPath    = Downloads.Default.downloadPath;
                                Downloader.DownloadQuality = BatchQuality;
                                Downloader.DownloadType    = 1;
                                Downloader.DownloadUrl     = ReadFile[i].Trim(' ');
                                Downloader.ShowDialog();
                                break;

                            case 2:
                                Downloader.DownloadArguments = txtArgs.Text;
                                Downloader.DownloadPath      = Downloads.Default.downloadPath;
                                Downloader.DownloadQuality   = 0;
                                Downloader.DownloadType      = 2;
                                Downloader.DownloadUrl       = ReadFile[i].Trim(' ');
                                Downloader.ShowDialog();
                                break;

                            case 3:
                                Downloader.DownloadPath    = Downloads.Default.downloadPath;
                                Downloader.DownloadQuality = 0;
                                Downloader.DownloadType    = 0;
                                Downloader.DownloadUrl     = ReadFile[i].Trim(' ');
                                Downloader.ShowDialog();
                                break;
                            }
                        }
                    }
                }
            });

            BatchThread.Start();
        }