public YourTube() { InitializeComponent(); songPlaylistDownload = new SongPlaylistDownload(ProgressBar); songDownload = new SongDownload(ProgressBar); oneSongDownload = new OneSongDownload(ProgressBar); videoDownload = new VideoDownload(ProgressBarVideo); videoPlaylistDownload = new VideoPlaylistDownload(ProgressBarVideo); updateList(); UserGetSet.input(); labelUsername.Text = UserGetSet.username; labelApiKey.Text = UserGetSet.apiKey; labelTotalPlaylist.Text = UserGetSet.playlistCount; GetInfo getInfo = new GetInfo(); }
private void VideoDownload_Click(object sender, EventArgs e) { string[] videoArray = videoURL.Text.Split('?'); if (String.IsNullOrEmpty(videoURL.Text)) { MessageBox.Show("Please insert your video URL"); } else if (String.IsNullOrEmpty(saveToTextBoxVideo.Text)) { MessageBox.Show("Please select where you want to save your video"); } //else if (MP4.Checked == false && MKV.Checked == false) //{ // MessageBox.Show("Please select video quality"); //} else if (videoArray[0] != "https://www.youtube.com/watch" && videoArray[0] != "https://www.youtube.com/playlist") { MessageBox.Show("We only support Youtube.com links"); } else if (videoArray[0] == "https://www.youtube.com/watch") { VideoDownload videoDownload = new VideoDownload(ProgressBarVideo); string format1 = "1"; //if (MP4.Checked == true) //{ // format1 = "1"; //} //else format1 = "2"; DialogResult dr = MessageBox.Show("Do you want to download this video", "Download", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { videoProgressBar.Maximum = 1; toVidLab.Text = 1.ToString(); videoDownload.DownloadVideo(videoURL.Text, saveToTextBoxVideo.Text, format1); } } else if (videoArray[0] == "https://www.youtube.com/playlist") { DialogResult dr = MessageBox.Show("This is a video play list do you want to download it ?", "Download", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { string format1 = null; if (MP4.Checked == true) { format1 = "1"; } else format1 = "2"; LinksFromPlaylist linksFromPlaylist = new LinksFromPlaylist(); List<string> videoIdLists = linksFromPlaylist.getLinks(videoURL.Text); if (videoIdLists[0] == "error") { MessageBox.Show("Your playlist link is invalid or API key is invalid"); } VideoPlaylistDownload videosDownloads = new VideoPlaylistDownload(ProgressBarVideo); int index = 0; string[] playlistID = videoURL.Text.Split('='); videoProgressBar.Maximum = videoIdLists.Count; toVidLab.Text = videoIdLists.Count.ToString(); videosDownloads.downloadVideoPlaylist(videoIdLists, saveToTextBoxVideo.Text, index, playlistID[1]); } } }