Exemplo n.º 1
0
        public void videoTitlesFromYoutubeDataApi_goodData()
        {
            GetTitles getTitles = new GetTitles();

            UserGetSet.input();
            UserGetSet.apiKey = "AIzaSyCBYx5nDeHanit6rpvzhZLSDy52diu7ecI";

            List <string> list = getTitles.getTitles("https://www.youtube.com/playlist?list=PLYQ21GguN2ssJfHlwxZxzepHaiu3t798Y");

            CollectionAssert.AreEqual(list, getTitles.getTitles("https://www.youtube.com/playlist?list=PLYQ21GguN2ssJfHlwxZxzepHaiu3t798Y"));
        }
Exemplo n.º 2
0
        public void addSongs(string playlistName, string url, string yesNo)
        {
            LinksFromPlaylist linksFromPlaylist = new LinksFromPlaylist();
            GetTitles         getTitles         = new GetTitles();
            List <string>     videoId           = linksFromPlaylist.getLinks(url);
            List <string>     videoTitle        = getTitles.getTitles(url);
            SQLiteConnection  sqlite_conn       = new SQLiteConnection("Data Source=YourTubeDB.db; Version = 3; New = True; Compress = True; ");

            sqlite_conn.Open();
            SQLiteCommand sqlite_cmd;

            sqlite_cmd = sqlite_conn.CreateCommand();
            for (int i = 0; i < videoId.Count; i++)
            {
                sqlite_cmd.CommandText = "INSERT INTO Titles (PlaylistID, VideoTitle, VideoId, DownloadedVideo) VALUES('" + playlistName + "' ,'" + videoTitle[i] + "' ,'" + videoId[i] + "', '" + yesNo + "'); ";
                sqlite_cmd.ExecuteNonQuery();
            }
        }
Exemplo n.º 3
0
        public void addSongs(string playlistName, string url, string yesNo)
        {
            LinksFromPlaylist linksFromPlaylist = new LinksFromPlaylist();
            GetTitles         getTitles         = new GetTitles();
            List <string>     videoId           = linksFromPlaylist.getLinks(url);
            List <string>     videoTitle        = getTitles.getTitles(url);

            sqlite_conn.Open();
            SQLiteCommand sqlite_cmd = sqlite_conn.CreateCommand();

            for (int i = 0; i < videoId.Count; i++)
            {
                videoTitle[i]          = videoTitle[i].Replace("\"", "").Replace("'", "");
                sqlite_cmd.CommandText = "INSERT INTO Titles (PlaylistID, VideoTitle, VideoId, DownloadedVideo, VideoUrl) VALUES('" + playlistName + "' ,'" + videoTitle[i] + "' ,'" + videoId[i] + "', '" + yesNo + "', '" + url + "'); ";
                sqlite_cmd.ExecuteNonQuery();
            }
            sqlite_cmd.CommandText = "INSERT INTO PlaylistInfo (PlaylistName, PlaylistID) VALUES('" + playlistName + "','" + url + "')";
            sqlite_cmd.ExecuteNonQuery();
            sqlite_conn.Close();
        }
Exemplo n.º 4
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);
                        }
                    }
                }
            }
        }