public Package() { Tracks = new Track[] { }; NextOid = 10250; }
public Track GetTrack(FileInfo audioFile) { log.InfoFormat("Read meta information from {0}", audioFile); var track = new Track { Path = audioFile.FullName }; try { using (var f = TagLib.File.Create(audioFile.FullName)) { track.Duration = f.Properties.Duration; if (!f.Tag.IsEmpty) { track.Title = f.Tag.Title; track.TrackNumber = f.Tag.Track; track.Album = f.Tag.Album; track.Artists = f.Tag.AlbumArtists.Concat(f.Tag.Performers).ToArray(); } } } catch (Exception ex) { log.Warn(String.Format("Exception ignored while reading {0}", audioFile), ex); } if (track.Artists == null) { track.Artists = new string[] { }; } if (String.IsNullOrEmpty(track.Title)) { track.Title = System.IO.Path.GetFileNameWithoutExtension(track.Path); } if (String.IsNullOrEmpty(track.Album)) { track.Album = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(track.Path)); } if (track.TrackNumber == 0) { track.TrackNumber = GetDirectoryIndex(track.Path); } return track; }