public void AddDefaultCategories() { CategoriesRead.WaitOne(); AddCategory(new Category(Constants.Artist)); AddCategory(new Category(Constants.Album)); AddCategory(new Category(Constants.Genre)); AddCategory(new Category(Constants.Uncategorized)); }
public void InsertFromFile(string filename) { CategoriesRead.WaitOne(); try { Logger.Debug("Attempting to add {0}", filename); if (!File.Exists(filename)) { Logger.Error("File {0} does not exist", filename); return; } using (var file = TagLib.File.Create(filename)) { var song = new Song(file.Tag.Title, filename, (int)file.Properties.Duration.TotalMilliseconds, new Bpm(0, true), 0); AddBaseTags(song, ArtistCategory, file.Tag.AlbumArtists); AddBaseTags(song, GenreCategory, file.Tag.Genres); if (file.Tag.Album != null) { var albumTag = AlbumCategory[file.Tag.Album] ?? new Tag(file.Tag.Album, AlbumCategory); TagSong(song, albumTag); } if (file.Tag.BeatsPerMinute > 0 && file.Tag.BeatsPerMinute < int.MaxValue) { song.Bpm = new Bpm((int)file.Tag.BeatsPerMinute, false); } AddSong(song); //SaveChanges(); } } catch (Exception e) { Logger.Error("Couldn't open file with TagLib: {0}\n{1}", e.Message, e.StackTrace); } }