예제 #1
0
 private async Task<byte[]> DownloadArtistPictureFromLastFm(string artistName)
 {
     var lastFmClient = new LastFmClient();
     var lastFmArtist = await lastFmClient.GetArtistInfo(artistName);
     if (lastFmArtist == null) return null;
     try
     {
         var clientPic = new HttpClient();
         var imageElement = lastFmArtist.Images.LastOrDefault(node => !string.IsNullOrEmpty(node.Url));
         if (imageElement == null) return null;
         HttpResponseMessage responsePic = await clientPic.GetAsync(imageElement.Url);
         byte[] img = await responsePic.Content.ReadAsByteArrayAsync();
         return img;
     }
     catch (Exception)
     {
         Debug.WriteLine("Error getting or saving art from LastFm.");
         return null;
     }
 }
예제 #2
0
 public async Task<string> GetArtistBiography(string artistName)
 {
     if (string.IsNullOrEmpty(artistName)) return null;
     var biography = string.Empty;
     try
     {
         var lastFmClient = new LastFmClient();
         var artistInformation = await lastFmClient.GetArtistInfo(artistName);
         biography = artistInformation != null ? artistInformation.Biography : String.Empty;
     }
     catch
     {
         Debug.WriteLine("Failed to get artist biography from LastFM. Returning nothing.");
     }
     return biography;
 }