/// <summary> /// Get the song lyrics for a given song /// </summary> /// <param name="artist">The artist who performs the song</param> /// <param name="title">The title of the song</param> /// <returns></returns> public async Task <string> GetSongLyrics(string artist, string title) { string lyrics = null; if (title.Contains('/')) { int found = title.IndexOf('/'); title = title.Substring(0, found); } try { string endpoint = String.Format("{0}/{1}", artist.ToLower(), title); string responseData = await _clientManager.GetJsonResponse(endpoint); var dict = JsonConvert.DeserializeObject <Dictionary <string, string> >(responseData); lyrics = dict["lyrics"]; } catch (Exception) { } return(lyrics); }
/// <summary> /// Get the artist Id being used in the MusicBrainz database for the artist /// specified by the input parameter /// </summary> /// <param name="artist">The artist name e.g. Coldplay</param> /// <returns>The Artist Id</returns> public async Task <string> GetArtistId(string artist) { string artistId = null; string endpoint = String.Format("artist?query={0}", artist); string responseData = await _clientManager.GetJsonResponse(endpoint); if (responseData != null) { // Parse the result into our ArtistWrapper, there could be multiple matches. ArtistWrapper wrapper = JsonConvert.DeserializeObject <ArtistWrapper>(responseData); // Only take an exact match IEnumerable <ArtistSearchResult> matches = wrapper.Artists.Where(a => a.Name.Equals(artist, StringComparison.OrdinalIgnoreCase)); if (matches.Count() >= 1) { artistId = matches.ToList()[0].Id; } } return(artistId); }