コード例 #1
0
        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);
        }
コード例 #2
0
        public void Gn_Query_Test_ReturnsValidResponse()
        {
            var songFromAPI = GracenoteWebAPI.Query(file);

            if (String.IsNullOrEmpty(songFromAPI.Artist))
            {
                Assert.Fail();
            }
            if (String.IsNullOrEmpty(songFromAPI.Album))
            {
                Assert.Fail();
            }
            if (String.IsNullOrEmpty(songFromAPI.Title))
            {
                Assert.Fail();
            }
        }