Comparing version 1.0.0 to 1.0.1
35
index.js
"use strict"; | ||
var COMMAND = "fpcalc"; | ||
var run = require("comandante"), | ||
var COMMAND = "fpcalc", | ||
run = require("comandante"), | ||
fpcalc = run.bind(null, COMMAND), | ||
split = require("split"); | ||
module.exports = function(path, options, callback) { | ||
module.exports = function(file, options, callback) { | ||
// Handle `options` parameter being optional | ||
if ( ! callback) { | ||
@@ -14,4 +15,9 @@ callback = options; | ||
var args = []; | ||
var | ||
// Result object to build as data is returned by fpcalc | ||
result = {}, | ||
// Command-line arguments to pass to fpcalc | ||
args = []; | ||
// `-length` command-line argument | ||
if (options.length) { | ||
@@ -21,8 +27,7 @@ args.push("-length", options.length); | ||
args.push(path); | ||
args.push(file); | ||
// Create a result object to build as data comes in | ||
var result = {}; | ||
function onData(data) { | ||
// Data is given as lines like `FILE=path/to/file`, so we split the | ||
// parts out and build the `results` object | ||
var parts = data.split("=", 2), | ||
@@ -37,11 +42,11 @@ name = parts[0].toLowerCase(), | ||
function onEnd() { | ||
callback(null, result); | ||
} | ||
run(COMMAND, args) | ||
fpcalc(args) | ||
// parse one complete line at a time | ||
.pipe(split()) | ||
// parse data into result object | ||
.on("data", onData) | ||
.on("end", onEnd) | ||
// return result object | ||
.on("end", callback.bind(null, null, result)) | ||
// return error | ||
.on("error", callback); | ||
}; |
{ | ||
"name": "fpcalc", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Light wrapper around the AcoustID Chromaprint fpcalc tool", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# node-fpcalc | ||
Lightweight wrapper around the [Acoustid fpcalc command-line | ||
A wrapper around the [AcoustID fpcalc command-line | ||
tool](http://acoustid.org/chromaprint) providing a Node interface to get | ||
@@ -12,3 +12,3 @@ audio fingerprints. | ||
if (err) throw err; | ||
console.log(result.path, result.duration, result.fingerprint); | ||
console.log(result.file, result.duration, result.fingerprint); | ||
}); | ||
@@ -19,7 +19,7 @@ ``` | ||
## `fpcalc(path, options, callback)` | ||
## `fpcalc(file, options, callback)` | ||
Calculates the fingerprint of the given audio file. | ||
*Path* must be the path to an audio file. | ||
*File* must be the path to an audio file. | ||
@@ -35,3 +35,3 @@ *Options* may be an object with the following keys: | ||
* `path`: Path to the audio file | ||
* `file`: Path to the audio file | ||
* `duration`: Duration of audio file in seconds | ||
@@ -42,5 +42,5 @@ * `fingerprint`: Fingerprint of audio file | ||
**The [*fpcalc* command-line utility](http://acoustid.org/chromaprint) must be | ||
installed.** This is often available via your package manager (e.g., `apt-get | ||
install libchromaprint-tools` or `brew install chromaprint`). | ||
**The [*fpcalc* command-line tool](http://acoustid.org/chromaprint) must | ||
be installed.** This is often available via your package manager (e.g., | ||
`apt-get install libchromaprint-tools` or `brew install chromaprint`). | ||
@@ -47,0 +47,0 @@ ``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
202107
7
60