IEnumerable <IPicture> GetAlbumPictures() { return(Tracks.Select(t => System.IO.Path.GetDirectoryName(t.Path)).Distinct() .SelectMany(d => new System.IO.DirectoryInfo(d).GetFiles()) .Where(f => AlbumReader.IsImageFile(f)) .OrderByDescending(f => AlbumReader.IsFrontCover(f)) .Select(f => new Picture(f))); }
public void ConvertAllTestFiles() { var audioFiles = new AlbumReader().GetAudioFiles(new[] { TestFile(@"audio") }).ToList(); Assert.AreEqual(4, audioFiles.Count); foreach (var i in audioFiles) { TestConvert(i); } }
/// <summary> /// Add all new tracks found in inputfiles /// </summary> /// <param name="inputFiles"></param> public void AddTracks(IEnumerable <string> inputFiles) { var albumReader = new AlbumReader(); var existing = Tracks.ToLookup(_ => _.Path); var toAdd = albumReader.GetTracks(albumReader.GetAudioFiles(inputFiles)) .Where(t => !existing.Contains(t.Path)); foreach (var track in toAdd) { track.Oid = this.GetNextOid(); } Tracks = Tracks.Concat(toAdd) .OrderBy(_ => _.Album) .ThenBy(_ => _.TrackNumber) .ToArray(); }
public static Package CreateFromInputPaths(IEnumerable <string> inputPaths) { var albumReader = new AlbumReader(); var audioFiles = albumReader.GetAudioFiles(inputPaths); var package = new Package(new ProductIdProvider()) { Tracks = albumReader.GetTracks(audioFiles) }; var artists = package.Tracks.SelectMany(track => track.Artists).Distinct(); package.Title = String.Join(", ", artists); return(package); }
public void PackageBuilderTest() { var penDirectory = TestFile("penDirectory"); PathUtil.EnsureNotExists(penDirectory); PathUtil.EnsureDirectoryExists(penDirectory); var converter = new MediaFileConverter(TestFile("media-cache")); var albumReader = new AlbumReader(); var package = Package.CreateFromInputPaths(new[] { TestFile("audio") }); package.Albums.First().Tracks = Enumerable.Range(0, 20).Select(_ => package.Albums.First().Tracks.First()).ToArray(); package.ProductId = 800; var structure = new PackageDirectoryStructure(penDirectory, package); var pb = new PackageBuilder(structure, converter); pb.Build(CancellationToken.None).Wait(); Console.WriteLine(structure.GmeFile); }
public void ReadArtist() { var audioFile = TestFile(@"audio\187950__soundmatch24__rnb-beat.mp3"); var track = new AlbumReader().GetTrack(new FileInfo(audioFile)); Assert.AreEqual("Soundmatch", String.Join(", ", track.Artists)); }
public static Package CreateFromInputPaths(IEnumerable<string> inputPaths) { var albumReader = new AlbumReader(); var audioFiles = albumReader.GetAudioFiles(inputPaths); var package = new Package(new ProductIdProvider()) { Tracks = albumReader.GetTracks(audioFiles) }; var artists = package.Tracks.SelectMany(track => track.Artists).Distinct(); package.Title = String.Join(", ", artists); return package; }
/// <summary> /// Add all new tracks found in inputfiles /// </summary> /// <param name="inputFiles"></param> public void AddTracks(IEnumerable<string> inputFiles) { var albumReader = new AlbumReader(); var existing = Tracks.ToLookup(_ => _.Path); var toAdd = albumReader.GetTracks(albumReader.GetAudioFiles(inputFiles)) .Where(t => !existing.Contains(t.Path)); foreach (var track in toAdd) { track.Oid = this.GetNextOid(); } Tracks = Tracks.Concat(toAdd) .OrderBy(_ => _.Album) .ThenBy(_ => _.TrackNumber) .ToArray(); }
/// <summary> /// Extract an /// </summary> /// <param name="picture"></param> /// <returns></returns> string Extract(TagLib.IPicture picture) { PathUtil.EnsureDirectoryExists(packageDirectoryStructure.HtmlMediaDirectory); return(AlbumReader.ExportPicture(picture, packageDirectoryStructure.HtmlMediaDirectory)); }