public async Task <List <LastFmArtist> > Search(string artist, int limit = 0) { var parameters = new Dictionary <string, string>(); parameters.Add("artist", artist); if (limit > 0) { parameters.Add("limit", limit.ToString()); } parameters.Add("api_key", _lastFm.ApiKey); var response = await(new CoreRequest(new Uri(LastFmConst.MethodBase + "artist.search"), parameters).Execute()); LastFmErrorProcessor.ProcessError(response); if (response.SelectToken("results.artistmatches.artist") != null) { var artistJson = response.SelectToken("results.artistmatches.artist"); if (artistJson is JArray) { return((from a in response.SelectToken("results.artistmatches.artist") select LastFmArtist.FromJson(a)).ToList()); } else { return new List <LastFmArtist>() { LastFmArtist.FromJson(artistJson) } }; } return(null); }
public async Task <LastFmArtist> GetInfo(string mbid, string artist) { var parameters = new Dictionary <string, string>(); if (!string.IsNullOrEmpty(mbid)) { parameters.Add("mbid", mbid); } else { parameters.Add("artist", artist); } if (!string.IsNullOrEmpty(_lastFm.Lang)) { parameters.Add("lang", _lastFm.Lang); } parameters.Add("api_key", _lastFm.ApiKey); var response = await(new CoreRequest(new Uri(LastFmConst.MethodBase + "artist.getInfo"), parameters).Execute()); LastFmErrorProcessor.ProcessError(response); if (response["artist"] != null) { return(LastFmArtist.FromJson(response["artist"])); } return(null); }
public async Task <List <LastFmArtist> > GetSimilar(string artist, int count = 0) { var parameters = new Dictionary <string, string>(); parameters.Add("artist", artist); if (count > 0) { parameters.Add("limit", count.ToString()); } parameters.Add("api_key", _lastFm.ApiKey); var response = await(new CoreRequest(new Uri(LastFmConst.MethodBase + "artist.getSimilar"), parameters).Execute()); LastFmErrorProcessor.ProcessError(response); if (response.SelectToken("similarartists.artist") != null) { return((from a in response.SelectToken("similarartists.artist") select LastFmArtist.FromJson(a)).ToList()); } return(null); }