示例#1
0
        private void updateYTDL()
        {
            buffer           = "Checking for updates, please wait...\r\n";
            past             = ShellOutputForm.Text;
            performingAction = "downloading";
            /// Disable controls
            disableControls();

            using (Process cmdProcess = new Process())
            {
                cmdProcess.StartInfo.FileName               = @".\bin\youtube-dl.exe";
                cmdProcess.StartInfo.Arguments              = "--update";
                cmdProcess.StartInfo.CreateNoWindow         = true;
                cmdProcess.StartInfo.UseShellExecute        = false;
                cmdProcess.StartInfo.RedirectStandardOutput = true;

                // Set event handler
                cmdProcess.OutputDataReceived += new DataReceivedEventHandler(TextBoxHandler);
                cmdProcess.ErrorDataReceived  += new DataReceivedEventHandler(TextBoxHandler);


                // Start the process.
                cmdProcess.Start();

                // Start the asynchronous read
                cmdProcess.BeginOutputReadLine();

                cmdProcess.WaitForExit();
                performingAction = "none";
            }
            ShellOutputForm.AppendText("Update has ended.\r\n");
            ShellOutputForm.SelectionStart = ShellOutputForm.Text.Length;
            ShellOutputForm.ScrollToCaret();
            enableControls();
        }
示例#2
0
        private void audioYTDL()
        {
            past             = ShellOutputForm.Text;
            performingAction = "downloading";
            var downloadLink = linkTextBox.Text;
            var ffmpegpath   = "--ffmpeg-location /bin/ffmpeg.exe";
            var outputpath   = "-o " + preferences["outputfolder"] + "\\%(title)s.%(ext)s";
            var audioFormat  = "";

            /// Disable controls
            disableControls();

            switch (comboAudioBox.SelectedIndex)
            {
            case 0:
                audioFormat = "mp3";
                break;

            case 1:
                audioFormat = "aac";
                break;

            case 2:
                audioFormat = "m4a";
                break;

            default:
                audioFormat = "mp3";
                break;
            }
            var audioOption = "--extract-audio --audio-format " + audioFormat;

            using (Process cmdProcess = new Process())
            {
                cmdProcess.StartInfo.FileName               = @".\bin\youtube-dl.exe";
                cmdProcess.StartInfo.Arguments              = downloadLink + " " + ffmpegpath + " " + audioOption + " " + outputpath;;
                cmdProcess.StartInfo.CreateNoWindow         = true;
                cmdProcess.StartInfo.UseShellExecute        = false;
                cmdProcess.StartInfo.RedirectStandardOutput = true;

                // Set event handler
                cmdProcess.OutputDataReceived += new DataReceivedEventHandler(TextBoxHandler);
                cmdProcess.ErrorDataReceived  += new DataReceivedEventHandler(TextBoxHandler);


                // Start the process.
                cmdProcess.Start();

                // Start the asynchronous read
                cmdProcess.BeginOutputReadLine();

                cmdProcess.WaitForExit();
                performingAction = "none";
            }
            ShellOutputForm.AppendText("Audio download has ended.\r\n");
            ShellOutputForm.SelectionStart = ShellOutputForm.Text.Length;
            ShellOutputForm.ScrollToCaret();
            enableControls();
        }
示例#3
0
        private void updateUI()
        {
            while (true)
            {
                if (performingAction.Equals("none"))
                {
                    Thread.Sleep(500);
                    continue;
                }
                if (performingAction.Equals("downloading"))
                {
                    String toAdd = "";
                    toAdd = past + buffer + "\r\n";
                    ShellOutputForm.Text           = toAdd;
                    ShellOutputForm.SelectionStart = ShellOutputForm.Text.Length;
                    ShellOutputForm.ScrollToCaret();
                }

                Thread.Sleep(500);
            }
        }
示例#4
0
        private void runYTDL()
        {
            past             = ShellOutputForm.Text;
            performingAction = "downloading";
            var downloadLink = linkTextBox.Text;
            var ffmpegpath   = "--ffmpeg-location /bin/ffmpeg.exe";
            var outputpath   = "-o " + preferences["outputfolder"] + "\\%(title)s.%(ext)s";

            /// Disable controls
            disableControls();

            using (Process cmdProcess = new Process())
            {
                cmdProcess.StartInfo.FileName               = @".\bin\youtube-dl.exe";
                cmdProcess.StartInfo.Arguments              = "-f bestvideo+bestaudio " + downloadLink + " " + ffmpegpath + " " + outputpath;
                cmdProcess.StartInfo.CreateNoWindow         = true;
                cmdProcess.StartInfo.UseShellExecute        = false;
                cmdProcess.StartInfo.RedirectStandardOutput = true;

                // Set event handler
                cmdProcess.OutputDataReceived += new DataReceivedEventHandler(TextBoxHandler);
                cmdProcess.ErrorDataReceived  += new DataReceivedEventHandler(TextBoxHandler);


                // Start the process.
                cmdProcess.Start();

                // Start the asynchronous read
                cmdProcess.BeginOutputReadLine();

                cmdProcess.WaitForExit();
                performingAction = "none";
            }
            ShellOutputForm.AppendText("Download has ended.\r\n");
            ShellOutputForm.SelectionStart = ShellOutputForm.Text.Length;
            ShellOutputForm.ScrollToCaret();
            enableControls();
        }