Пример #1
0
        private void BackBu_Click(object sender, EventArgs e)
        {
            this.Hide();
            YourTube yourTube = new YourTube();

            yourTube.Show();
        }
Пример #2
0
 private void Save_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(usenameText.Text))
     {
         MessageBox.Show("Please type in your ussername");
     }
     else if (String.IsNullOrEmpty(passwordText.Text))
     {
         MessageBox.Show("Please type in your password");
     }
     else
     {
         GetInfo    getInfo     = new GetInfo();
         int        check       = getInfo.checkUserCredentials(usenameText.Text, passwordText.Text);
         TestApiKey testApiKey  = new TestApiKey();
         string     testRezults = testApiKey.testApiKey(UserGetSet.apiKey);
         YourTube   yourTube    = new YourTube();
         if (testRezults == "Bad")
         {
             MessageBox.Show("Your Api Key has expired please change it");
             this.Hide();
             yourTube.Show();
         }
         else if (check == 1)
         {
             this.Hide();
             yourTube.Show();
         }
         else
         {
             MessageBox.Show("Error your credentials are bad");
         }
     }
 }
Пример #3
0
        public async void DownloadVideo(string uri, string directory, string format)
        {
            if (format == "1")
            {
                var youtube = new YoutubeClient();
                var vid     = await youtube.Videos.GetAsync(uri);

                YourTube yourTube = new YourTube();
                if (File.Exists(directory + "\\" + vid.Title + ".mp4"))
                {
                    yourTube.YourHaveVideo();
                }
                else
                {
                    var streamManifest = await youtube.Videos.Streams.GetManifestAsync(vid.Id);

                    var streamInfo = streamManifest.GetMuxed().WithHighestVideoQuality();
                    if (streamInfo != null)
                    {
                        await youtube.Videos.Streams.GetAsync(streamInfo);

                        await youtube.Videos.Streams.DownloadAsync(streamInfo, vid.Title + ".mp4");
                    }
                    string data = Directory.GetCurrentDirectory() + "\\";
                    File.Move(data + vid.Title + ".mp4", directory + "\\" + vid.Title + ".mp4");
                    int index = 1;
                    progressBar1.Invoke((int)index);
                    yourTube.DownloadEn();
                }
            }
            else
            {
                var youtube = new YoutubeClient();
                var vid     = await youtube.Videos.GetAsync(uri);


                // Get stream manifest
                var streamManifest = await youtube.Videos.Streams.GetManifestAsync(uri);

                // Select streams (1080p60 / highest bitrate audio)
                var audioStreamInfo = streamManifest.GetAudioOnly().WithHighestBitrate();
                var videoStreamInfo = streamManifest.GetVideoOnly().Where(s => s.Container == Container.Mp4).WithHighestVideoQuality();

                var streamInfos = new IStreamInfo[] { audioStreamInfo, videoStreamInfo };

                // Download and process them into one file
                string data = Directory.GetCurrentDirectory() + "\\";
                await youtube.Videos.DownloadAsync(streamInfos, new ConversionRequestBuilder("a").Build());
            }
        }
Пример #4
0
        public async void DownloadSongPlaylist(List <string> mas, string directory, string playlistID, int index)
        {
            YourTube yourTube = new YourTube();

            for (int i = index; i < mas.Count; i++)
            {
                //try
                //{
                string url = "https://www.youtube.com/watch?v=" + mas[i] + "&list=" + playlistID + "&index=" + index + 1;
                index++;
                var youtube = new YoutubeClient();
                var vid     = await youtube.Videos.GetAsync(url);

                if (File.Exists(directory + "\\" + vid.Title + ".mp3"))
                {
                    progressBar1.Invoke((int)index);
                }
                else
                {
                    var streamManifest = await youtube.Videos.Streams.GetManifestAsync(vid.Id);

                    var streamInfo = streamManifest.GetAudioOnly().WithHighestBitrate();
                    if (streamInfo != null)
                    {
                        await youtube.Videos.Streams.GetAsync(streamInfo);

                        await youtube.Videos.Streams.DownloadAsync(streamInfo, vid.Title + ".mp3");
                    }
                    string data = Directory.GetCurrentDirectory() + "\\";
                    File.Move(data + vid.Title + ".mp3", directory + "\\" + vid.Title + ".mp3");
                    progressBar1.Invoke((int)index);
                }
                if (index == mas.Count)
                {
                    yourTube.DownloadEn();
                }
                //}
                //catch (Exception e)
                //{
                //    if (index < mas.Count)
                //    {
                //        DownloadSongPlaylist(mas, directory, playlistID, index - 1);
                //    }
                //}
            }
        }
Пример #5
0
 private void Add_Click(object sender, EventArgs e)
 {
     string[] array = playlistLink.Text.Split('?');
     if (String.IsNullOrEmpty(playlistName.Text))
     {
         MessageBox.Show("Please type in your playlist name");
     }
     else if (String.IsNullOrEmpty(playlistLink.Text))
     {
         MessageBox.Show("Please insert your youtube link");
     }
     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")
     {
         DialogResult dr = MessageBox.Show("It's a single song do you want to add it ?", "Download", MessageBoxButtons.YesNo);
         if (dr == DialogResult.Yes)
         {
             //SaveNewPlaylist saveNewPlaylist = new SaveNewPlaylist();
             AddInfo addInfo = new AddInfo();
             addInfo.addNewPlaylist(playlistName.Text, playlistLink.Text, "No");
             //test it more
         }
     }
     else if (array[0] == "https://www.youtube.com/playlist")
     {
         DialogResult dr = MessageBox.Show("This is a song play list do you want to add it ?", "Download", MessageBoxButtons.YesNo);
         if (dr == DialogResult.Yes)
         {
             //SaveNewPlaylist saveNewPlaylist = new SaveNewPlaylist();
             AddInfo addInfo = new AddInfo();
             addInfo.addNewPlaylist(playlistName.Text, playlistLink.Text, "No");
             MessageBox.Show("Your playlist has been added successfully");
             this.Hide();
             YourTube yourTube = new YourTube();
             yourTube.Show();
             //test it more
         }
     }
 }
Пример #6
0
        private void Save_Click(object sender, EventArgs e)
        {
            TestApiKey testApiKey = new TestApiKey();
            string     testResult = testApiKey.testApiKey(textBoxKey.Text);

            if (testResult == "Bad")
            {
                MessageBox.Show("This Api key is invalid");
            }
            else
            {
                SQLiteConnection sqlite_conn = new SQLiteConnection("Data Source=YourTubeDB.db; Version = 3; New = True; Compress = True; ");
                sqlite_conn.Open();
                SQLiteCommand sqlite_cmd = sqlite_conn.CreateCommand();
                sqlite_cmd.CommandText = "UPDATE User SET ApiKey = '" + textBoxKey.Text + "' WHERE Username = '******'";
                sqlite_cmd.ExecuteNonQuery();
                UserGetSet.apiKey = textBoxKey.Text;
                MessageBox.Show("Your API has been saved successfully");
                this.Hide();
                YourTube yourTube = new YourTube();
                yourTube.Show();
            }
        }
Пример #7
0
        public async void DownloadSong(string uri, string directory)
        {
            //try
            //{
            YourTube yourTube = new YourTube();
            var      youtube  = new YoutubeClient();
            var      vid      = await youtube.Videos.GetAsync(uri);

            if (File.Exists(directory + "\\" + vid.Title + ".mp3"))
            {
                yourTube.YouHaveSong();
            }
            else
            {
                var streamManifest = await youtube.Videos.Streams.GetManifestAsync(vid.Id);

                var streamInfo = streamManifest.GetAudioOnly().WithHighestBitrate();
                if (streamInfo != null)
                {
                    await youtube.Videos.Streams.GetAsync(streamInfo);

                    await youtube.Videos.Streams.DownloadAsync(streamInfo, vid.Title + ".mp3");
                }
                string         data           = Directory.GetCurrentDirectory() + "\\";
                AudioConverter audioConverter = new AudioConverter();
                audioConverter.ConvertAudio(data + vid.Title);
                File.Move(data + vid.Title + ".mp3", directory + "\\" + vid.Title + ".mp3");
                int index = 1;
                progressBar1.Invoke((int)index);
                yourTube.DownloadEn();
            }
            //}
            //catch (Exception e)
            //{
            //    DownloadSong(uri, directory);
            //}
        }
Пример #8
0
 private void Save_Click(object sender, EventArgs e)
 {
     UserGetSet.input();
     if (String.IsNullOrEmpty(oldPassword.Text))
     {
         MessageBox.Show("Please type in your old password");
     }
     else if (String.IsNullOrEmpty(newPassword.Text))
     {
         MessageBox.Show("Please type in your new password");
     }
     else if (String.IsNullOrEmpty(repeatPassword.Text))
     {
         MessageBox.Show("Please type in your repeat new password");
     }
     else if (newPassword.Text != repeatPassword.Text)
     {
         MessageBox.Show("Your new and repeated passwords dont mach");
     }
     else if (UserGetSet.password != oldPassword.Text)
     {
         MessageBox.Show("Your old password dosent match");
     }
     else
     {
         SQLiteConnection sqlite_conn = new SQLiteConnection("Data Source=YourTubeDB.db; Version = 3; New = True; Compress = True; ");
         sqlite_conn.Open();
         SQLiteCommand sqlite_cmd = sqlite_conn.CreateCommand();
         sqlite_cmd.CommandText = "UPDATE User SET Password = '******' WHERE Username = '******'";
         sqlite_cmd.ExecuteNonQuery();
         UserGetSet.password = newPassword.Text;
         MessageBox.Show("Your password has been successfully changed");
         this.Hide();
         YourTube yourTube = new YourTube();
         yourTube.Show();
     }
 }