Ejemplo n.º 1
0
 /// <summary>
 /// Function to edit lyrics (incomplete)
 /// </summary>
 /// <param name="lyrics"></param>
 public void EditLyrics(Lyrics lyrics)
 {
     Dictionary<string, string> arguments = new Dictionary<string, string>();
     arguments.Add("cs", lyrics.Checksum);
     arguments.Add("id", lyrics.SongID);
     string response = SendRequest(HttpMethod.GET, "http://lyricsfly.com/search/correction.php?", arguments);
     ParseResponse(response);
 }
Ejemplo n.º 2
0
        private Lyrics ParseResponse(string response)
        {
            if (!string.IsNullOrEmpty(response))
            {
                XDocument xdoc = XDocument.Parse(response);
                XElement  xele = xdoc.Element("start");

                if (xele != null)
                {
                    string status = xele.GetElementValue("status");
                    if (!string.IsNullOrEmpty(status))
                    {
                        switch (status)
                        {
                        case "200":     // OK - Results are returned. All parameters checked ok.
                        case "300":     // TESTING LIMITED - Temporary access. Limited content. All parameters checked ok.
                            xele = xele.Element("sg");
                            if (xele != null)
                            {
                                Lyrics lyric = new Lyrics();
                                lyric.Checksum   = xele.GetElementValue("cs");
                                lyric.SongID     = xele.GetElementValue("id");
                                lyric.ArtistName = xele.GetElementValue("ar");
                                lyric.Title      = xele.GetElementValue("tt");
                                lyric.AlbumName  = xele.GetElementValue("al");
                                lyric.Text       = xele.GetElementValue("tx").Replace("[br]", string.Empty);

                                return(lyric);
                            }
                            break;

                        case "204":     // NO CONTENT
                            Errors.Add("Parameter query returned no results. All parameters checked ok.");
                            break;

                        case "400":     // MISSING KEY
                            Errors.Add("Parameter “i” missing. Authorization failed.");
                            break;

                        case "401":     // UNAUTHORIZED
                            Errors.Add("Parameter “i” invalid. Authorization failed.");
                            break;

                        case "402":     // LIMITED TIME
                            Errors.Add("Query request too soon. Limit query requests. Time of delay is shown in <delay> tag in milliseconds.");
                            break;

                        case "406":     // QUERY TOO SHORT
                            Errors.Add("Query request string is too short. All other parameters checked ok.");
                            break;

                        default:
                            Errors.Add("Unknown status.");
                            break;
                        }
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 3
0
        private Lyrics ParseResponse(string response)
        {
            if (!string.IsNullOrEmpty(response))
            {
                XDocument xdoc = XDocument.Parse(response);
                XElement xele = xdoc.Element("start");

                if (xele != null)
                {
                    string status = xele.GetElementValue("status");
                    if (!string.IsNullOrEmpty(status))
                    {
                        switch (status)
                        {
                            case "200": // OK - Results are returned. All parameters checked ok.
                            case "300": // TESTING LIMITED - Temporary access. Limited content. All parameters checked ok.
                                xele = xele.Element("sg");
                                if (xele != null)
                                {
                                    Lyrics lyric = new Lyrics();
                                    lyric.Checksum = xele.GetElementValue("cs");
                                    lyric.SongID = xele.GetElementValue("id");
                                    lyric.ArtistName = xele.GetElementValue("ar");
                                    lyric.Title = xele.GetElementValue("tt");
                                    lyric.AlbumName = xele.GetElementValue("al");
                                    lyric.Text = xele.GetElementValue("tx").Replace("[br]", string.Empty);

                                    return lyric;
                                }
                                break;
                            case "204": // NO CONTENT
                                Errors.Add("Parameter query returned no results. All parameters checked ok.");
                                break;
                            case "400": // MISSING KEY
                                Errors.Add("Parameter “i” missing. Authorization failed.");
                                break;
                            case "401": // UNAUTHORIZED
                                Errors.Add("Parameter “i” invalid. Authorization failed.");
                                break;
                            case "402": // LIMITED TIME
                                Errors.Add("Query request too soon. Limit query requests. Time of delay is shown in <delay> tag in milliseconds.");
                                break;
                            case "406": // QUERY TOO SHORT
                                Errors.Add("Query request string is too short. All other parameters checked ok.");
                                break;
                            default:
                                Errors.Add("Unknown status.");
                                break;
                        }
                    }
                }
            }

            return null;
        }