private ImportedAlbumTrack ParseTrack(DataRow dataRow, int nextTrackNum) { var track = new ImportedAlbumTrack(); track.Title = dataRow.GetString(AlbumFileField.Title); var trackNumMatch = numRegex.Match(dataRow.GetString(AlbumFileField.Track, string.Empty)); if (trackNumMatch.Success) { track.TrackNum = int.Parse(trackNumMatch.Groups[1].Value); } else { track.TrackNum = nextTrackNum; } var artists = new List <string>(); var composer = dataRow.GetString(AlbumFileField.Composer, string.Empty); if (composer != string.Empty) { artists.Add(composer); } var artist = dataRow.GetString(AlbumFileField.Artist, string.Empty); if (artist != string.Empty) { var featPos = artist.IndexOf("feat.", StringComparison.InvariantCultureIgnoreCase); if (featPos != -1) { var vocaloidName = artist.Substring(featPos + 5, artist.Length - featPos - 5).Trim(); track.VocalistNames = GetArtistNames(vocaloidName); artist = artist.Substring(0, featPos).Trim(); } else { track.VocalistNames = new string[] {}; } artists.AddRange(GetArtistNames(artist)); } track.ArtistNames = artists.Distinct().ToArray(); return(track); }
private InspectedTrack InspectTrack(ISession session, ImportedAlbumTrack importedTrack, IEnumerable <Artist> artists, Album album) { var inspected = new InspectedTrack(importedTrack); var existingTrack = album != null?album.GetSongByTrackNum(importedTrack.DiscNum, importedTrack.TrackNum) : null; var existingSong = existingTrack != null && existingTrack.Song != null ? existingTrack.Song : FindSong(session, importedTrack.Title, artists); if (existingSong != null) { inspected.ExistingSong = new SongContract(existingSong, PermissionContext.LanguagePreference); } inspected.Selected = existingTrack != null; return(inspected); }
private void AssertTrack(string expectedTitle, string expectedVocalists, ImportedAlbumTrack track) { track.Should().NotBeNull("Track was parsed successfully"); track.Title.Should().Be(expectedTitle, "Title"); string.Join(", ", track.VocalistNames).Should().Be(expectedVocalists, "Vocalists"); }
private void AssertTrack(string expectedTitle, string expectedVocalists, ImportedAlbumTrack track) { Assert.IsNotNull(track, "Track was parsed successfully"); Assert.AreEqual(expectedTitle, track.Title, "Title"); Assert.AreEqual(expectedVocalists, string.Join(", ", track.VocalistNames), "Vocalists"); }