private void textBoxUrl_TextChanged(object sender, EventArgs e) { try { if (textBoxUrl.Text == "") { LabelBitrate.Text = ""; LabelName.Text = ""; LabelDuration.Text = ""; pictureBoxImage.Image = null; return; } LabelWarning.Text = ""; if (textBoxUrl.Text.Contains("youtube.com")) { LabelName.Text = ""; LabelBitrate.Text = ""; LabelDuration.Text = ""; Dowloader dowloader = new Dowloader(textBoxUrl.Text); dowloader.GetImage(); LabelBitrate.Text = dowloader.Audio_Bitrate.ToString(); pictureBoxImage.Image = dowloader.GetImageBitmap(); if (dowloader.VideoName.Length >= 30) { LabelName.Text = dowloader.VideoName.Substring(0, 30) + "..."; } } else { LabelWarning.Text = "This is not a youtube link!"; } } catch (Exception) { LabelWarning.Text = "Not Found Video"; // throw; } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { BW_Proses = true; try { if (LabelWarning.Text == "" && textBoxUrl.Text != "") { if (!checkBoxMp3.Checked && !checkBoxMp4.Checked) { pictureBoxStatus.Image = Properties.Resources.close; return; } pictureBoxStatus.Image = Properties.Resources.DownloadGif; Dowloader dowloader = new Dowloader(textBoxUrl.Text); dowloader.VideoDownload(path); if (checkBoxMp3.Checked) { Convert convert = new Convert(); convert.Mp4ToMp3(path, dowloader.VideoName); } if (!checkBoxMp4.Checked) { File.Delete($"{path + dowloader.VideoName}"); } pictureBoxStatus.Image = Properties.Resources._checked; return; } else { pictureBoxStatus.Image = Properties.Resources.close; } } catch (Exception) { pictureBoxStatus.Image = Properties.Resources.close; throw; } }