Ejemplo n.º 1
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            tbLyrics.Clear();
            pbImage.ImageLocation = null;

            if (string.IsNullOrEmpty(tbArtist.Text) || string.IsNullOrEmpty(tbSong.Text))
            {
                MessageBox.Show("Please enter artist and title!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }


            string url = "https://api.lyrics.ovh/v1/" + tbArtist.Text + "/" + tbSong.Text;


            using (WebClient wc = new WebClient()
            {
                Encoding = Encoding.UTF8
            })
            {
                try
                {
                    var json = wc.DownloadString(url).Replace("\\n", Environment.NewLine).ToLower();

                    var result = JsonConvert.DeserializeObject <Lyrics>(json);

                    tbLyrics.Text = result.lyrics;

                    var document = new HtmlWeb().Load(@"http://images.google.com/images?q=" + tbArtist.Text + "&start=1&ndsp=2");

                    var ImageURLS = document.DocumentNode.Descendants("img")
                                    .Select(ee => ee.GetAttributeValue("src", null))
                                    .Where(s => !String.IsNullOrEmpty(s)).ToList();

                    Random rnd    = new Random();
                    int    random = rnd.Next(1, ImageURLS.Count);

                    pbImage.ImageLocation = ImageURLS[random].ToString();
                }
                catch (Exception)
                {
                    if (MessageBox.Show("No lyrics found!Do you want to listen song on YouTube?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) !=
                        DialogResult.Yes)
                    {
                        return;
                    }

                    List <string> songDetails = new List <string>();
                    songDetails = TrailerUrl();
                    YouTubeForm frm = new YouTubeForm(songDetails);
                    frm.ShowDialog();
                }
            }
        }
Ejemplo n.º 2
0
        private void linkSong_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (string.IsNullOrEmpty(tbArtist.Text) || string.IsNullOrEmpty(tbSong.Text))
            {
                MessageBox.Show("Please enter artist and title!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            List <string> songDetails = new List <string>();

            songDetails = TrailerUrl();
            YouTubeForm frm = new YouTubeForm(songDetails);

            frm.ShowDialog();
        }