Writes gme, tta, html, and album art files for a package
Inheritance: HtmlGenerator
Example #1
0
        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);
        }
Example #2
0
        static void Main(string[] args)
        {
            log4net.Config.BasicConfigurator.Configure();

            var pen = TipToiPen.GetAll().FirstOrDefault();
            if (pen == null)
            {
                pen = TipToiPen.Simulated;
                log.InfoFormat("Pen is not attached. Output will be written to {0}", pen.RootDirectory);
            }

            var package = Package.CreateFromInputPaths(args);
    
            var cacheDirectory = Path.Combine(About.LocalApplicationDataDirectory, "cache");
            var converter = new MediaFileConverter(cacheDirectory);

            var structure = new PackageDirectoryStructure(pen.RootDirectory, package);
            var packageBuilder = new PackageBuilder(structure, converter, Settings.Read().CreateOidSvgWriter());
            packageBuilder.Build(CancellationToken.None).Wait();
        }
Example #3
0
        public async Task Build(CancellationToken cancellationToken)
        {
            var p = packageDirectoryStructure.Package;

            PrepareInputFiles(cancellationToken);

            cancellationToken.ThrowIfCancellationRequested();

            // check if size > MaxGmeSize and split into parts if required
            var parts = Split(p);
            if (parts.Count > 1)
            {
                foreach (var i in parts)
                {
                    var structure = new PackageDirectoryStructure(Path.GetDirectoryName(this.packageDirectoryStructure.GmeFile), i);
                    var pb = new PackageBuilder(structure, this.converter, OidSvgWriter);
                    await pb.Build(cancellationToken);
                }
                return;
            }

            // write yaml
            WriteYaml();

            // write html
            WriteHtml(cancellationToken);

            // open html
            Process.Start(packageDirectoryStructure.HtmlFile);

            cancellationToken.ThrowIfCancellationRequested();

            // create gme
            await Assemble(cancellationToken);

            log.InfoFormat("{0} was sucessfully built.", packageDirectoryStructure.GmeFile);
        }
Example #4
0
        Task Convert(CancellationToken cancel, IList<string> files, string title, string productId)
        {
            return Task.Factory.StartNew(async () => 
            {
                try
                {
                    var package = Package.CreateFromInputPaths(files);
                    
                    if (!String.IsNullOrEmpty(title))
                    {
                        package.Title = title;
                    }
                    if (!String.IsNullOrEmpty(productId))
                    {
                        package.ProductId = UInt16.Parse(productId);
                    }

                    var converter = Context.GetDefaultMediaFileConverter();

                    var pen = TipToiPen.GetAll().First();
                    var packageBuilder = new PackageBuilder(
                        new PackageDirectoryStructure(pen.RootDirectory, package), converter);

                    await packageBuilder.Build(cancel);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }
            }, cancel);
        }