Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

musicmetadata

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

musicmetadata - npm Package Compare versions

Comparing version 0.5.2 to 0.6.0

10

lib/asf.js

@@ -6,4 +6,6 @@ var fs = require('fs');

var common = require('./common');
var bufferEqual = require('buffer-equal');
var equal = require('deep-equal');
var decodeString = common.decodeString;
module.exports = function (stream, callback, done) {

@@ -35,3 +37,3 @@ var currentState = startState;

parse: function (callback, data, done) {
if (! bufferEqual(common.asfGuidBuf, data)) {
if (!equal(common.asfGuidBuf, data)) {
done(new Error('expected asf header but was not found'));

@@ -213,3 +215,3 @@ return finishedState;

var GuidState = guidStates[i];
if (bufferEqual(GuidState.guid, guidBuf)) return GuidState;
if (equal(GuidState.guid, guidBuf)) return GuidState;
}

@@ -220,3 +222,3 @@ return null;

function parseUnicodeAttr(buf) {
return common.stripNulls(common.readUTF16String(buf));
return common.stripNulls(decodeString(buf, 'utf16le'));
}

@@ -223,0 +225,0 @@

39

lib/common.js
var strtok = require('strtok2');
var bufferEqual = require('buffer-equal');
var equal = require('deep-equal');
var iconv = require('iconv-lite');

@@ -16,3 +16,3 @@ var asfGuidBuf = new Buffer([

if (header.length >= offset + type.buf.length &&
bufferEqual(header.slice(offset, offset + type.buf.length), type.buf))
equal(header.slice(offset, offset + type.buf.length), type.buf))
{

@@ -92,11 +92,4 @@ return type.tag;

var decodeString = exports.decodeString = function (b, encoding, start, end) {
var text = '';
if (encoding == 'utf16') {
text = readUTF16String(b.slice(start, end));
} else {
var enc = (encoding == 'iso-8859-1') ? 'binary' : 'utf8';
text = b.toString(enc, start, end);
}
return { text : text, length : end - start }
var decodeString = exports.decodeString = function (buffer, encoding) {
return iconv.decode(buffer, encoding);
}

@@ -119,26 +112,2 @@

var readUTF16String = exports.readUTF16String = function (buffer) {
var offset = 0;
if (buffer[0] === 0xFE && buffer[1] === 0xFF) { // big endian
buffer = swapBytes(buffer);
offset = 2;
} else if (buffer[0] === 0xFF && buffer[1] === 0xFE) { // little endian
offset = 2;
}
return buffer.toString('ucs2', offset);
}
function swapBytes(buffer) {
var l = buffer.length;
if (l & 0x01) {
throw new Error('Buffer length must be even');
}
for (var i = 0; i < l; i += 2) {
var a = buffer[i];
buffer[i] = buffer[i+1];
buffer[i+1] = a;
}
return buffer;
}
exports.stripNulls = function(str) {

@@ -145,0 +114,0 @@ str = str.replace(/^\x00+/g, "");

@@ -8,11 +8,11 @@ var Buffer = require('buffer').Buffer;

exports.readData = function readData(b, type, flags, major) {
var encoding;
var encoding = getTextEncoding(b[0]);
var length = b.length;
var offset = 0;
var output = [];
var nullTerminatorLength;
var nullTerminatorLength = getNullTerminatorLength(encoding);
var fzero;
if (type[0] === 'T') {
type = 'T*';
encoding = getTextEncoding(b[0]);
}

@@ -22,7 +22,4 @@

case 'T*':
var text = decodeString(b, encoding, 1, length).text;
//trim any whitespace and any leading or trailing null characters
text = text.trim().replace(/^\x00+/,'').replace(/\x00+$/,'');
text = text.replace(/^\uFEFF/, ''); //REMOVE BOM
// id3v2.4 defines that multiple T* values are separted by 0x00
var text = decodeString(b.slice(1), encoding).replace(/\x00+$/,'');
// id3v2.4 defines that multiple T* values are separated by 0x00
output = text.split(/\x00/g);

@@ -34,4 +31,2 @@ break;

var pic = {};
encoding = getTextEncoding(b[0]);
nullTerminatorLength = getNullTerminatorLength(encoding);

@@ -42,3 +37,3 @@ offset += 1;

case 2:
pic.format = decodeString(b, encoding, offset, offset + 3).text;
pic.format = decodeString(b.slice(offset, offset + 3), encoding);
offset += 3;

@@ -49,5 +44,5 @@ break;

var enc = 'iso-8859-1';
pic.format = decodeString(b, enc, offset, findZero(b, offset, length, enc));
offset += 1 + pic.format.length;
pic.format = pic.format.text;
fzero = findZero(b, offset, length, enc);
pic.format = decodeString(b.slice(offset, fzero), enc);
offset = fzero + 1;
break;

@@ -59,5 +54,5 @@ }

pic.description = decodeString(b, encoding, offset, findZero(b, offset, length, encoding));
offset += nullTerminatorLength + pic.description.length;
pic.description = pic.description.text;
fzero = findZero(b, offset, length, encoding);
pic.description = decodeString(b.slice(offset, fzero), encoding);
offset = fzero + nullTerminatorLength;

@@ -68,23 +63,2 @@ pic.data = new Buffer(b.slice(offset, length));

case 'COM':
case 'COMM':
var comment = {};
encoding = getTextEncoding(b[0]);
nullTerminatorLength = getNullTerminatorLength(encoding);
offset +=1;
comment.language = b.slice(offset, offset + 3).toString('ascii');
offset += 3;
comment.short_description = decodeString(
b, encoding, offset, findZero(b, offset, length, encoding));
offset += nullTerminatorLength + comment.short_description.length;
comment.short_description = comment.short_description.text.trim().replace(/\x00/g,'');
comment.text = decodeString(b, encoding, offset, length).text.trim().replace(/\x00/g,'');
output = [comment];
break;
case 'CNT':

@@ -97,19 +71,18 @@ case 'PCNT':

case 'USLT':
var lyrics = {};
encoding = getTextEncoding(b[0]);
nullTerminatorLength = getNullTerminatorLength(encoding);
case 'COM':
case 'COMM':
var out = {};
offset += 1;
lyrics.language = b.slice(offset, offset + 3).toString('ascii');
out.language = decodeString(b.slice(offset, offset + 3), 'iso-8859-1');
offset += 3;
lyrics.descriptor = decodeString(b, encoding, offset, findZero(b, offset, length, encoding));
offset += nullTerminatorLength + lyrics.descriptor.length;
lyrics.descriptor = lyrics.descriptor.text;
fzero = findZero(b, offset, length, encoding);
out.description = decodeString(b.slice(offset, fzero), encoding);
offset = fzero + nullTerminatorLength;
lyrics.text = decodeString(b, encoding, offset, length);
lyrics.text = lyrics.text.text;
out.text = decodeString(b.slice(offset, length), encoding).replace(/\x00+$/,'');
output = [lyrics];
output = [out];
break;

@@ -116,0 +89,0 @@ }

{
"name": "musicmetadata",
"description": "Streaming music metadata parser for node and the browser.",
"version": "0.5.2",
"version": "0.6.0",
"author": "Lee Treveil",
"dependencies": {
"buffer-equal": "0.0.0",
"deep-equal": "~0.1.2",
"deep-equal": "0.2.1",
"filereader-stream": "0.0.1",
"iconv-lite": "^0.4.4",
"node-bitarray": "0.0.2",

@@ -11,0 +11,0 @@ "strtok2": "~1.0.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc