public static Task SaveAlbumArt(DetailedAlbumInfo info) { var uri = info.LargeImageUri; var extension = Path.GetExtension(uri.ToString()); var folder = App.ImageSavingConfig.Folder; var fileName = App.ImageSavingConfig.Format .Replace("[?artist]", info.Artist) .Replace("[?album]", info.Name) .Replace("[?albumId]", info.ShortInfo.Id) .Replace("[?guid]", Guid.NewGuid().ToString()); var correctedName = AddExtension(fileName, extension) .Let(CorrectInvalidPath); var destination = Path.Combine(folder, correctedName); if (App.ImageSavingConfig.Strategy == ImageSavingStrategy.Ignore && File.Exists(destination)) { Logger.Debug($"File {destination} already exists"); return(Task.CompletedTask); } Logger.Debug($"Downloading image from {uri} to {destination}"); using (var client = new WebClient()) { return(client.DownloadFileTaskAsync(uri, destination)); } }
public static void SaveDetailedAlbumInfo(DetailedAlbumInfo info) { JsonCacheUtils.SaveIntoJsonCache(info, DetailedAlbumClz, info.ShortInfo.Id); }