musicmetadata
Advanced tools
Comparing version 0.4.6 to 0.5.0
@@ -11,3 +11,4 @@ var Buffer = require('buffer').Buffer; | ||
var offset = 0; | ||
var output = []; | ||
if (type[0] === 'T') { | ||
@@ -24,6 +25,6 @@ type = 'T*'; | ||
text = text.replace(/^\uFEFF/, ''); //REMOVE BOM | ||
//convert nulls into / | ||
text = text.replace(/\x00/g, '/'); | ||
return text; | ||
// id3v2.4 defines that multiple T* values are separted by 0x00 | ||
output = text.split(/\x00/g); | ||
break; | ||
case 'PIC': | ||
@@ -57,3 +58,4 @@ case 'APIC': | ||
pic.data = new Buffer(b.slice(offset, length)); | ||
return pic; | ||
output = [pic]; | ||
break; | ||
@@ -75,7 +77,9 @@ case 'COM': | ||
comment.text = decodeString(b, encoding, offset, length).text.trim().replace(/\x00/g,''); | ||
return comment; | ||
output = [comment]; | ||
break; | ||
case 'CNT': | ||
case 'PCNT': | ||
return strtok.UINT32_BE.get(b, 0); | ||
output = [strtok.UINT32_BE.get(b, 0)]; | ||
break; | ||
@@ -99,7 +103,7 @@ case 'ULT': | ||
return lyrics; | ||
output = [lyrics]; | ||
break; | ||
} | ||
// unrecognized tag | ||
return null; | ||
return output; | ||
}; | ||
@@ -106,0 +110,0 @@ |
@@ -220,3 +220,7 @@ var strtok = require('strtok2'); | ||
var frameData = readFrameData(frameDataBytes, frameHeader, header.major); | ||
callback(frameHeader.id, frameData); | ||
/*jshint loopfunc:true */ | ||
frameData.forEach(function (val) { | ||
callback(frameHeader.id, val); | ||
}) | ||
} | ||
@@ -223,0 +227,0 @@ } |
@@ -162,12 +162,2 @@ var util = require('util'); | ||
// many tagging libraries use forward slashes to separate artists etc | ||
// within a string, this code separates those strings into an array | ||
if (cleaned.constructor === String) { | ||
// limit to these three aliases, we don't want to be splitting anything else | ||
if (alias === 'artist' || alias === 'albumartist' || alias === 'genre') { | ||
cleaned = cleaned.split('/'); | ||
if (cleaned.length === 1) cleaned = cleaned[0]; | ||
} | ||
} | ||
// if we haven't previously seen this tag then | ||
@@ -201,5 +191,2 @@ // initialize it to an array, ready for values to be entered | ||
function cleanupArtist (origVal) { | ||
return origVal.split('/'); | ||
} | ||
@@ -206,0 +193,0 @@ // TODO: a string of 1of1 would fail to be converted |
@@ -38,6 +38,10 @@ var common = require('./common'); | ||
var value; | ||
if (kind === 0) { // utf-8 textstring | ||
value = buffer.toString('utf8', offset, offset += size); | ||
value = value.replace(/\x00/g, '/'); | ||
var value = buffer.toString('utf8', offset, offset += size); | ||
var values = value.split(/\x00/g); | ||
/*jshint loopfunc:true */ | ||
values.forEach(function (val) { | ||
callback(key, val); | ||
}) | ||
} else if (kind === 1) { //binary (probably artwork) | ||
@@ -57,7 +61,6 @@ if (key === 'Cover Art (Front)' || key === 'Cover Art (Back)') { | ||
value = picture; | ||
offset += size; | ||
callback(key, picture); | ||
} | ||
} | ||
callback(key, value); | ||
} | ||
@@ -64,0 +67,0 @@ return done(); |
{ | ||
"name": "musicmetadata", | ||
"description": "Streaming music metadata parser for node and the browser.", | ||
"version": "0.4.6", | ||
"version": "0.5.0", | ||
"author": "Lee Treveil", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
290153
8521