public void TestGettingTheDiscTagsForACdStub() { var tagSource = new MusicBrainzTagSource(new MockMusicBrainzApi(), new MockCoverArtApi()); var discTags = tagSource.GetTags(DummyData.AppelsEten.TableOfContents).ToList(); Assert.That(discTags, Is.Not.Null); Assert.That(discTags.Count(), Is.EqualTo(1)); var expectedAlbum = new AlbumIdentification { Id = "S0liNSPBm5gjOHw9JtmPPDhXynI-", //Stub has a special Id AlbumArtist = "Ketnet Band", AlbumTitle = "Appels Eten", Year = null, NumberOfTracks = 3 }; expectedAlbum.AddTrack(new TrackIdentification { Title = "Appels Eten q2", TrackNumber = 1 }); expectedAlbum.AddTrack(new TrackIdentification { Title = "Appels Eten Instrumental q2", TrackNumber = 2 }); expectedAlbum.AddTrack(new TrackIdentification { Title = "Appels Eten PB q2", TrackNumber = 3 }); AssertAlbum(discTags.First(), expectedAlbum); }
public void TestGettingAnUnknownDiscId() { var tagSource = new MusicBrainzTagSource(new MockMusicBrainzApi(), new MockCoverArtApi()); var discTags = tagSource.GetTags(DummyData.UnknownCd.TableOfContents).ToList(); Assert.That(discTags.Count, Is.EqualTo(1)); AssertAlbum(discTags.First(), AlbumIdentification.GetEmpty(2)); }
public void TestGetInfoForACdWithCoverArt() { var tagSource = new MusicBrainzTagSource(new MockMusicBrainzApi(), new MockCoverArtApi()); var discTags = tagSource.GetTags(DummyData.MuchAgainstEveryonesAdvice.TableOfContents).ToList(); foreach (var tag in discTags) { Assert.That(tag.AlbumArt, Is.EqualTo(DummyData.MuchAgainstEveryonesAdvice.AlbumArt[tag.Id])); } }
public void TestGettingInfoForACdWithMultipleResults() { var tagSource = new MusicBrainzTagSource(new MockMusicBrainzApi(), new MockCoverArtApi()); var discTags = tagSource.GetTags(DummyData.MuchAgainstEveryonesAdvice.TableOfContents).ToList(); Assert.That(discTags.Count, Is.EqualTo(3)); Assert.That(discTags.ElementAt(0).Id, Is.EqualTo("6d283259-8c9a-3558-9acc-d6c2e429c657")); Assert.That(discTags.ElementAt(1).Id, Is.EqualTo("7cf38b3b-d110-318a-ae18-1d4078c347ce")); Assert.That(discTags.ElementAt(2).Id, Is.EqualTo("d939579c-cd40-4dd7-8927-8030f7932cbc")); }
public void TestGettingTheDiscTags() { var tagSource = new MusicBrainzTagSource(new MockMusicBrainzApi(), new MockCoverArtApi()); var discTags = tagSource.GetTags(DummyData.SteekJeVingerInDeLucht.TableOfContents).ToList(); Assert.That(discTags, Is.Not.Null); Assert.That(discTags.Count(), Is.EqualTo(1)); Assert.That(discTags.First().Id, Is.EqualTo(DummyData.SteekJeVingerInDeLucht.MusicBrainzReleases.Keys.First())); Assert.That(discTags.First().AlbumArtist, Is.EqualTo("Jan De Smet")); Assert.That(discTags.First().AlbumTitle, Is.EqualTo("Steek Je vinger in de lucht")); Assert.That(discTags.First().Year, Is.EqualTo("2005")); Assert.That(discTags.First().NumberOfTracks, Is.EqualTo(14)); Assert.That(discTags.First().Tracks.Count(), Is.EqualTo(14)); Assert.That(discTags.First().Tracks.ElementAt(0).Title, Is.EqualTo("Alles Goed")); Assert.That(discTags.First().Tracks.ElementAt(0).Artist, Is.EqualTo("Jan De Smet")); Assert.That(discTags.First().Tracks.ElementAt(0).TrackNumber, Is.EqualTo(1)); Assert.That(discTags.First().Tracks.ElementAt(13).Title, Is.EqualTo("Steek Je Vinger in de Lucht")); Assert.That(discTags.First().Tracks.ElementAt(13).Artist, Is.EqualTo("Jan De Smet")); Assert.That(discTags.First().Tracks.ElementAt(13).TrackNumber, Is.EqualTo(14)); }
static async Task RipWithMusicBrainz(string driveletter) { using (var drive = CdDrive.Create(driveletter)) { var toc = await drive.ReadTableOfContents(); if (toc == null) { Console.WriteLine("No CD in drive!"); return; } var discId = TagSource.GetTags(toc).ToList(); if (discId.Count == 0) { Console.WriteLine("No matching cd found in MusicBrainz"); return; } var discNumber = 0; if (discId.Count > 1) { Console.WriteLine("Multiple matching CD's found in MusicBrainz"); for (int i = 0; i < discId.Count; i++) { Console.WriteLine("{0}: {1} - {2} (Coverart: {3})", i + 1, discId[i].AlbumArtist, discId[i].AlbumTitle, discId[i].AlbumArt == null ? "no" : "yes"); } Console.WriteLine("Enter the number of the correct cd"); discNumber = Convert.ToInt32(Console.ReadLine()) - 1; } foreach (var track in toc.Tracks) { Console.WriteLine("track {0}: {1} (lenth={2}-{3})", track.TrackNumber, discId[discNumber].Tracks.First(s => s.TrackNumber == track.TrackNumber).Title, track.Offset, track.Offset + track.Sectors); } Console.WriteLine("Enter tracknumber to rip"); var trackNumber = Convert.ToInt32(Console.ReadLine()); using (var trackReader = new TrackReader(drive)) { using (var encoder = new LameMp3Encoder(new EncoderSettings { Output = new OutputLocationBuilder( Environment.GetFolderPath(Environment.SpecialFolder.Desktop), @"encoding\{albumartist}\{albumtitle}\{tracknumber}-{title}.mp3"), Mp3Settings = new Mp3Settings(), Track = discId[discNumber].Tracks.First(s => s.TrackNumber == trackNumber) })) { var cts = new CancellationTokenSource(); trackReader.Progress += (i, a) => Console.WriteLine("{0} of {1} read", i, a); var track = toc.Tracks.First(t => t.TrackNumber == trackNumber); await trackReader.ReadTrack(track, b => encoder.Write(b), cts.Token); } } await drive.Eject(); } }