private static UpdateHelper CreateUpdateHelper(MasterFile masterFile, GracenoteSong songFromAPI, IEnumerable <string> propertiesToVerify) { var oldProps = new List <string>(); var newProps = new List <string>(); foreach (var property in propertiesToVerify) { oldProps.Add(masterFile.TagLibProps[property].ToString()); switch (property) { case "Artist": newProps.Add(songFromAPI.Artist); break; case "Album": newProps.Add(songFromAPI.Album); break; case "Title": newProps.Add(songFromAPI.Title); break; default: break; } } return(new UpdateHelper(masterFile, propertiesToVerify.ToList(), oldProps, newProps)); }
private List <UpdateHelper> ProcessMasterFileUpdates() { var updates = new List <UpdateHelper>(); foreach (MasterFile masterFile in files) { if ((bool)masterFile.TagLibProps["IsCover"] || masterFile.CheckForUpdates == false) { continue; } GracenoteSong songFromAPI = masterFile.TagLibProps["Album"].ToString() == "Singles" ? GracenoteWebAPI.Query(masterFile, includeAlbumInQuery: false) : GracenoteWebAPI.Query(masterFile, includeAlbumInQuery: true); var results = songFromAPI.CheckMetadataEquality(masterFile); var propertiesToVerify = results.Where(pair => pair.Value == false) .Where(pair => pair.Key == "Artist" || pair.Key == "Album" || pair.Key == "Title") .Select(pair => pair.Key); if (propertiesToVerify.Count() > 0) { displayFilesBox.Text += $"\"{masterFile}\" has new or different data. Updating... {Environment.NewLine}"; displayFilesBox.Refresh(); UpdateHelper update = CreateUpdateHelper(masterFile, songFromAPI, propertiesToVerify); updates.Add(update); masterFile.Update(songFromAPI, propertiesToVerify); } else { displayFilesBox.Text += $"\"{masterFile}\" has no new or different data. Not updating. {Environment.NewLine}"; } } return(updates); }