Esempio n. 1
0
        private void Update_Click(object sender, EventArgs e)
        {
            GetInfo           getInfo           = new GetInfo();
            LinksFromPlaylist linksFromPlaylist = new LinksFromPlaylist();
            List <string>     playlistUrls      = getInfo.playlistUrls();

            List <int> videoCount = getInfo.getPlaylistData(playlistUrls);

            List <int>    updatedInfoCount = new List <int>();
            List <string> infoCount        = new List <string>();

            foreach (string url in playlistUrls)
            {
                infoCount = linksFromPlaylist.getLinks(url);
                updatedInfoCount.Add(infoCount.Count);
            }
            bool noUpdate = false;

            for (int i = 0; i < updatedInfoCount.Count; i++)
            {
                if (videoCount[i] < updatedInfoCount[i])
                {
                    List <string> databaseVideoId  = getInfo.getVideoIdUpdate(playlistUrls[i]);
                    List <string> updatedVideoList = new List <string>();
                    List <string> newSongs         = linksFromPlaylist.getLinks(playlistUrls[i]);
                    for (int j = 0; j < newSongs.Count; j++)
                    {
                        bool foundVideo = false;
                        for (int z = 0; z < databaseVideoId.Count; z++)
                        {
                            if (newSongs[j] == databaseVideoId[z])
                            {
                                foundVideo = true;
                                break;
                            }
                        }
                        if (foundVideo == false)
                        {
                            updatedVideoList.Add(newSongs[j]);
                        }
                    }
                    AddInfo addInfo = new AddInfo();
                    addInfo.addUpdatedSongs(updatedVideoList, playlistUrls[i]);
                    noUpdate = true;
                }
            }
            if (noUpdate == false)
            {
                MessageBox.Show("There are no available updates");
            }
            else
            {
                updateList();
                MessageBox.Show("Playlists have been updated");
            }
        }
Esempio n. 2
0
        private void Mp3Download_Click(object sender, EventArgs e)
        {
            string[] array = uriTextBoxSong.Text.Split('?');
            if (String.IsNullOrEmpty(uriTextBoxSong.Text))
            {
                MessageBox.Show("Please insert your URL");
            }
            else if (String.IsNullOrEmpty(saveToTextBoxSong.Text))
            {
                MessageBox.Show("Please select where you want to save your file");
            }
            else if (array[0] != "https://www.youtube.com/watch" && array[0] != "https://www.youtube.com/playlist")
            {
                MessageBox.Show("We only support Youtube.com links");
            }
            else if (array[0] == "https://www.youtube.com/watch")
            {
                SongDownload songDownload = new SongDownload(ProgressBar);
                DialogResult dr = MessageBox.Show("Do you want to download this one song", "Download", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    songProgressBar.Maximum = 1;
                    toLab.Text = "1";
                    songDownload.DownloadSong(uriTextBoxSong.Text, saveToTextBoxSong.Text);
                }
            }
            else if (array[0] == "https://www.youtube.com/playlist")
            {
                SongPlaylistDownload playlistDownload = new SongPlaylistDownload(ProgressBar);
                DialogResult dr = MessageBox.Show("This is a song play list do you want to download it ?", "Download", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    DialogResult dr1 = MessageBox.Show("Do you want to save this play list to your database?", "Download", MessageBoxButtons.YesNo);
                    if (dr1 == DialogResult.Yes)
                    {
                        GetTitles get = new GetTitles();
                        List<string> titles = get.getTitles(uriTextBoxSong.Text);
                        if (titles[0] == "error")
                        {
                            MessageBox.Show("Your playlist link is invalid or API key is invalid");
                        }
                        else
                        {
                            string playlistName = Microsoft.VisualBasic.Interaction.InputBox("Please type in your playlist name", "Download", "");
                            if (playlistName == "")
                            {
                            }
                            else
                            {
                                AddInfo addInfo = new AddInfo();
                                addInfo.addNewPlaylist(playlistName, uriTextBoxSong.Text, "Yes");
                                this.Refresh();
                                LinksFromPlaylist linksFromPlaylist = new LinksFromPlaylist();
                                List<string> videoIdLists = linksFromPlaylist.getLinks(uriTextBoxSong.Text);
                                songProgressBar.Maximum = videoIdLists.Count;
                                toLab.Text = videoIdLists.Count.ToString();
                                string[] playlistID = uriTextBoxSong.Text.Split('=');
                                int index = 0;
                                playlistDownload.DownloadSongPlaylist(videoIdLists, saveToTextBoxSong.Text, playlistID[1], index);
                            }
                        }

                    }
                    else if (dr1 == DialogResult.No)
                    {
                        LinksFromPlaylist linksFromPlaylist = new LinksFromPlaylist();
                        List<string> videoIdLists = linksFromPlaylist.getLinks(uriTextBoxSong.Text);
                        if (videoIdLists[0] == "error")
                        {
                            MessageBox.Show("Your playlist link is invalid or API key is invalid");
                        }
                        else
                        {
                            songProgressBar.Maximum = videoIdLists.Count;
                            toLab.Text = videoIdLists.Count.ToString();
                            fromLab.Text = "0 /";
                            string[] playlistID = uriTextBoxSong.Text.Split('=');
                            int index = 0;
                            playlistDownload.DownloadSongPlaylist(videoIdLists, saveToTextBoxSong.Text, playlistID[1], index);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        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]);
                }
            }
        }