Пример #1
0
        public async Task getLyrics(string artist, string song, string lyricsURL = "", string coverImg = "", string songId = "")
        {
            if (lyricsURL.Length == 0)
            {
                // Search the song on Genius
                var searchResult = await geniusClient.SearchClient.Search(TextFormat.Dom, Uri.EscapeDataString(artist) + "-" + Uri.EscapeDataString(song));

                // Save all the valid search results
                for (var r = 0; r < searchResult.Response.Count(); r++)
                {
                    Hit h = searchResult.Response[r];
                    if (h.Type != "song")
                    {
                        break;
                    }
                    string[] hContent = h.Result.ToString().Replace('"', '\'').Split('\n');

                    MainWindow.lyricsURL lyricsObj = new MainWindow.lyricsURL();
                    lyricsObj.source = "Genius";
                    for (var x = 0; x < hContent.Count(); x++)
                    {
                        var ln = hContent[x];
                        if (ln.Contains("'id':"))
                        {
                            lyricsObj.id = ln.Replace("  'id': ", "").Replace(",\r", "");
                            if (lyricsObj.img != null)
                            {
                                break;
                            }
                        }
                        else if (ln.Contains("'api_path':"))
                        {
                            lyricsObj.url = "https://genius.com" + ln.Replace("  'api_path': ", "").Replace(",\r", "").Replace("'", "");
                        }
                        else if (ln.Contains("'header_image_thumbnail_url':"))
                        {
                            lyricsObj.img = ln.Replace("  'header_image_thumbnail_url': '", "").Replace("',\r", "");
                            if (lyricsObj.id != null)
                            {
                                break;
                            }
                        }
                    }

                    mainW.lyricsURLs.Add(lyricsObj);
                }
            }
            else
            {
                MainWindow.lyricsURL lyricsObj = new MainWindow.lyricsURL();
                lyricsObj.source = "Genius";
                lyricsObj.id     = songId;
                lyricsObj.url    = lyricsURL;
                lyricsObj.img    = coverImg;
                mainW.lyricsURLs.Add(lyricsObj);
            }
        }
Пример #2
0
        public void getLyrics(string artist, string song, ref List <MainWindow.lyricsURL> lyricsURLs, string lyricsURL = "")
        {
            if (lyricsURL.Length == 0)
            {
                // Search the song on Tekstowo.pl
                string searchURL = "https://www.tekstowo.pl/szukaj,wykonawca," + artist.Replace(" ", "+") + ",tytul," + song.Replace(" ", "+") + ".html";
                string response  = getHTTPSRequest(searchURL);
                response = response.Replace("\"", "'");
                List <string> responseArr = response.Split('\n').ToList();

                // Save all the valid search results
                foreach (string ln in responseArr)
                {
                    if (ln.ToLower().Trim().Contains(song.ToLower().Trim()) && ln.ToLower().Trim().Contains(artist.ToLower().Trim()) && ln.Contains("href"))
                    {
                        try
                        {
                            // Found
                            int    firstPoint  = ln.IndexOf("href='") + "href='".Length;
                            int    secondPoint = ln.IndexOf("'", firstPoint);
                            string songLink    = "https://www.tekstowo.pl" + ln.Substring(firstPoint, secondPoint - firstPoint);

                            MainWindow.lyricsURL lyricsObj = new MainWindow.lyricsURL();
                            lyricsObj.id     = "";
                            lyricsObj.img    = "";
                            lyricsObj.url    = songLink;
                            lyricsObj.source = "Tekstowo.pl";

                            lyricsURLs.Add(lyricsObj);
                        }
                        catch (Exception ex)
                        {
                        }
                        break;
                    }
                }
            }
            else
            {
                MainWindow.lyricsURL lyricsObj = new MainWindow.lyricsURL();
                lyricsObj.id     = "";
                lyricsObj.img    = "";
                lyricsObj.url    = lyricsURL;
                lyricsObj.source = "Tekstowo.pl";

                lyricsURLs.Add(lyricsObj);
            }
        }
Пример #3
0
        public void getLyrics(string artist, string song, ref List <MainWindow.lyricsURL> lyricsURLs, string lyricsURL = "")
        {
            if (lyricsURL.Length == 0)
            {
                // Search the song on Musixmatch
                string searchURL = "https://www.musixmatch.com/search/" + Uri.EscapeDataString(artist) + "-" + Uri.EscapeDataString(song) + "/tracks";
                string response  = getHTTPSRequest(searchURL);
                response = response.Replace("\"", "'");

                // Save all the valid search results
                while (response.Contains("href='/lyrics/"))
                {
                    try
                    {
                        int    a    = response.IndexOf("href='/lyrics/");
                        int    b    = response.IndexOf("'>", a);
                        string link = response.Substring(a, b - a).Replace("href='", "");

                        MainWindow.lyricsURL lyricsObj = new MainWindow.lyricsURL();
                        lyricsObj.id     = "";
                        lyricsObj.img    = "";
                        lyricsObj.url    = "https://www.musixmatch.com" + link;
                        lyricsObj.source = "Musixmatch";

                        lyricsURLs.Add(lyricsObj);
                        response = response.Substring(b, response.Length - b);
                    }
                    catch (Exception ex)
                    {
                        break;
                    }
                }
            }
            else
            {
                MainWindow.lyricsURL lyricsObj = new MainWindow.lyricsURL();
                lyricsObj.id     = "";
                lyricsObj.img    = "";
                lyricsObj.url    = lyricsURL;
                lyricsObj.source = "Musixmatch";

                lyricsURLs.Add(lyricsObj);
            }
        }