Exemple #1
0
 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);
     }
 }
Exemple #3
0
        /// <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();
        }
Exemple #4
0
        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);
        }
Exemple #6
0
 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));
 }
Exemple #7
0
        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;
        }
Exemple #8
0
        /// <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();
        }
Exemple #9
0
 /// <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));
 }