private void frmMain_Load(object sender, EventArgs e) { niTray.ContextMenu = cmTray; // Check for updater batch file & delete it. Set "HasUpdated" to true to signify an update MIGHT have occured, not 100% sure. if (File.Exists(System.Windows.Forms.Application.StartupPath + @"\ydgu.bat")) { hasUpdated = true; } if (!Settings.Default.updateCheck) { Thread checkUpdates = new Thread(() => { decimal cV = Updater.getCloudVersion(); if (Updater.isUpdateAvailable(cV)) { if (MessageBox.Show("An update is available.\nNew verison: " + cV.ToString() + " | Your version: " + Properties.Settings.Default.currentVersion.ToString() + "\n\nWould you like to update?", "youtube-dl-gui", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { Updater.createUpdaterStub(cV); Updater.runUpdater(); } } }); } if (String.IsNullOrWhiteSpace(Settings.Default.DownloadDir)) { switch (MessageBox.Show("Would you like to use " + Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads" + " as your download path?", "youtube-dl-gui", MessageBoxButtons.YesNoCancel)) { case System.Windows.Forms.DialogResult.Yes: Settings.Default.DownloadDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads"; break; case System.Windows.Forms.DialogResult.No: FolderBrowserDialog fbd = new FolderBrowserDialog { Description = "Select a folder for videos to download to" }; switch (fbd.ShowDialog()) { case System.Windows.Forms.DialogResult.OK: Settings.Default.DownloadDir = fbd.SelectedPath; break; case System.Windows.Forms.DialogResult.Cancel: Environment.Exit(0); break; } break; } Settings.Default.Save(); } if (String.IsNullOrWhiteSpace(Settings.Default.youtubedlDir) && Settings.Default.staticYTD) { if (MessageBox.Show("Would you like to use a static youtube-dl.exe path? Select \"No\" to keep youtube-dl.exe with youtube-dl-gui.exe.", "youtube-dl-gui", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { FolderBrowserDialog fbd = new FolderBrowserDialog { Description = "Select a folder to store youtube-dl.exe" }; if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Settings.Default.youtubedlDir = fbd.SelectedPath; } } else { Settings.Default.staticYTD = false; } Settings.Default.Save(); } if (Settings.Default.staticYTD) { ytdl = Settings.Default.youtubedlDir + @"\youtube-dl.exe"; } else { ytdl = System.Windows.Forms.Application.StartupPath + @"\youtube-dl.exe"; Settings.Default.youtubedlDir = System.Windows.Forms.Application.StartupPath + @"\youtube-dl.exe"; } // Downloads the youtube-dl application if it does not exist, otherwise it checks for updates. if (!File.Exists(ytdl)) { Download.downloadYoutubeDL(ytdl); } }
private void btnRedownload_Click(object sender, EventArgs e) { Download.downloadYoutubeDL(Settings.Default.youtubedlDir); }