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

music-metadata

Package Overview
Dependencies
Maintainers
1
Versions
256
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

music-metadata - npm Package Compare versions

Comparing version 0.7.13 to 0.7.14

lib/riff/RiffInfoTagMap.d.ts

4

lib/aiff/AiffParser.js

@@ -25,3 +25,3 @@ "use strict";

*/
var AIFFParser = (function () {
var AIFFParser = /** @class */ (function () {
function AIFFParser() {

@@ -96,3 +96,3 @@ this.metadata = {

exports.AIFFParser = AIFFParser;
var ID3Stream = (function (_super) {
var ID3Stream = /** @class */ (function (_super) {
__extends(ID3Stream, _super);

@@ -99,0 +99,0 @@ function ID3Stream(buf) {

@@ -19,3 +19,3 @@ "use strict";

};
var Common = (function () {
var Common = /** @class */ (function () {
function Common(header) {

@@ -22,0 +22,0 @@ assert.ok(header.size >= 18, "chunkSize should always be at least 18");

@@ -13,3 +13,3 @@ 'use strict';

})(DataType || (DataType = {}));
var Structure = (function () {
var Structure = /** @class */ (function () {
function Structure() {

@@ -115,3 +115,3 @@ }

}());
var APEv2Parser = (function () {
var APEv2Parser = /** @class */ (function () {
function APEv2Parser() {

@@ -118,0 +118,0 @@ this.type = 'APEv2'; // ToDo: versionIndex should be made dynamic, APE may also contain ID3

@@ -77,3 +77,3 @@ // ASF Objects

};
var State = (function () {
var State = /** @class */ (function () {
function State(header) {

@@ -86,3 +86,3 @@ this.len = header.objectSize - exports.HeaderObjectToken.len;

// ToDo: use ignore type
var IgnoreObjectState = (function (_super) {
var IgnoreObjectState = /** @class */ (function (_super) {
__extends(IgnoreObjectState, _super);

@@ -102,3 +102,3 @@ function IgnoreObjectState(header) {

*/
var FilePropertiesObject = (function (_super) {
var FilePropertiesObject = /** @class */ (function (_super) {
__extends(FilePropertiesObject, _super);

@@ -135,3 +135,3 @@ function FilePropertiesObject(header) {

*/
var StreamPropertiesObject = (function (_super) {
var StreamPropertiesObject = /** @class */ (function (_super) {
__extends(StreamPropertiesObject, _super);

@@ -156,3 +156,3 @@ function StreamPropertiesObject(header) {

*/
var HeaderExtensionObject = (function () {
var HeaderExtensionObject = /** @class */ (function () {
function HeaderExtensionObject(header) {

@@ -178,3 +178,3 @@ this.len = 22;

*/
var ContentDescriptionObjectState = (function (_super) {
var ContentDescriptionObjectState = /** @class */ (function (_super) {
__extends(ContentDescriptionObjectState, _super);

@@ -207,3 +207,3 @@ function ContentDescriptionObjectState(header) {

*/
var ExtendedContentDescriptionObjectState = (function (_super) {
var ExtendedContentDescriptionObjectState = /** @class */ (function (_super) {
__extends(ExtendedContentDescriptionObjectState, _super);

@@ -244,3 +244,3 @@ function ExtendedContentDescriptionObjectState(header) {

*/
var ExtendedStreamPropertiesObjectState = (function (_super) {
var ExtendedStreamPropertiesObjectState = /** @class */ (function (_super) {
__extends(ExtendedStreamPropertiesObjectState, _super);

@@ -284,3 +284,3 @@ function ExtendedStreamPropertiesObjectState(header) {

*/
var MetadataObjectState = (function (_super) {
var MetadataObjectState = /** @class */ (function (_super) {
__extends(MetadataObjectState, _super);

@@ -324,3 +324,3 @@ function MetadataObjectState(header) {

// 4.8 Metadata Library Object (optional, 0 or 1)
var MetadataLibraryObjectState = (function (_super) {
var MetadataLibraryObjectState = /** @class */ (function (_super) {
__extends(MetadataLibraryObjectState, _super);

@@ -337,3 +337,3 @@ function MetadataLibraryObjectState(header) {

*/
var WmPictureToken = (function () {
var WmPictureToken = /** @class */ (function () {
function WmPictureToken(len) {

@@ -340,0 +340,0 @@ this.len = len;

@@ -15,3 +15,3 @@ 'use strict';

*/
var AsfParser = (function () {
var AsfParser = /** @class */ (function () {
function AsfParser() {

@@ -18,0 +18,0 @@ this.tags = [];

@@ -20,3 +20,3 @@ "use strict";

*/
var GUID = (function () {
var GUID = /** @class */ (function () {
function GUID(str) {

@@ -23,0 +23,0 @@ this.str = str;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("../common");
var Util = (function () {
var Util = /** @class */ (function () {
function Util() {

@@ -6,0 +6,0 @@ }

@@ -5,3 +5,3 @@ "use strict";

var ID3v1Parser_1 = require("./id3v1/ID3v1Parser");
var Common = (function () {
var Common = /** @class */ (function () {
function Common() {

@@ -8,0 +8,0 @@ }

@@ -21,3 +21,3 @@ 'use strict';

})(BlockType || (BlockType = {}));
var FlacParser = (function () {
var FlacParser = /** @class */ (function () {
function FlacParser() {

@@ -137,3 +137,3 @@ this.tags = [];

exports.FlacParser = FlacParser;
var Metadata = (function () {
var Metadata = /** @class */ (function () {
function Metadata() {

@@ -191,3 +191,3 @@ }

}());
var DataDecoder = (function () {
var DataDecoder = /** @class */ (function () {
function DataDecoder(data) {

@@ -194,0 +194,0 @@ this.data = data;

@@ -74,3 +74,3 @@ 'use strict';

};
var Id3v1StringType = (function (_super) {
var Id3v1StringType = /** @class */ (function (_super) {
__extends(Id3v1StringType, _super);

@@ -87,3 +87,3 @@ function Id3v1StringType() {

}(Token.StringType));
var ID3v1Parser = (function () {
var ID3v1Parser = /** @class */ (function () {
function ID3v1Parser() {

@@ -90,0 +90,0 @@ }

@@ -6,3 +6,3 @@ "use strict";

var ID3v2Parser_1 = require("./ID3v2Parser");
var FrameParser = (function () {
var FrameParser = /** @class */ (function () {
function FrameParser() {

@@ -9,0 +9,0 @@ }

@@ -36,3 +36,3 @@ "use strict";

})(AttachedPictureType = exports.AttachedPictureType || (exports.AttachedPictureType = {}));
var ID3v2 = (function () {
var ID3v2 = /** @class */ (function () {
function ID3v2() {

@@ -100,3 +100,3 @@ }

}());
var ID3v2Parser = (function () {
var ID3v2Parser = /** @class */ (function () {
function ID3v2Parser() {

@@ -103,0 +103,0 @@ this.tags = [];

@@ -7,3 +7,3 @@ /* jshint maxlen: 300 */

var ParserFactory_1 = require("./ParserFactory");
var MusicMetadataParser = (function () {
var MusicMetadataParser = /** @class */ (function () {
function MusicMetadataParser() {

@@ -10,0 +10,0 @@ /**

@@ -5,3 +5,2 @@ import { ITokenParser } from "../ParserFactory";

export declare class MP4Parser implements ITokenParser {
static getInstance(): MP4Parser;
private static Types;

@@ -8,0 +7,0 @@ private static read_BE_Signed_Integer(value);

@@ -9,3 +9,3 @@ "use strict";

*/
var Atom = (function () {
var Atom = /** @class */ (function () {
function Atom() {

@@ -93,3 +93,3 @@ }

*/
var DataAtom = (function () {
var DataAtom = /** @class */ (function () {
function DataAtom(len) {

@@ -114,3 +114,3 @@ this.len = len;

*/
var NameAtom = (function () {
var NameAtom = /** @class */ (function () {
function NameAtom(len) {

@@ -134,3 +134,3 @@ this.len = len;

*/
var MP4Parser = (function () {
var MP4Parser = /** @class */ (function () {
function MP4Parser() {

@@ -144,5 +144,2 @@ this.metaAtomsTotalLength = 0;

}
MP4Parser.getInstance = function () {
return new MP4Parser();
};
MP4Parser.read_BE_Signed_Integer = function (value) {

@@ -149,0 +146,0 @@ switch (value.length) {

@@ -11,3 +11,3 @@ 'use strict';

*/
var MpegFrameHeader = (function () {
var MpegFrameHeader = /** @class */ (function () {
function MpegFrameHeader(buf, off) {

@@ -135,3 +135,3 @@ // B(20,19): MPEG Audio versionIndex ID

*/
var MpegAudioLayer = (function () {
var MpegAudioLayer = /** @class */ (function () {
function MpegAudioLayer() {

@@ -194,3 +194,3 @@ }

}());
var MpegParser = (function () {
var MpegParser = /** @class */ (function () {
function MpegParser(tokenizer, headerSize, readDuration) {

@@ -197,0 +197,0 @@ this.tokenizer = tokenizer;

@@ -17,6 +17,5 @@ 'use strict';

var es6_promise_1 = require("es6-promise");
var then_read_stream_1 = require("then-read-stream");
var Token = require("token-types");
var VorbisParser_1 = require("../vorbis/VorbisParser");
var VorbisStream = (function (_super) {
var VorbisStream = /** @class */ (function (_super) {
__extends(VorbisStream, _super);

@@ -49,3 +48,3 @@ function VorbisStream() {

}(stream_1.Readable));
var OggParser = (function () {
var OggParser = /** @class */ (function () {
function OggParser() {

@@ -62,13 +61,6 @@ }

return strtok3.fromStream(this.vorbisStream).then(function (vorbisTokenizer) {
// ToDo: should be provided with level-2 tokenizer
var vorbis = _this.vorbisParser.parse(vorbisTokenizer, options).then(function (metadata) {
if (metadata.format.sampleRate) {
// Calculate duration
metadata.format.duration = _this.header.absoluteGranulePosition / metadata.format.sampleRate;
}
return metadata;
});
var ogg = _this.parsePage().catch(function (err) {
if (err === then_read_stream_1.StreamReader.EndOfStream) {
// console.log("EndOfStream: ogg");
var vorbis = _this.vorbisParser.parse(vorbisTokenizer, options);
var ogg = _this.parsePage()
.catch(function (err) {
if (err === strtok3.EndOfFile) {
_this.vorbisStream.append(null);

@@ -78,10 +70,9 @@ }

throw err;
}).catch(function (err) {
if (err === strtok3.EndOfFile)
return;
else
throw err;
});
return es6_promise_1.Promise.all([vorbis, ogg]).then(function (_a) {
var metadata = _a[0];
if (metadata.format.sampleRate && _this.header.absoluteGranulePosition >= 0) {
// Calculate duration
metadata.format.duration = _this.header.absoluteGranulePosition / metadata.format.sampleRate;
}
return metadata;

@@ -97,2 +88,3 @@ });

}
// console.log('Ogg: Page-header: seqNo=%s, pos=%s', header.pageSequenceNo, header.absoluteGranulePosition);
_this.header = header;

@@ -121,3 +113,3 @@ _this.pageNumber = header.pageSequenceNo;

// packet_flag: buf.readUInt8(off + 5),
absoluteGranulePosition: (buf.readUInt32LE(off + 10) << 32) + buf.readUInt32LE(off + 6),
absoluteGranulePosition: buf.readIntLE(off + 6, 6),
streamSerialNumber: Token.UINT32_LE.get(buf, off + 14),

@@ -124,0 +116,0 @@ pageSequenceNo: Token.UINT32_LE.get(buf, off + 18),

@@ -17,3 +17,3 @@ "use strict";

var WavPackParser_1 = require("./wavpack/WavPackParser");
var ParserFactory = (function () {
var ParserFactory = /** @class */ (function () {
function ParserFactory() {

@@ -20,0 +20,0 @@ // ToDo: expose warnings to API

import * as Token from "token-types";
export interface IChunkHeader {
/**
* A chunk ID (ie, 4 ASCII bytes)
* A chunk ID (ie, 4 ASCII bytes)
*/

@@ -16,1 +16,10 @@ chunkID: string;

export declare const Header: Token.IGetToken<IChunkHeader>;
/**
* Token to parse RIFF-INFO tag value
*/
export declare class ListInfoTagValue implements Token.IGetToken<string> {
private tagHeader;
len: number;
constructor(tagHeader: IChunkHeader);
get(buf: any, off: any): string;
}

@@ -18,1 +18,16 @@ "use strict";

};
/**
* Token to parse RIFF-INFO tag value
*/
var ListInfoTagValue = /** @class */ (function () {
function ListInfoTagValue(tagHeader) {
this.tagHeader = tagHeader;
this.len = tagHeader.size;
this.len += this.len & 1; // if it an odd length, round up to even
}
ListInfoTagValue.prototype.get = function (buf, off) {
return new Token.StringType(this.tagHeader.size, 'ascii').get(buf, off);
};
return ListInfoTagValue;
}());
exports.ListInfoTagValue = ListInfoTagValue;
import { ITokenParser } from "../ParserFactory";
import * as strtok3 from "strtok3";
import { IOptions, INativeAudioMetadata } from "../";
import { IChunkHeader } from "../aiff/Chunk";
/**

@@ -17,7 +18,11 @@ * Resource Interchange File Format (RIFF) Parser

private metadata;
/**
* RIFF/ILIST-INFO tag stored in EXIF
*/
private riffInfoTags;
private warnings;
private blockAlign;
private native;
parse(tokenizer: strtok3.ITokenizer, options: IOptions): Promise<INativeAudioMetadata>;
readChunk(): Promise<void>;
readChunk(parent: IChunkHeader): Promise<void>;
private parseRiffInfoTags(chunkSize);
}

@@ -19,2 +19,3 @@ "use strict";

var ID3v2Parser_1 = require("../id3v2/ID3v2Parser");
var common_1 = require("../common");
/**

@@ -29,3 +30,3 @@ * Resource Interchange File Format (RIFF) Parser

*/
var WavePcmParser = (function () {
var WavePcmParser = /** @class */ (function () {
function WavePcmParser() {

@@ -38,2 +39,6 @@ this.metadata = {

};
/**
* RIFF/ILIST-INFO tag stored in EXIF
*/
this.riffInfoTags = [];
this.warnings = [];

@@ -48,7 +53,7 @@ }

if (header.chunkID !== 'RIFF')
return null; // Not AIFF format
return null; // Not RIFF format
return _this.tokenizer.readToken(new Token.StringType(4, 'ascii')).then(function (type) {
_this.metadata.format.dataformat = type;
}).then(function () {
return _this.readChunk().then(function () {
return _this.readChunk(header).then(function () {
return null;

@@ -65,5 +70,10 @@ });

}
}).then(function (metadata) {
if (_this.riffInfoTags.length > 0) {
metadata.native.exif = _this.riffInfoTags;
}
return metadata;
});
};
WavePcmParser.prototype.readChunk = function () {
WavePcmParser.prototype.readChunk = function (parent) {
var _this = this;

@@ -73,2 +83,12 @@ return this.tokenizer.readToken(WaveChunk.Header)

switch (header.chunkID) {
case "LIST":
return _this.tokenizer.readToken(new Token.StringType(4, 'ascii')).then(function (listTypes) {
switch (listTypes) {
case 'INFO':
return _this.parseRiffInfoTags(header.size - 4).then(function () { return header.size; });
default:
_this.warnings.push("Ignore chunk: RIFF/LIST." + listTypes);
return _this.tokenizer.ignore(header.size).then(function () { return header.size; });
}
});
case "fmt ":// The Common Chunk

@@ -83,3 +103,3 @@ return _this.tokenizer.readToken(new WaveChunk.Format(header))

});
case "id3 ": // The way Picard currently stores, ID3 meta-data
case "id3 ": // The way Picard, FooBar currently stores, ID3 meta-data
case "ID3 ":// The way Mp3Tags stores ID3 meta-data

@@ -99,16 +119,36 @@ return _this.tokenizer.readToken(new Token.BufferType(header.size))

_this.metadata.format.duration = _this.metadata.format.numberOfSamples / _this.metadata.format.sampleRate;
_this.metadata.format.bitrate = _this.metadata.format.numberOfChannels * _this.blockAlign * _this.metadata.format.sampleRate; // ToDo: check me
return _this.tokenizer.ignore(header.size);
case "LIST": // LIST ToDo?
default:
_this.warnings.push("Ignore chunk: " + header.chunkID);
_this.warnings.push("Ignore chunk: RIFF/" + header.chunkID);
return _this.tokenizer.ignore(header.size);
}
}).then(function () {
return _this.readChunk();
return _this.readChunk(parent);
});
};
WavePcmParser.prototype.parseRiffInfoTags = function (chunkSize) {
var _this = this;
return this.tokenizer.readToken(WaveChunk.Header)
.then(function (header) {
var valueToken = new RiffChunk.ListInfoTagValue(header);
return _this.tokenizer.readToken(valueToken).then(function (value) {
_this.riffInfoTags.push({ id: header.chunkID, value: common_1.default.stripNulls(value) });
chunkSize -= (8 + valueToken.len);
if (chunkSize > 8) {
return _this.parseRiffInfoTags(chunkSize);
}
else if (chunkSize === 0) {
return Promise.resolve();
}
else {
throw Error("Illegal remaining size: " + chunkSize);
}
});
});
};
return WavePcmParser;
}());
exports.WavePcmParser = WavePcmParser;
var ID3Stream = (function (_super) {
var ID3Stream = /** @class */ (function (_super) {
__extends(ID3Stream, _super);

@@ -115,0 +155,0 @@ function ID3Stream(buf) {

@@ -10,6 +10,7 @@ "use strict";

var APEv2TagMap_1 = require("./apev2/APEv2TagMap");
var RiffInfoTagMap_1 = require("./riff/RiffInfoTagMap");
/**
* tagmap maps native meta tags to generic common types
*/
var TagMap = (function () {
var TagMap = /** @class */ (function () {
function TagMap() {

@@ -25,2 +26,3 @@ // Normalize (post-process) common tag mappings

'iTunes MP4': MP4TagMap_1.MP4TagMap,
exif: RiffInfoTagMap_1.RiffInfoTagMap,
vorbis: VorbisTagMap_1.VorbisTagMap

@@ -27,0 +29,0 @@ };

@@ -11,3 +11,3 @@ "use strict";

*/
var VorbisPictureToken = (function () {
var VorbisPictureToken = /** @class */ (function () {
function VorbisPictureToken(len) {

@@ -14,0 +14,0 @@ this.len = len;

@@ -10,3 +10,3 @@ 'use strict';

*/
var VorbisParser = (function () {
var VorbisParser = /** @class */ (function () {
function VorbisParser() {

@@ -45,7 +45,6 @@ this.format = {

}
return res.done;
});
}).catch(function (err) {
if (err === then_read_stream_1.StreamReader.EndOfStream) {
return true;
return;
}

@@ -52,0 +51,0 @@ else

@@ -30,3 +30,3 @@ /// <reference types="node" />

/**
* "fmt " chunk
* format chunk; chunk-id is "fmt "
* http://soundfile.sapp.org/doc/WaveFormat/

@@ -33,0 +33,0 @@ */

@@ -20,6 +20,6 @@ "use strict";

/**
* "fmt " chunk
* format chunk; chunk-id is "fmt "
* http://soundfile.sapp.org/doc/WaveFormat/
*/
var Format = (function () {
var Format = /** @class */ (function () {
function Format(header) {

@@ -26,0 +26,0 @@ assert.ok(header.size >= 16, "16 for PCM.");

@@ -7,3 +7,3 @@ "use strict";

48000, 64000, 88200, 96000, 192000, -1];
var WavPack = (function () {
var WavPack = /** @class */ (function () {
function WavPack() {

@@ -78,3 +78,3 @@ }

*/
var WavPackParser = (function () {
var WavPackParser = /** @class */ (function () {
function WavPackParser() {

@@ -81,0 +81,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Windows1292Decoder = (function () {
var Windows1292Decoder = /** @class */ (function () {
function Windows1292Decoder() {

@@ -5,0 +5,0 @@ }

{
"name": "music-metadata",
"description": "Streaming music metadata parser for node and the browser.",
"version": "0.7.13",
"version": "0.7.14",
"author": {

@@ -59,5 +59,5 @@ "name": "Borewit",

"fs-extra": "^4.0.1",
"strtok3": "^1.1.1",
"then-read-stream": "^0.9.3",
"token-types": "^0.9.0"
"strtok3": "^1.1.2",
"then-read-stream": "^0.9.5",
"token-types": "^0.9.1"
},

@@ -69,3 +69,3 @@ "devDependencies": {

"@types/mocha": "^2.2.41",
"@types/node": "^8.0.20",
"@types/node": "^8.0.24",
"chai": "^4.1.1",

@@ -79,3 +79,3 @@ "coveralls": "^2.13.1",

"tslint": "^5.6.0",
"typescript": "^2.4.2"
"typescript": "^2.5.1"
},

@@ -100,8 +100,2 @@ "testling": {

},
"jshintConfig": {
"asi": true,
"node": true,
"maxlen": 120,
"indent": 2
},
"license": "MIT",

@@ -121,3 +115,14 @@ "standard": {

"url": "https://github.com/Borewit/music-metadata/issues"
},
"nyc": {
"check-coverage": true,
"include": [
"src/**/*"
],
"reporter": [
"lcov",
"text"
],
"report-dir": "coverage"
}
}

@@ -29,3 +29,3 @@ [![Build Status](https://travis-ci.org/Borewit/music-metadata.svg?branch=master)](https://travis-ci.org/Borewit/music-metadata)

| ogv, oga, ogx, ogg | audio/ogg, application/ogg | Vorbis |
| wav | audio/wav, audio/wave | ID3v2 |
| wav | audio/wav, audio/wave | ID3v2, RIFF/INFO (EXIF 2.3) |
| wv, wvp | audio/x-wavpack | APEv2 |

@@ -32,0 +32,0 @@

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