Beispiel #1
0
 private void cmTrayExit_Click(object sender, EventArgs e)
 {
     if (Program.IsPortable)
     {
         CheckSettings.SavePortableSettings();
     }
     else
     {
         Saved.Default.Save();
     }
     trayIcon.Visible = false;
     Environment.Exit(0);
 }
Beispiel #2
0
        private void saveSettings()
        {
            General.Default.UseStaticYtdl = chkSettingsGeneralUseStaticYoutubeDl.Checked;
            if (chkSettingsGeneralUseStaticYoutubeDl.Checked)
            {
                General.Default.ytdlPath = txtSettingsGeneralYoutubeDlPath.Text;
            }
            General.Default.UseStaticFFmpeg = chkSettingsGeneralUseStaticFFmpeg.Checked;
            if (chkSettingsGeneralUseStaticFFmpeg.Checked && !string.IsNullOrEmpty(txtSettingsGeneralFFmpegPath.Text))
            {
                General.Default.ffmpegPath = txtSettingsGeneralFFmpegPath.Text;
            }
            General.Default.CheckForUpdatesOnLaunch    = chkSettingsGeneralCheckForUpdatesOnLaunch.Checked;
            General.Default.HoverOverURLTextBoxToPaste = chkSettingsGeneralHoverOverUrlToPasteClipboard.Checked;
            General.Default.ClearURLOnDownload         = chkSettingsGeneralClearUrlOnDownload.Checked;
            General.Default.ClearClipboardOnDownload   = chkSettingsGeneralClearClipboardOnDownload.Checked;
            if (rbSettingsGeneralCustomArgumentsDontSave.Checked)
            {
                General.Default.SaveCustomArgs = 0;
            }
            else if (rbSettingsGeneralCustomArgumentsSaveAsArgsText.Checked)
            {
                General.Default.SaveCustomArgs = 1;
            }
            else if (rbSettingsGeneralCustomArgumentsSaveInSettings.Checked)
            {
                General.Default.SaveCustomArgs = 2;
            }
            else
            {
                General.Default.SaveCustomArgs = 0;
            }

            Downloads.Default.downloadPath   = txtSettingsDownloadsSavePath.Text;
            Downloads.Default.fileNameSchema = txtSettingsDownloadsFileNameSchema.Text;
            if (!txtSettingsDownloadsFileNameSchema.Items.Contains(txtSettingsDownloadsFileNameSchema.Text))
            {
                txtSettingsDownloadsFileNameSchema.Items.Add(txtSettingsDownloadsFileNameSchema.Text);
            }
            string FileNameSchemaHistory = GetHistoryFromComboBox(txtSettingsDownloadsFileNameSchema);

            if (Saved.Default.FileNameSchemaHistory != FileNameSchemaHistory)
            {
                Saved.Default.FileNameSchemaHistory = FileNameSchemaHistory;
            }

            Downloads.Default.SaveFormatQuality      = chkSettingsDownloadsSaveFormatQuality.Checked;
            Downloads.Default.SaveSubtitles          = chkSettingsDownloadsDownloadSubtitles.Checked;
            Downloads.Default.EmbedSubtitles         = chkSettingsDownloadsEmbedSubtitles.Checked;
            Downloads.Default.SaveVideoInfo          = chkSettingsDownloadsSaveVideoInfo.Checked;
            Downloads.Default.WriteMetadata          = chkSettingsDownloadsWriteMetadataToFile.Checked;
            Downloads.Default.SaveDescription        = chkSettingsDownloadsSaveDescription.Checked;
            Downloads.Default.KeepOriginalFiles      = chkSettingsDownloadsKeepOriginalFiles.Checked;
            Downloads.Default.SaveAnnotations        = chkSettingsDownloadsSaveAnnotations.Checked;
            Downloads.Default.SaveThumbnail          = chkSettingsDownloadsSaveThumbnails.Checked;
            Downloads.Default.EmbedThumbnails        = chkSettingsDownloadsEmbedThumbnails.Checked;
            Downloads.Default.deleteYtdlOnClose      = chkSettingsDownloadsAutomaticallyDeleteYoutubeDlWhenClosing.Checked;
            Downloads.Default.separateDownloads      = chkSettingsDownloadsSeparateDownloadsToDifferentFolders.Checked;
            Downloads.Default.separateIntoWebsiteURL = chkSettingsDownloadsSeparateIntoWebsiteUrl.Checked;
            Downloads.Default.fixReddit         = chkSettingsDownloadsFixVReddIt.Checked;
            Downloads.Default.PreferFFmpeg      = chkSettingsDownloadsPreferFFmpeg.Checked;
            Downloads.Default.LimitDownloads    = chkSettingsDownloadsLimitDownload.Checked;
            Downloads.Default.DownloadLimit     = (int)numSettingsDownloadsLimitDownload.Value;
            Downloads.Default.DownloadLimitType = cbSettingsDownloadsLimitDownload.SelectedIndex;
            Downloads.Default.ForceIPv4         = chkSettingsDownloadsForceIpv4.Checked;
            Downloads.Default.ForceIPv6         = chkSettingsDownloadsForceIpv6.Checked;
            Downloads.Default.UseProxy          = chkSettingsDownloadsUseProxy.Checked;
            Downloads.Default.ProxyType         = cbSettingsDownloadsProxyType.SelectedIndex;
            Downloads.Default.ProxyIP           = txtSettingsDownloadsProxyIp.Text;
            Downloads.Default.ProxyPort         = txtSettingsDownloadsProxyPort.Text;
            Downloads.Default.useYtdlUpdater    = chksettingsDownloadsUseYoutubeDlsUpdater.Checked;

            Converts.Default.detectFiletype    = chkSettingsConverterDetectOutputFileType.Checked;
            Converts.Default.clearOutput       = chkSettingsConverterClearOutputAfterConverting.Checked;
            Converts.Default.clearInput        = chkSettingsConverterClearInputAfterConverting.Checked;
            Converts.Default.hideFFmpegCompile = chkSettingsConverterHideFFmpegCompileInfo.Checked;

            Converts.Default.videoUseBitrate = chkUseVideoBitrate.Checked;
            Converts.Default.videoBitrate    = Decimal.ToInt32(numConvertVideoBitrate.Value);
            Converts.Default.videoUsePreset  = chkSettingsConverterVideoPreset.Checked;
            Converts.Default.videoPreset     = cbConvertVideoPreset.SelectedIndex;
            Converts.Default.videoUseProfile = chkUseVideoProfile.Checked;
            Converts.Default.videoProfile    = cbConvertVideoProfile.SelectedIndex;
            Converts.Default.videoUseCRF     = chkUseVideoCRF.Checked;
            Converts.Default.videoCRF        = Decimal.ToInt32(numConvertVideoCRF.Value);
            Converts.Default.videoFastStart  = chkSettingsConverterVideoFastStart.Checked;

            Converts.Default.audioUseBitrate = chkUseAudioBitrate.Checked;
            Converts.Default.audioBitrate    = Decimal.ToInt32(numConvertAudioBitrate.Value);

            Saved.Default.convertCustom    = txtSettingsConverterCustomArguments.Text;
            Saved.Default.SettingsFormSize = this.Size;

            saveExtensions();

            Errors.Default.detailedErrors = chkSettingsErrorsShowDetailedErrors.Checked;
            Errors.Default.logErrors      = chkSettingsErrorsSaveErrorsAsErrorLog.Checked;
            Errors.Default.suppressErrors = chkSettingsErrorsSuppressErrors.Checked;

            if (!Program.IsPortable)
            {
                General.Default.Save();
                Downloads.Default.Save();
                Converts.Default.Save();
                Settings.Default.Save();
                Errors.Default.Save();
                Saved.Default.Save();
            }
            else
            {
                CheckSettings.SavePortableSettings();
            }
        }
Beispiel #3
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();
        }
Beispiel #4
0
        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (this.Location.X == 0 || this.Location.Y == 0)
            {
                Saved.Default.formTrue0 = true;
            }
            else
            {
                Saved.Default.formTrue0 = false;
            }
            Saved.Default.MainFormSize = this.Size;

            switch (General.Default.SaveCustomArgs)
            {
            case 1:     // txt
                System.IO.File.WriteAllText(Environment.CurrentDirectory + "\\args.txt", txtArgs.Text.TrimEnd('\n'));
                break;

            case 2:     // settings
                Saved.Default.downloadArgs = txtArgs.Text;
                break;
            }

            if (rbVideo.Checked)
            {
                Saved.Default.downloadType = 0;
            }
            else if (rbAudio.Checked)
            {
                Saved.Default.downloadType = 1;
            }
            else if (rbCustom.Checked)
            {
                Saved.Default.downloadType = 2;
            }
            else
            {
                Saved.Default.downloadType = -1;
            }

            if (rbConvertVideo.Checked)
            {
                Saved.Default.convertType = 0;
            }
            else if (rbConvertAudio.Checked)
            {
                Saved.Default.convertType = 1;
            }
            else if (rbConvertCustom.Checked)
            {
                Saved.Default.convertType = 2;
            }
            else if (rbConvertAutoFFmpeg.Checked)
            {
                Saved.Default.convertType = 6;
            }
            else
            {
                Saved.Default.convertType = -1;
            }

            Saved.Default.formLocationX = this.Location.X;
            Saved.Default.formLocationY = this.Location.Y;

            if (Program.IsPortable)
            {
                CheckSettings.SavePortableSettings();
            }
            else
            {
                Saved.Default.Save();
            }
            trayIcon.Visible = false;
        }
        private static bool DMCA         = false; // Will bypass the youtube-dl check if it gets DMCA'd

        public static void CheckForUpdate(bool ForceCheck = false)
        {
            if (Program.IsDebug && !ForceCheck)
            {
                Debug.Print("-version " + GitData.UpdateVersion + " -name " + System.AppDomain.CurrentDomain.FriendlyName);
            }
            else
            {
                if (!General.Default.CheckForUpdatesOnLaunch && !ForceCheck)
                {
                    return;
                }


                if (GitData.UpdateAvailable)
                {
                    using (frmUpdateAvailable Update = new frmUpdateAvailable()) {
                        Update.BlockSkip = ForceCheck;
                        switch (Update.ShowDialog())
                        {
                        case DialogResult.Yes:
                            try {
                                UpdateApplication();
                            }
                            catch (Exception ex) {
                                ErrorLog.ReportException(ex);
                                return;
                            }
                            break;
                        }
                    }
                }
                else
                {
                    Thread checkUpdates = new Thread(() => {
                        if (GitData.UpdateVersion == "-1" || ForceCheck)
                        {
                            decimal GitVersion = UpdateChecker.GetGitVersion(0);
                            if (UpdateChecker.IsUpdateAvailable(GitVersion))
                            {
                                GitData.UpdateAvailable = true;
                                if (GitVersion != Properties.Settings.Default.SkippedVersion || ForceCheck)
                                {
                                    using (frmUpdateAvailable Update = new frmUpdateAvailable()) {
                                        Update.BlockSkip = ForceCheck;
                                        switch (Update.ShowDialog())
                                        {
                                        case DialogResult.Yes:
                                            try {
                                                UpdateApplication();
                                            }
                                            catch (Exception ex) {
                                                ErrorLog.ReportException(ex);
                                                return;
                                            }
                                            break;

                                        case DialogResult.Ignore:
                                            Properties.Settings.Default.SkippedVersion = GitVersion;
                                            if (Program.IsPortable)
                                            {
                                                CheckSettings.SavePortableSettings();
                                            }
                                            else
                                            {
                                                Properties.Settings.Default.Save();
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                            else if (ForceCheck)
                            {
                                MessageBox.Show("No updates available.");
                            }
                        }
                    });
                    checkUpdates.Name = "Check for application update";
                    checkUpdates.Start();
                }
            }
        }