.then(function writeResult (pixels) { // FIXME find a good format to output program.output.write(["P3\n# gl.ppm\n", program.width, " ", program.height, "\n255\n"].join("")); for(var i=0; i<pixels.length; ++i) { program.output.write(pixels[i] + " "); } program.output.end(); })
function pluckScreenName(res, next) { var screenName = res.screen_name; program.output = program.output.replace('<screen_name>', screenName) next(null); },
request = request.defaults({ timeout: timeout, headers: { 'Referer': 'http://www.javbus.xyz', 'Cookie': 'existmag=all' } }); if (proxy) { request = request.defaults({ 'proxy': proxy }); } var count = parseInt(program.limit); var hasLimit = (count !== 0), targetFound = false; var output = program.output.replace(/['"]/g, ''); var errorCount = 0; console.log('========== 获取xyz资源站点:%s =========='.green.bold, baseUrl); console.log('并行连接数:'.green, parallel.toString().green.bold, ' ', '连接超时设置:'.green, (timeout / 1000.0).toString().green.bold, '秒'.green); console.log('磁链保存位置: '.green, output.green.bold); console.log('代理服务器: '.green, (proxy ? proxy : '无').green.bold); /**************************** ***************************** **** MAIN LOOP START ! ****** **************************** ****************************/ mkdirp.sync(output);
sequencer.loadImages(program.image, function() { console.warn( "\x1b[33m%s\x1b[0m", "Please wait \n output directory generated will be empty until the execution is complete" ); //Generate the Output Directory var outputFilename = program.output.split('/').slice(-1)[0]; if (outputFilename.includes('.')) { // user did give an output filename we have to remove it from dir program.output = program.output.split('/').slice(0, -1).join('/'); } else { outputFilename = null; } require("./src/CliUtils").makedir(program.output, () => { console.log('Files will be exported to "' + program.output + '"'); if (program.basic) console.log("Basic mode is enabled, outputting only final image"); // Iterate through the steps and retrieve their inputs. program.step.forEach(function(step) { var options = Object.assign({}, sequencer.modulesInfo(step).inputs); // If inputs exists, print to console. if (Object.keys(options).length) { console.log("[" + step + "]: Inputs"); } // If inputs exists, print them out with descriptions. Object.keys(options).forEach(function(input) { // The array below creates a variable number of spaces. This is done with (length + 1). // The extra 4 that makes it (length + 5) is to account for the []: characters console.log( new Array(step.length + 5).join(" ") + input + ": " + options[input].desc ); }); if (program.config) { try { var config = JSON.parse(program.config); console.log(`The parsed options object: `, config); } catch (e) { console.error( "\x1b[31m%s\x1b[0m", `Options(Config) is not a not valid JSON Fallback activate` ); program.config = false; console.log(e); } } if (program.config && validateConfig(config, options)) { console.log("Now using Options object"); Object.keys(options).forEach(function(input) { options[input] = config[input]; }); } else { // If inputs exist, iterate through them and prompt for values. Object.keys(options).forEach(function(input) { var value = readlineSync.question( "[" + step + "]: Enter a value for " + input + " (" + options[input].type + ", default: " + options[input].default + "): " ); options[input] = value; }); } // Add the step and its inputs to the sequencer. sequencer.addSteps(step, options); }); var spinnerObj = { succeed: () => { }, stop: () => { } }; if (!process.env.TEST) spinnerObj = Spinner("Your Image is being processed..").start(); // Run the sequencer. sequencer.run({ progressObj: spinnerObj }, function() { // Export all images or final image as binary files. sequencer.exportBin(program.output, program.basic, outputFilename); //check if spinner was not overriden stop it if (!spinnerObj.overrideFlag) { spinnerObj.succeed(); console.log(`\nDone!!`); } }); }); });