diff --git a/badger-am.js b/badger-am.js index f0fe36c..c0b6631 100755 --- a/badger-am.js +++ b/badger-am.js @@ -19,7 +19,8 @@ function badger() { commander .version(app.version) .usage('[options] ') - .option('-c, --concurrency ', 'specify concurrency level', os.cpus().length); + .option('-c, --concurrency ', 'specify concurrency level', os.cpus().length) + .option('-n, --no-confirm', 'disable confirmation messages'); // conversion commander .command('convert ') @@ -54,6 +55,7 @@ function convert(input, output, options) { input: path.normalize(input), output: path.normalize(output), concurrency: commander.concurrency || os.cpus().length, + confirm: commander.confirm || false, bitrate: options.bitrate || 320, format: options.format || '.flac' }, function (err, time) { @@ -67,7 +69,7 @@ function sort(input, output, options) { input: path.normalize(input), output: path.normalize(output), concurrency: commander.concurrency || os.cpus().length, - bitrate: options.bitrate || 320, + confirm: commander.confirm || false, format: options.format || '.flac' }, function (err, skipped, time) { if (!skipped || skipped.length === 0) { @@ -103,6 +105,7 @@ function scan(input, options) { audio.batchScan({ input: path.normalize(input), concurrency: commander.concurrency || os.cpus().length, + confirm: commander.confirm || false, format: options.format || '.flac' }, function (err, missing, time) { if (!missing || missing.length === 0) { diff --git a/lib/audio.js b/lib/audio.js index b9f5687..8ab68d1 100644 --- a/lib/audio.js +++ b/lib/audio.js @@ -19,12 +19,16 @@ function batchConvert(config, callback) { // display info, prompt user and create progressbar function (files, waterfallCallback) { console.log(files.length + ' files found after ' + util.getTimeDiff(timestamp) + ' seconds'); - cli.askForConfirmation('start conversion now?', ['yes', 'y'], function (err) { - if (err) { - return waterfallCallback(err); - } + if (config.confirm) { + cli.askForConfirmation('start conversion now?', ['yes', 'y'], function (err) { + if (err) { + return waterfallCallback(err); + } + waterfallCallback(null, files, cli.createProgressBar(files.length)); + }); + } else { waterfallCallback(null, files, cli.createProgressBar(files.length)); - }); + } }, // process each file function (files, bar, waterfallCallback) { @@ -92,12 +96,16 @@ function batchExtract(config, callback) { // display info, prompt user and create progressbar function (files, waterfallCallback) { console.log(files.length + ' files found after ' + util.getTimeDiff(timestamp) + ' seconds'); - cli.askForConfirmation('start artwork extraction now?', ['yes', 'y'], function (err) { - if (err) { - return waterfallCallback(err); - } + if (config.confirm) { + cli.askForConfirmation('start artwork extraction now?', ['yes', 'y'], function (err) { + if (err) { + return waterfallCallback(err); + } + + }); + } else { waterfallCallback(null, files, cli.createProgressBar(files.length)); - }); + } }, // process each file function (files, bar, waterfallCallback) { diff --git a/lib/util.js b/lib/util.js index ebfd251..cf70cb5 100644 --- a/lib/util.js +++ b/lib/util.js @@ -18,12 +18,16 @@ function batchSort(config, callback) { // display info, prompt user and create progressbar function (files, waterfallCallback) { console.log(files.length + ' files found after ' + getTimeDiff(timestamp) + ' seconds'); - cli.askForConfirmation('start sorting now?', ['yes', 'y'], function (err) { - if (err) { - return waterfallCallback(err); - } + if (config.confirm) { + cli.askForConfirmation('start sorting now?', ['yes', 'y'], function (err) { + if (err) { + return waterfallCallback(err); + } + waterfallCallback(null, files, cli.createProgressBar(files.length)); + }); + } else { waterfallCallback(null, files, cli.createProgressBar(files.length)); - }); + } }, // process each file function (files, bar, waterfallCallback) { @@ -125,9 +129,9 @@ function getPathByMetadata(source, output, metadata, callback) { fileName += metadata.title.trim(); } // append extension - fileName += replaceIllegalChars(path.extname(source)).trim(); - // join directory and name - callback(null, path.join(filePath, fileName)); + fileName += path.extname(source).trim(); + // replace illegal chars, join directory and name + callback(null, path.join(filePath, replaceIllegalChars(fileName))); } // fill a string beginning from the front @@ -140,7 +144,6 @@ function frontFill(string, fill, length) { // replace illegal characters function replaceIllegalChars(string) { - // TODO: check function, seems like it doesn't work at all return string.replace(/[/\\:*?"<>|]/g, '-'); } diff --git a/package.json b/package.json index 74125c6..29c0947 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "badger-am", - "version": "0.6.1", + "version": "0.7.0", "license": "MIT", "description": "audio manager", "author": "Daniel Sommer ",