private TrackInfoCache CreateTrackInfoCache(SQLiteDataReader reader) { TrackInfoCache trackInfoCache = this.Deserialize <TrackInfoCache>(reader.GetBytes("bson")); trackInfoCache.Id = reader.GetInt64("id").ToString(); return(trackInfoCache); }
public void Save(TrackInfoCache trackInfo) { if (!this.localTrackInfos.Any(t => t.Id.Equals(trackInfo.Id))) { this.localTrackInfos.Add(trackInfo); } }
public LocalAlbum(TrackInfoCache trackInfo) { this.Title = trackInfo.Album; this.DiscCount = trackInfo.DiscCount; this.Year = trackInfo.Year; this.Genre = trackInfo.Genre; this.AlbumArtist = trackInfo.AlbumArtist; this.Discs = new LocalDisc[trackInfo.DiscCount]; this.Discs[trackInfo.Disc - 1] = new LocalDisc(trackInfo); }
public void Add(TrackInfoCache track) { LocalAlbum album; if (this.Albums.TryGetValue(track.Album, out album)) { album.Add(track); } else { this.Albums[track.Album] = new LocalAlbum(track); } }
public void Add(TrackInfoCache track) { this.PreprocessTrack(track); LocalAlbumArtist albumArtist; if (this.AlbumArtists.TryGetValue(track.AlbumArtist, out albumArtist)) { albumArtist.Add(track); } else { this.AlbumArtists[track.AlbumArtist] = new LocalAlbumArtist(track); } }
private void PreprocessTrack(TrackInfoCache track) { int i = track.Album.Length - 1; while (i >= 0 && char.IsDigit(track.Album[i])) { --i; } --i; if (i > 0 && i + 2 < track.Album.Length && track.Album.Substring(i, 2) == "CD") { Assert.IsTrue(int.Parse(track.Album.Substring(i + 2)) == track.Disc); track.Album = track.Album.Substring(0, i - 1); } }
public void Add(TrackInfoCache t) { //Assert.IsTrue(this.Title == t.Album); //Assert.IsTrue(this.AlbumArtist == t.AlbumArtist); //Assert.IsTrue(this.DiscCount == t.DiscCount); //Assert.IsTrue(this.Year == t.Year); //Assert.IsTrue(this.Genre == t.Genre); if (this.Discs[t.Disc - 1] == null) { this.Discs[t.Disc - 1] = new LocalDisc(t); } else { this.Discs[t.Disc - 1].Add(t); } }
public void Save(TrackInfoCache trackInfo) { this.saveTrackCache.Parameters["bson"].Value = trackInfo.ToBson(this.bsonWriterSettings); this.saveTrackCache.ExecuteNonQuery(); }
public LocalAlbumArtist(TrackInfoCache trackInfo) { this.Name = trackInfo.AlbumArtist; this.Albums = new Dictionary <string, LocalAlbum>(); this.Add(trackInfo); }
public void Save(TrackInfoCache trackInfo) { this.trackInfosCollection.Save(trackInfo); }
public void Scan() { Dictionary <string, TrackInfoCache> cache = new Dictionary <string, TrackInfoCache>(); foreach (TrackInfoCache localTrackInfo in this.collectionManager.LocalTrackInfos) { cache[localTrackInfo.Filename] = localTrackInfo; } //using (var transaction = this.collectionManager.BeginTransaction()) //{ string[] files; if (Directory.Exists(this.collectionManager.Settings.MusicDirectory)) { files = Directory.GetFiles(this.collectionManager.Settings.MusicDirectory, "*", SearchOption.AllDirectories) .Where(f => f.EndsWith(".flac") || f.EndsWith(".mp3")) .ToArray(); } else { files = new string[0]; } int processed = 0; foreach (string file in files) { TrackInfoCache trackInfo; FileInfo fileInfo = new FileInfo(file); if (!cache.TryGetValue(file, out trackInfo) || trackInfo.LastWriteTime != fileInfo.LastWriteTime.Ticks) { if (trackInfo == null) { trackInfo = new TrackInfoCache(); } trackInfo.Filename = file; trackInfo.RelativeFilename = trackInfo.Filename.Substring(this.collectionManager.Settings.MusicDirectory.Length).Trim('\\').Trim('/'); trackInfo.LastWriteTime = fileInfo.LastWriteTime.Ticks; using (TagLib.File mediaFile = TagLib.File.Create(file)) { trackInfo.Artist = mediaFile.Tag.JoinedPerformers; trackInfo.AlbumArtist = mediaFile.Tag.JoinedAlbumArtists; trackInfo.Album = mediaFile.Tag.Album; trackInfo.Disc = (int)mediaFile.Tag.Disc; trackInfo.DiscCount = (int)mediaFile.Tag.DiscCount; trackInfo.Track = (int)mediaFile.Tag.Track; trackInfo.TrackCount = (int)mediaFile.Tag.TrackCount; trackInfo.Title = mediaFile.Tag.Title; trackInfo.Genre = mediaFile.Tag.JoinedGenres; trackInfo.Year = (int)mediaFile.Tag.Year; } this.collectionManager.Save(trackInfo); } this.LocalCollection.Add(trackInfo); ++processed; ProgressChangedEventArgs eventArgs = new ProgressChangedEventArgs((double)processed / files.Length); this.OnProgressChanged(eventArgs); if (eventArgs.Cancel) { return; } } //transaction.Commit(); //} }
public void Add(TrackInfoCache t) { Assert.IsTrue(this.Tracks[t.Track - 1] == null); this.Tracks[t.Track - 1] = t; }
public LocalDisc(TrackInfoCache trackInfo) { this.Tracks = new TrackInfoCache[trackInfo.TrackCount]; this.Tracks[trackInfo.Track - 1] = trackInfo; }