/// <summary> /// Get Track by MusicBrainz ID (Avoid using this) /// </summary> /// <param name="mbid">MusicBrainz ID</param> /// <returns></returns> public async Task <LastFmTrack> GetTrackByMbid(string mbid) { string args = string.Format("?method=track.getInfo&mbid={0}&{1}&format=json", mbid, _credentials); Uri url = new Uri(Domain + args); HttpClient webClient = new HttpClient(); string jsonSource = await webClient.GetStringAsync(url); JObject json = JObject.Parse(jsonSource); JToken temp; if (json.TryGetValue("error", out temp)) { LastFmApiExceptionArgs arg = new LastFmApiExceptionArgs(temp.ToObject <int>(), json.GetValue("message").ToString()); throw new LastFmApiException(arg); } LastFmTrack album = LastFmTrack.Parse(json); return(album); }
public async Task <IList <LastFmSearchTrackResult> > SearchTrack(string trackTitle, string trackArtist) { string args = $"?method=track.search&track={trackTitle}&artist={trackArtist}&{_credentials}&format=json"; Uri url = new Uri(Domain + args); HttpClient webClient = new HttpClient(); string jsonSource = await webClient.GetStringAsync(url); JObject json = JObject.Parse(jsonSource); JToken temp; if (json.TryGetValue("error", out temp)) { LastFmApiExceptionArgs arg = new LastFmApiExceptionArgs(temp.ToObject <int>(), json.GetValue("message").ToString()); throw new LastFmApiException(arg); } var resuts = ParseSearchTrackResults(json); return(resuts); }
public LastFmApiException(LastFmApiExceptionArgs args) : base(args.Message) { Args = args; }