private void PopulateDatabase(IEnumerable<MPDSongResponseBlock> response) { foreach (MPDSongResponseBlock block in response) { Song song = new Song(block); song.Date = song.IsSpotify ? m_DataModel.YearNormalizer.Normalize(block.Date) : m_DataModel.CustomDateNormalizer.Normalize(block.Date); song.Artist = GetOrCreateArtist(SelectArtistTag(block)); song.Genre = GetOrCreateGenre(block.Genre); song.Album = GetOrCreateAlbum(block); song.GenreFilteredAlbum = GetOrCreateGenreFilteredAlbum(song.Album, block); song.Directory = GetOrCreateDirectory(song.Path); Songs[song.Path] = song; AddAlbumExpansion(song.Album, song); AddGenreFilteredAlbumExpansion(song.GenreFilteredAlbum, song); } }
private static bool Match(Song song, string[] fragments) { string title = song.Title == null ? null : song.Title.ToLower(); string album = song.Album == null ? null : song.Album.Title.ToLower(); string artist = song.Artist == null ? null : song.Artist.Name.ToLower(); return fragments.All(e => artist != null && artist.Contains(e) || album != null && album.Contains(e) || title != null && title.Contains(e)); }
private void AddGenreFilteredAlbumExpansion(GenreFilteredAlbum parent, Song child) { if (!m_GenreFilteredAlbumExpansion.ContainsKey(parent)) { m_GenreFilteredAlbumExpansion[parent] = new SortedSet<Song>(); } m_GenreFilteredAlbumExpansion[parent].Add(child); }