private async Task <string> GetArtworkFromInternet(Album album) { if (album.AlbumArtist.Equals(Defaults.UnknownArtistText) || album.AlbumTitle.Equals(Defaults.UnknownAlbumText)) { return(string.Empty); } Api.Lastfm.Album lfmAlbum = await Api.Lastfm.LastfmApi.AlbumGetInfo((string)album.AlbumArtist, (string)album.AlbumTitle, false, "EN"); if (string.IsNullOrEmpty(lfmAlbum.LargestImage())) { return(string.Empty); } return(await this.cacheService.CacheArtworkAsync(new Uri(lfmAlbum.LargestImage()))); }
public static async Task <Uri> GetAlbumArtworkFromInternetAsync(string albumTitle, IList <string> albumArtists, string trackTitle = "", IList <string> trackArtists = null) { string title = string.Empty; List <string> artists = new List <string>(); // Title if (!string.IsNullOrEmpty(albumTitle)) { title = albumTitle; } else if (!string.IsNullOrEmpty(trackTitle)) { title = trackTitle; } // Artist if (albumArtists != null && albumArtists.Count > 0) { artists.AddRange(albumArtists.Where(a => !string.IsNullOrEmpty(a))); } if (trackArtists != null && trackArtists.Count > 0) { artists.AddRange(trackArtists.Where(a => !string.IsNullOrEmpty(a))); } if (string.IsNullOrEmpty(title) || artists == null) { return(null); } foreach (string artist in artists) { Api.Lastfm.Album lfmAlbum = await Api.Lastfm.LastfmApi.AlbumGetInfo(artist, title, false, "EN"); if (!string.IsNullOrEmpty(lfmAlbum.LargestImage())) { return(new Uri(lfmAlbum.LargestImage())); } } return(null); }
public static async Task <Uri> GetAlbumArtworkFromInternetAsync(string title, string artist, string alternateTitle = "", string alternateArtist = "") { string albumTitle = string.Empty; string albumArtist = string.Empty; // Title if (!string.IsNullOrEmpty(title)) { albumTitle = title; } else if (!string.IsNullOrEmpty(alternateTitle)) { albumTitle = alternateTitle; } // Artist if (!string.IsNullOrEmpty(artist)) { albumArtist = artist; } else if (!string.IsNullOrEmpty(alternateArtist)) { albumArtist = alternateArtist; } if (string.IsNullOrEmpty(albumTitle) || string.IsNullOrEmpty(albumArtist)) { return(null); } Api.Lastfm.Album lfmAlbum = await Api.Lastfm.LastfmApi.AlbumGetInfo(albumArtist, albumTitle, false, "EN"); if (!string.IsNullOrEmpty(lfmAlbum.LargestImage())) { return(new Uri(lfmAlbum.LargestImage())); } return(null); }