private void buttonSaveSettings_Click(object sender, EventArgs e) { SSettings.setDownloadFolder(textBoxDownload.Text); SSettings.SetVlcFile(textBoxVLCPath.Text); SSettings.SetCacheFolder(textBoxChacheLocation.Text); Dispose(); }
public Settings() { InitializeComponent(); textBoxVLCPath.Text = SSettings.GetVlcFile(); textBoxDownload.Text = SSettings.getDownloadFolder(); textBoxChacheLocation.Text = SSettings.getCacheFolder(); }
private void toolStripMenuItemOpenVLC_Click(object sender, EventArgs e) { string vlcPath = SSettings.GetVlcFile(); if (vlcPath != null) { try { //process.Close(); //process.Dispose(); ProcessStartInfo start = new ProcessStartInfo(); start.Arguments = "--one-instance " + results[listResults.FocusedItem.Index].url; start.FileName = vlcPath; //string[] args = { "--one-instance", "--playlist-enqueue"}; start.CreateNoWindow = false; //start.WindowStyle = ProcessWindowStyle.Maximized; process = Process.Start(start); //process.WaitForExit(); } catch (Exception exception) { // do nothing MessageBox.Show(exception.Message); } } else { MessageBox.Show("Couldn't find VLC player \n Please make sure VLC is installed on your system ", "File not found vlc.exe"); } //process.Start("c:/VLC/vlc.exe", results[listResults.FocusedItem.Index].url); }
public void DownloadVideo(YouTubeVideo video, string VideoURL) { // TODO if a file like this already exists warn the user of the duplicated download // don't waste his localFileLocation = SSettings.getDownloadFolder() + @"\" + $"[{video.Resolution}]" + video.FullName; bool download = true; if (File.Exists(localFileLocation)) { const string message = "This video has been already downloaded \n Do you want to re-Download it again ? "; const string caption = "Redownload ?"; var result = MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { download = false; } } if (download) { try { tempDownloadFile = SSettings.getCacheFolder() + $"[{video.Resolution}]" + video.FullName; if (File.Exists(tempDownloadFile)) { try { File.Delete(tempDownloadFile); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR "); Dispose(); } } webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFinished); webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged); webClient.DownloadFileAsync(new Uri(video.Uri), tempDownloadFile); startTime = DateTimeOffset.Now.ToUnixTimeMilliseconds(); labRemoteLink.Text = VideoURL; labLocalFile.Text = $"[{video.Resolution}]" + video.FullName; Text = "Downloading " + $"[{video.Resolution}]" + video.FullName; } catch (Exception ex) { MessageBox.Show(ex.Message, "Network Error"); } } else { webClient.Dispose(); Dispose(); } }
static void Main() { SSettings.getCurrentLocation(); SSettings.loadSettings(); Directory.CreateDirectory(SSettings.getDownloadFolder()); Directory.CreateDirectory(SSettings.getCacheFolder()); foreach (var str in Directory.GetFiles(SSettings.getCacheFolder())) { try { File.Delete(str); } catch (Exception e) { Console.WriteLine(e.Message); } } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
private void btnSearch_Click(object sender, EventArgs e) { btnSearch.Enabled = false; listResults.Items.Clear(); string searchQuery = txtSearchQuery.Text; if (txtSearchQuery.Text.StartsWith("https://www.youtube.com/watch?v=") || txtSearchQuery.Text.StartsWith("http://www.youtube.com/watch?v=") || txtSearchQuery.Text.StartsWith("www.youtube.com/watch?v=")) { searchQuery = txtSearchQuery.Text.Split('=')[1].Split('&')[0]; } try { results = YoutubeScrapeEngine.scrapeYoutube(searchQuery); } catch (Exception ex) { results = new List <VideoItem>(); MessageBox.Show(ex.Message + "\n Hint : Check your internet connection before trying again ", "Network Error"); } ImageList imageList = new ImageList(); imageList.ImageSize = new Size(120, 80); imageList.ColorDepth = ColorDepth.Depth24Bit; if (results.Any()) { int i = 0; Directory.CreateDirectory(SSettings.getCacheFolder()); foreach (VideoItem video in results) { string path = video.DownloadThumbSmallImage(); imageList.Images.Add(Image.FromFile(path)); string[] arr = { "", "" + (i + 1), video.title, video.url }; ListViewItem l = new ListViewItem(arr) { Font = new Font("Century Gothic", 10.75F, FontStyle.Regular, GraphicsUnit.Point, 0), ImageIndex = i }; listResults.Items.Add(l); i++; } listResults.SmallImageList = imageList; } else { imageList.Images.Add(imageList1.Images[0]); string[] arr = { "", " ", "No Results check your enternet connection ", "N/A" }; ListViewItem t = new ListViewItem(arr) { Font = Font = new Font("Century Gothic", 10.75F, FontStyle.Regular, GraphicsUnit.Point, 0), ImageIndex = 0 }; listResults.Items.Add(t); listResults.SmallImageList = imageList; } btnSearch.Enabled = true; foreach (var video in results) { video.LoadVideos(); } }