music-metadata 7.12.4 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -31
- package/lib/ParserFactory.js +37 -41
- package/lib/aiff/AiffParser.js +25 -17
- package/lib/aiff/AiffToken.js +13 -12
- package/lib/apev2/APEv2Parser.js +29 -32
- package/lib/apev2/APEv2TagMapper.js +2 -6
- package/lib/apev2/APEv2Token.js +13 -19
- package/lib/asf/AsfObject.js +42 -56
- package/lib/asf/AsfParser.js +15 -19
- package/lib/asf/AsfTagMapper.js +2 -6
- package/lib/asf/AsfUtil.js +4 -7
- package/lib/asf/GUID.js +1 -4
- package/lib/common/BasicParser.js +1 -5
- package/lib/common/CaseInsensitiveTagMap.js +2 -6
- package/lib/common/CombinedTagMapper.js +20 -24
- package/lib/common/FourCC.js +3 -6
- package/lib/common/GenericTagMapper.js +2 -6
- package/lib/common/GenericTagTypes.js +5 -10
- package/lib/common/MetadataCollector.js +20 -25
- package/lib/common/RandomFileReader.js +2 -6
- package/lib/common/RandomUint8ArrayReader.js +1 -5
- package/lib/common/Util.js +11 -25
- package/lib/core.js +18 -28
- package/lib/dsdiff/DsdiffParser.js +24 -28
- package/lib/dsdiff/DsdiffToken.js +4 -7
- package/lib/dsf/DsfChunk.js +8 -11
- package/lib/dsf/DsfParser.js +13 -17
- package/lib/flac/FlacParser.js +22 -26
- package/lib/id3v1/ID3v1Parser.js +16 -21
- package/lib/id3v1/ID3v1TagMap.js +2 -6
- package/lib/id3v2/AbstractID3Parser.js +13 -17
- package/lib/id3v2/FrameParser.js +12 -17
- package/lib/id3v2/ID3v22TagMapper.js +4 -8
- package/lib/id3v2/ID3v24TagMapper.js +5 -9
- package/lib/id3v2/ID3v2Parser.js +10 -14
- package/lib/id3v2/ID3v2Token.js +9 -12
- package/lib/iff/index.js +4 -7
- package/lib/index.js +14 -44
- package/lib/lyrics3/Lyrics3.js +3 -7
- package/lib/matroska/MatroskaDtd.js +111 -114
- package/lib/matroska/MatroskaParser.js +20 -24
- package/lib/matroska/MatroskaTagMapper.js +2 -6
- package/lib/matroska/types.js +6 -9
- package/lib/mp4/Atom.js +4 -8
- package/lib/mp4/AtomToken.js +29 -44
- package/lib/mp4/MP4Parser.js +12 -16
- package/lib/mp4/MP4TagMapper.js +4 -8
- package/lib/mpeg/ExtendedLameHeader.js +6 -9
- package/lib/mpeg/MpegParser.js +17 -21
- package/lib/mpeg/ReplayGainDataFormat.js +2 -5
- package/lib/mpeg/XingTag.js +9 -13
- package/lib/musepack/index.js +10 -12
- package/lib/musepack/sv7/BitReader.js +2 -6
- package/lib/musepack/sv7/MpcSv7Parser.js +9 -13
- package/lib/musepack/sv7/StreamVersion7.js +3 -6
- package/lib/musepack/sv8/MpcSv8Parser.js +9 -13
- package/lib/musepack/sv8/StreamVersion8.js +5 -9
- package/lib/ogg/Ogg.js +1 -2
- package/lib/ogg/OggParser.js +19 -24
- package/lib/ogg/opus/Opus.js +2 -6
- package/lib/ogg/opus/OpusParser.js +4 -8
- package/lib/ogg/speex/Speex.js +3 -6
- package/lib/ogg/speex/SpeexParser.js +5 -9
- package/lib/ogg/theora/Theora.js +2 -5
- package/lib/ogg/theora/TheoraParser.js +5 -9
- package/lib/ogg/vorbis/Vorbis.js +6 -10
- package/lib/ogg/vorbis/VorbisDecoder.js +2 -6
- package/lib/ogg/vorbis/VorbisParser.js +18 -22
- package/lib/ogg/vorbis/VorbisTagMapper.js +3 -7
- package/lib/riff/RiffChunk.js +3 -7
- package/lib/riff/RiffInfoTagMap.js +4 -8
- package/lib/type.js +1 -5
- package/lib/wav/BwfChunk.js +8 -11
- package/lib/wav/WaveChunk.js +4 -9
- package/lib/wav/WaveParser.js +17 -21
- package/lib/wavpack/WavPackParser.js +17 -21
- package/lib/wavpack/WavPackToken.js +4 -8
- package/package.json +34 -44
- package/lib/ParserFactory.d.ts +0 -48
- package/lib/aiff/AiffParser.d.ts +0 -14
- package/lib/aiff/AiffToken.d.ts +0 -22
- package/lib/apev2/APEv2Parser.d.ts +0 -30
- package/lib/apev2/APEv2TagMapper.d.ts +0 -4
- package/lib/apev2/APEv2Token.d.ts +0 -100
- package/lib/asf/AsfObject.d.ts +0 -319
- package/lib/asf/AsfParser.d.ts +0 -17
- package/lib/asf/AsfTagMapper.d.ts +0 -7
- package/lib/asf/AsfUtil.d.ts +0 -13
- package/lib/asf/GUID.d.ts +0 -84
- package/lib/common/BasicParser.d.ts +0 -17
- package/lib/common/CaseInsensitiveTagMap.d.ts +0 -10
- package/lib/common/CombinedTagMapper.d.ts +0 -19
- package/lib/common/FourCC.d.ts +0 -6
- package/lib/common/GenericTagMapper.d.ts +0 -51
- package/lib/common/GenericTagTypes.d.ts +0 -33
- package/lib/common/MetadataCollector.d.ts +0 -76
- package/lib/common/RandomFileReader.d.ts +0 -22
- package/lib/common/RandomUint8ArrayReader.d.ts +0 -18
- package/lib/common/Util.d.ts +0 -57
- package/lib/core.d.ts +0 -48
- package/lib/dsdiff/DsdiffParser.d.ts +0 -14
- package/lib/dsdiff/DsdiffToken.d.ts +0 -9
- package/lib/dsf/DsfChunk.d.ts +0 -86
- package/lib/dsf/DsfParser.d.ts +0 -9
- package/lib/flac/FlacParser.d.ts +0 -28
- package/lib/id3v1/ID3v1Parser.d.ts +0 -13
- package/lib/id3v1/ID3v1TagMap.d.ts +0 -4
- package/lib/id3v2/AbstractID3Parser.d.ts +0 -17
- package/lib/id3v2/FrameParser.d.ts +0 -31
- package/lib/id3v2/ID3v22TagMapper.d.ts +0 -9
- package/lib/id3v2/ID3v24TagMapper.d.ts +0 -14
- package/lib/id3v2/ID3v2Parser.d.ts +0 -28
- package/lib/id3v2/ID3v2Token.d.ts +0 -73
- package/lib/iff/index.d.ts +0 -33
- package/lib/index.d.ts +0 -45
- package/lib/lyrics3/Lyrics3.d.ts +0 -3
- package/lib/matroska/MatroskaDtd.d.ts +0 -8
- package/lib/matroska/MatroskaParser.d.ts +0 -37
- package/lib/matroska/MatroskaTagMapper.d.ts +0 -4
- package/lib/matroska/types.d.ts +0 -175
- package/lib/mp4/Atom.d.ts +0 -16
- package/lib/mp4/AtomToken.d.ts +0 -395
- package/lib/mp4/MP4Parser.d.ts +0 -30
- package/lib/mp4/MP4TagMapper.d.ts +0 -5
- package/lib/mpeg/ExtendedLameHeader.d.ts +0 -27
- package/lib/mpeg/MpegParser.d.ts +0 -49
- package/lib/mpeg/ReplayGainDataFormat.d.ts +0 -55
- package/lib/mpeg/XingTag.d.ts +0 -45
- package/lib/musepack/index.d.ts +0 -5
- package/lib/musepack/sv7/BitReader.d.ts +0 -13
- package/lib/musepack/sv7/MpcSv7Parser.d.ts +0 -8
- package/lib/musepack/sv7/StreamVersion7.d.ts +0 -28
- package/lib/musepack/sv8/MpcSv8Parser.d.ts +0 -6
- package/lib/musepack/sv8/StreamVersion8.d.ts +0 -40
- package/lib/ogg/Ogg.d.ts +0 -72
- package/lib/ogg/OggParser.d.ts +0 -23
- package/lib/ogg/opus/Opus.d.ts +0 -48
- package/lib/ogg/opus/OpusParser.d.ts +0 -25
- package/lib/ogg/speex/Speex.d.ts +0 -36
- package/lib/ogg/speex/SpeexParser.d.ts +0 -22
- package/lib/ogg/theora/Theora.d.ts +0 -20
- package/lib/ogg/theora/TheoraParser.d.ts +0 -28
- package/lib/ogg/vorbis/Vorbis.d.ts +0 -69
- package/lib/ogg/vorbis/VorbisDecoder.d.ts +0 -12
- package/lib/ogg/vorbis/VorbisParser.d.ts +0 -36
- package/lib/ogg/vorbis/VorbisTagMapper.d.ts +0 -7
- package/lib/riff/RiffChunk.d.ts +0 -16
- package/lib/riff/RiffInfoTagMap.d.ts +0 -10
- package/lib/type.d.ts +0 -592
- package/lib/wav/BwfChunk.d.ts +0 -17
- package/lib/wav/WaveChunk.d.ts +0 -64
- package/lib/wav/WaveParser.d.ts +0 -24
- package/lib/wavpack/WavPackParser.d.ts +0 -14
- package/lib/wavpack/WavPackToken.d.ts +0 -64
package/lib/wav/WaveParser.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const BasicParser_1 = require("../common/BasicParser");
|
|
13
|
-
const BwfChunk_1 = require("../wav/BwfChunk");
|
|
14
|
-
const debug = (0, debug_1.default)('music-metadata:parser:RIFF');
|
|
1
|
+
import * as strtok3 from 'strtok3/core';
|
|
2
|
+
import * as Token from 'token-types';
|
|
3
|
+
import initDebug from 'debug';
|
|
4
|
+
import * as riff from '../riff/RiffChunk.js';
|
|
5
|
+
import * as WaveChunk from './../wav/WaveChunk.js';
|
|
6
|
+
import { ID3v2Parser } from '../id3v2/ID3v2Parser.js';
|
|
7
|
+
import * as util from '../common/Util.js';
|
|
8
|
+
import { FourCcToken } from '../common/FourCC.js';
|
|
9
|
+
import { BasicParser } from '../common/BasicParser.js';
|
|
10
|
+
import { BroadcastAudioExtensionChunk } from '../wav/BwfChunk.js';
|
|
11
|
+
const debug = initDebug('music-metadata:parser:RIFF');
|
|
15
12
|
/**
|
|
16
13
|
* Resource Interchange File Format (RIFF) Parser
|
|
17
14
|
*
|
|
@@ -23,7 +20,7 @@ const debug = (0, debug_1.default)('music-metadata:parser:RIFF');
|
|
|
23
20
|
*
|
|
24
21
|
* ToDo: Split WAVE part from RIFF parser
|
|
25
22
|
*/
|
|
26
|
-
class WaveParser extends
|
|
23
|
+
export class WaveParser extends BasicParser {
|
|
27
24
|
async parse() {
|
|
28
25
|
const riffHeader = await this.tokenizer.readToken(riff.Header);
|
|
29
26
|
debug(`pos=${this.tokenizer.position}, parse: chunkID=${riffHeader.chunkID}`);
|
|
@@ -36,11 +33,11 @@ class WaveParser extends BasicParser_1.BasicParser {
|
|
|
36
33
|
});
|
|
37
34
|
}
|
|
38
35
|
async parseRiffChunk(chunkSize) {
|
|
39
|
-
const type = await this.tokenizer.readToken(
|
|
36
|
+
const type = await this.tokenizer.readToken(FourCcToken);
|
|
40
37
|
this.metadata.setFormat('container', type);
|
|
41
38
|
switch (type) {
|
|
42
39
|
case 'WAVE':
|
|
43
|
-
return this.readWaveChunk(chunkSize -
|
|
40
|
+
return this.readWaveChunk(chunkSize - FourCcToken.len);
|
|
44
41
|
default:
|
|
45
42
|
throw new Error(`Unsupported RIFF format: RIFF/${type}`);
|
|
46
43
|
}
|
|
@@ -80,7 +77,7 @@ class WaveParser extends BasicParser_1.BasicParser {
|
|
|
80
77
|
case 'ID3 ': // The way Mp3Tags stores ID3 meta-data
|
|
81
78
|
const id3_data = await this.tokenizer.readToken(new Token.Uint8ArrayType(header.chunkSize));
|
|
82
79
|
const rst = strtok3.fromBuffer(id3_data);
|
|
83
|
-
await new
|
|
80
|
+
await new ID3v2Parser().parse(this.metadata, rst, this.options);
|
|
84
81
|
break;
|
|
85
82
|
case 'data': // PCM-data
|
|
86
83
|
if (this.metadata.format.lossless !== false) {
|
|
@@ -103,11 +100,11 @@ class WaveParser extends BasicParser_1.BasicParser {
|
|
|
103
100
|
await this.tokenizer.ignore(header.chunkSize);
|
|
104
101
|
break;
|
|
105
102
|
case 'bext': // Broadcast Audio Extension chunk https://tech.ebu.ch/docs/tech/tech3285.pdf
|
|
106
|
-
const bext = await this.tokenizer.readToken(
|
|
103
|
+
const bext = await this.tokenizer.readToken(BroadcastAudioExtensionChunk);
|
|
107
104
|
Object.keys(bext).forEach(key => {
|
|
108
105
|
this.metadata.addTag('exif', 'bext.' + key, bext[key]);
|
|
109
106
|
});
|
|
110
|
-
const bextRemaining = header.chunkSize -
|
|
107
|
+
const bextRemaining = header.chunkSize - BroadcastAudioExtensionChunk.len;
|
|
111
108
|
await this.tokenizer.ignore(bextRemaining);
|
|
112
109
|
break;
|
|
113
110
|
case '\x00\x00\x00\x00': // padding ??
|
|
@@ -155,4 +152,3 @@ class WaveParser extends BasicParser_1.BasicParser {
|
|
|
155
152
|
this.metadata.addTag('exif', id, value);
|
|
156
153
|
}
|
|
157
154
|
}
|
|
158
|
-
exports.WaveParser = WaveParser;
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const WavPackToken_1 = require("./WavPackToken");
|
|
9
|
-
const debug_1 = require("debug");
|
|
10
|
-
const debug = (0, debug_1.default)('music-metadata:parser:WavPack');
|
|
1
|
+
import * as Token from 'token-types';
|
|
2
|
+
import { APEv2Parser } from '../apev2/APEv2Parser.js';
|
|
3
|
+
import { FourCcToken } from '../common/FourCC.js';
|
|
4
|
+
import { BasicParser } from '../common/BasicParser.js';
|
|
5
|
+
import { WavPack } from './WavPackToken.js';
|
|
6
|
+
import initDebug from 'debug';
|
|
7
|
+
const debug = initDebug('music-metadata:parser:WavPack');
|
|
11
8
|
/**
|
|
12
9
|
* WavPack Parser
|
|
13
10
|
*/
|
|
14
|
-
class WavPackParser extends
|
|
11
|
+
export class WavPackParser extends BasicParser {
|
|
15
12
|
async parse() {
|
|
16
13
|
this.audioDataSize = 0;
|
|
17
14
|
// First parse all WavPack blocks
|
|
18
15
|
await this.parseWavPackBlocks();
|
|
19
16
|
// try to parse APEv2 header
|
|
20
|
-
return
|
|
17
|
+
return APEv2Parser.tryParseApeHeader(this.metadata, this.tokenizer, this.options);
|
|
21
18
|
}
|
|
22
19
|
async parseWavPackBlocks() {
|
|
23
20
|
do {
|
|
24
|
-
const blockId = await this.tokenizer.peekToken(
|
|
21
|
+
const blockId = await this.tokenizer.peekToken(FourCcToken);
|
|
25
22
|
if (blockId !== 'wvpk')
|
|
26
23
|
break;
|
|
27
|
-
const header = await this.tokenizer.readToken(
|
|
24
|
+
const header = await this.tokenizer.readToken(WavPack.BlockHeaderToken);
|
|
28
25
|
if (header.BlockID !== 'wvpk')
|
|
29
26
|
throw new Error('Invalid WavPack Block-ID');
|
|
30
|
-
debug(`WavPack header blockIndex=${header.blockIndex}, len=${
|
|
27
|
+
debug(`WavPack header blockIndex=${header.blockIndex}, len=${WavPack.BlockHeaderToken.len}`);
|
|
31
28
|
if (header.blockIndex === 0 && !this.metadata.format.container) {
|
|
32
29
|
this.metadata.setFormat('container', 'WavPack');
|
|
33
30
|
this.metadata.setFormat('lossless', !header.flags.isHybrid);
|
|
@@ -42,12 +39,12 @@ class WavPackParser extends BasicParser_1.BasicParser {
|
|
|
42
39
|
this.metadata.setFormat('numberOfSamples', header.totalSamples);
|
|
43
40
|
this.metadata.setFormat('codec', header.flags.isDSD ? 'DSD' : 'PCM');
|
|
44
41
|
}
|
|
45
|
-
const ignoreBytes = header.blockSize - (
|
|
42
|
+
const ignoreBytes = header.blockSize - (WavPack.BlockHeaderToken.len - 8);
|
|
46
43
|
await (header.blockIndex === 0 ? this.parseMetadataSubBlock(header, ignoreBytes) : this.tokenizer.ignore(ignoreBytes));
|
|
47
44
|
if (header.blockSamples > 0) {
|
|
48
45
|
this.audioDataSize += header.blockSize; // Count audio data for bit-rate calculation
|
|
49
46
|
}
|
|
50
|
-
} while (!this.tokenizer.fileInfo.size || this.tokenizer.fileInfo.size - this.tokenizer.position >=
|
|
47
|
+
} while (!this.tokenizer.fileInfo.size || this.tokenizer.fileInfo.size - this.tokenizer.position >= WavPack.BlockHeaderToken.len);
|
|
51
48
|
this.metadata.setFormat('bitrate', this.audioDataSize * 8 / this.metadata.format.duration);
|
|
52
49
|
}
|
|
53
50
|
/**
|
|
@@ -55,8 +52,8 @@ class WavPackParser extends BasicParser_1.BasicParser {
|
|
|
55
52
|
* @param remainingLength
|
|
56
53
|
*/
|
|
57
54
|
async parseMetadataSubBlock(header, remainingLength) {
|
|
58
|
-
while (remainingLength >
|
|
59
|
-
const id = await this.tokenizer.readToken(
|
|
55
|
+
while (remainingLength > WavPack.MetadataIdToken.len) {
|
|
56
|
+
const id = await this.tokenizer.readToken(WavPack.MetadataIdToken);
|
|
60
57
|
const dataSizeInWords = await this.tokenizer.readNumber(id.largeBlock ? Token.UINT24_LE : Token.UINT8);
|
|
61
58
|
const data = Buffer.alloc(dataSizeInWords * 2 - (id.isOddSize ? 1 : 0));
|
|
62
59
|
await this.tokenizer.readBuffer(data);
|
|
@@ -87,7 +84,7 @@ class WavPackParser extends BasicParser_1.BasicParser {
|
|
|
87
84
|
debug(`Ignore unsupported meta-sub-block-id functionId=0x${id.functionId.toString(16)}`);
|
|
88
85
|
break;
|
|
89
86
|
}
|
|
90
|
-
remainingLength -=
|
|
87
|
+
remainingLength -= WavPack.MetadataIdToken.len + (id.largeBlock ? Token.UINT24_LE.len : Token.UINT8.len) + dataSizeInWords * 2;
|
|
91
88
|
debug(`remainingLength=${remainingLength}`);
|
|
92
89
|
if (id.isOddSize)
|
|
93
90
|
this.tokenizer.ignore(1);
|
|
@@ -96,4 +93,3 @@ class WavPackParser extends BasicParser_1.BasicParser {
|
|
|
96
93
|
throw new Error('metadata-sub-block should fit it remaining length');
|
|
97
94
|
}
|
|
98
95
|
}
|
|
99
|
-
exports.WavPackParser = WavPackParser;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.WavPack = void 0;
|
|
4
|
-
const Token = require("token-types");
|
|
5
|
-
const FourCC_1 = require("../common/FourCC");
|
|
1
|
+
import * as Token from 'token-types';
|
|
2
|
+
import { FourCcToken } from '../common/FourCC.js';
|
|
6
3
|
const SampleRates = [6000, 8000, 9600, 11025, 12000, 16000, 22050, 24000, 32000, 44100,
|
|
7
4
|
48000, 64000, 88200, 96000, 192000, -1];
|
|
8
|
-
class WavPack {
|
|
5
|
+
export class WavPack {
|
|
9
6
|
static isBitSet(flags, bitOffset) {
|
|
10
7
|
return WavPack.getBitAllignedNumber(flags, bitOffset, 1) === 1;
|
|
11
8
|
}
|
|
@@ -13,7 +10,6 @@ class WavPack {
|
|
|
13
10
|
return (flags >>> bitOffset) & (0xffffffff >>> (32 - len));
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
exports.WavPack = WavPack;
|
|
17
13
|
/**
|
|
18
14
|
* WavPack Block Header
|
|
19
15
|
*
|
|
@@ -27,7 +23,7 @@ WavPack.BlockHeaderToken = {
|
|
|
27
23
|
const flags = Token.UINT32_LE.get(buf, off + 24);
|
|
28
24
|
const res = {
|
|
29
25
|
// should equal 'wvpk'
|
|
30
|
-
BlockID:
|
|
26
|
+
BlockID: FourCcToken.get(buf, off),
|
|
31
27
|
// 0x402 to 0x410 are valid for decode
|
|
32
28
|
blockSize: Token.UINT32_LE.get(buf, off + 4),
|
|
33
29
|
// 0x402 (1026) to 0x410 are valid for decode
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "music-metadata",
|
|
3
3
|
"description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "8.0.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Borewit",
|
|
7
7
|
"url": "https://github.com/Borewit"
|
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
"type": "github",
|
|
11
11
|
"url": "https://github.com/sponsors/Borewit"
|
|
12
12
|
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"node": "./lib/index.js",
|
|
17
|
+
"default": "./lib/core.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"types": "lib/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"lib/**/*.js",
|
|
23
|
+
"lib/**/*.d.ts"
|
|
24
|
+
],
|
|
13
25
|
"keywords": [
|
|
14
26
|
"music",
|
|
15
27
|
"metadata",
|
|
@@ -60,12 +72,6 @@
|
|
|
60
72
|
"parser",
|
|
61
73
|
"bwf"
|
|
62
74
|
],
|
|
63
|
-
"main": "lib/index.js",
|
|
64
|
-
"types": "lib/index.d.ts",
|
|
65
|
-
"files": [
|
|
66
|
-
"lib/**/*.js",
|
|
67
|
-
"lib/**/*.d.ts"
|
|
68
|
-
],
|
|
69
75
|
"scripts": {
|
|
70
76
|
"clean": "del-cli lib/**/*.js lib/**/*.js.map lib/**/*.d.ts src/**/*.d.ts test/**/*.js test/**/*.js.map test/**/*.js test/**/*.js.map doc-gen/**/*.js doc-gen/**/*.js.map",
|
|
71
77
|
"compile-src": "tsc -p lib",
|
|
@@ -75,53 +81,53 @@
|
|
|
75
81
|
"eslint": "eslint lib/**/*.ts --ignore-pattern lib/**/*.d.ts example/typescript/**/*.ts test/**/*.ts doc-gen/**/*.ts",
|
|
76
82
|
"lint-md": "remark -u preset-lint-recommended .",
|
|
77
83
|
"lint": "npm run lint-md && npm run eslint",
|
|
78
|
-
"test": "mocha
|
|
84
|
+
"test": "mocha",
|
|
79
85
|
"build": "npm run clean && npm run compile && npm run doc-gen",
|
|
80
86
|
"start": "npm-run-all compile lint cover-test",
|
|
81
|
-
"test-coverage": "
|
|
82
|
-
"send-
|
|
83
|
-
"send-codacy": "nyc report --reporter=text-lcov | codacy-coverage",
|
|
87
|
+
"test-coverage": "c8 npm run test",
|
|
88
|
+
"send-codacy": "c8 report --reporter=text-lcov | codacy-coverage",
|
|
84
89
|
"doc-gen": "node doc-gen/gen.js"
|
|
85
90
|
},
|
|
86
91
|
"dependencies": {
|
|
87
92
|
"@tokenizer/token": "^0.3.0",
|
|
88
93
|
"content-type": "^1.0.4",
|
|
89
94
|
"debug": "^4.3.4",
|
|
90
|
-
"file-type": "
|
|
95
|
+
"file-type": "^17.1.6",
|
|
91
96
|
"media-typer": "^1.1.0",
|
|
92
|
-
"strtok3": "^
|
|
93
|
-
"token-types": "^
|
|
97
|
+
"strtok3": "^7.0.0",
|
|
98
|
+
"token-types": "^5.0.1"
|
|
94
99
|
},
|
|
95
100
|
"devDependencies": {
|
|
96
101
|
"@types/chai": "^4.3.1",
|
|
102
|
+
"@types/chai-as-promised": "^7.1.5",
|
|
97
103
|
"@types/debug": "^4.1.7",
|
|
98
104
|
"@types/file-type": "^10.9.1",
|
|
99
105
|
"@types/mocha": "^9.1.0",
|
|
100
|
-
"@types/node": "^18.
|
|
101
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
102
|
-
"@typescript-eslint/parser": "^5.
|
|
106
|
+
"@types/node": "^18.6.3",
|
|
107
|
+
"@typescript-eslint/eslint-plugin": "^5.32.0",
|
|
108
|
+
"@typescript-eslint/parser": "^5.32.0",
|
|
109
|
+
"c8": "^7.12.0",
|
|
103
110
|
"chai": "^4.3.6",
|
|
104
|
-
"
|
|
105
|
-
"del-cli": "
|
|
106
|
-
"eslint": "^8.
|
|
111
|
+
"chai-as-promised": "^7.1.1",
|
|
112
|
+
"del-cli": "5.0.0",
|
|
113
|
+
"eslint": "^8.21.0",
|
|
107
114
|
"eslint-config-prettier": "^8.5.0",
|
|
108
|
-
"eslint-import-resolver-typescript": "^
|
|
115
|
+
"eslint-import-resolver-typescript": "^3.4.0",
|
|
109
116
|
"eslint-plugin-import": "^2.26.0",
|
|
110
|
-
"eslint-plugin-jsdoc": "^39.3.
|
|
117
|
+
"eslint-plugin-jsdoc": "^39.3.4",
|
|
111
118
|
"eslint-plugin-node": "^11.1.0",
|
|
112
|
-
"eslint-plugin-unicorn": "^
|
|
119
|
+
"eslint-plugin-unicorn": "^43.0.2",
|
|
113
120
|
"mime": "^3.0.0",
|
|
114
|
-
"mocha": "^
|
|
121
|
+
"mocha": "^10.0.0",
|
|
115
122
|
"npm-run-all": "^4.1.5",
|
|
116
|
-
"
|
|
123
|
+
"prettier": "^2.5.1",
|
|
117
124
|
"remark-cli": "^11.0.0",
|
|
118
125
|
"remark-preset-lint-recommended": "^6.1.2",
|
|
119
|
-
"
|
|
120
|
-
"ts-node": "^10.8.1",
|
|
126
|
+
"ts-node": "^10.9.1",
|
|
121
127
|
"typescript": "^4.7.4"
|
|
122
128
|
},
|
|
123
129
|
"engines": {
|
|
124
|
-
"node": ">=
|
|
130
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
125
131
|
},
|
|
126
132
|
"repository": {
|
|
127
133
|
"type": "git",
|
|
@@ -130,21 +136,5 @@
|
|
|
130
136
|
"license": "MIT",
|
|
131
137
|
"bugs": {
|
|
132
138
|
"url": "https://github.com/Borewit/music-metadata/issues"
|
|
133
|
-
},
|
|
134
|
-
"nyc": {
|
|
135
|
-
"exclude": [
|
|
136
|
-
"test/**/*.ts",
|
|
137
|
-
"src/**/*.js"
|
|
138
|
-
],
|
|
139
|
-
"extension": [
|
|
140
|
-
".ts"
|
|
141
|
-
],
|
|
142
|
-
"sourceMap": true,
|
|
143
|
-
"instrument": true,
|
|
144
|
-
"reporter": [
|
|
145
|
-
"lcov",
|
|
146
|
-
"text"
|
|
147
|
-
],
|
|
148
|
-
"report-dir": "coverage"
|
|
149
139
|
}
|
|
150
140
|
}
|
package/lib/ParserFactory.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { IOptions, IAudioMetadata, ParserType } from './type';
|
|
2
|
-
import { ITokenizer } from 'strtok3/lib/core';
|
|
3
|
-
import { INativeMetadataCollector } from './common/MetadataCollector';
|
|
4
|
-
export interface ITokenParser {
|
|
5
|
-
/**
|
|
6
|
-
* Initialize parser with output (metadata), input (tokenizer) & parsing options (options).
|
|
7
|
-
* @param metadata - Output
|
|
8
|
-
* @param tokenizer - Input
|
|
9
|
-
* @param options - Parsing options
|
|
10
|
-
*/
|
|
11
|
-
init(metadata: INativeMetadataCollector, tokenizer: ITokenizer, options: IOptions): ITokenParser;
|
|
12
|
-
/**
|
|
13
|
-
* Parse audio track.
|
|
14
|
-
* Called after init(...).
|
|
15
|
-
* @returns Promise
|
|
16
|
-
*/
|
|
17
|
-
parse(): Promise<void>;
|
|
18
|
-
}
|
|
19
|
-
export declare function parseHttpContentType(contentType: string): {
|
|
20
|
-
type: string;
|
|
21
|
-
subtype: string;
|
|
22
|
-
suffix?: string;
|
|
23
|
-
parameters: {
|
|
24
|
-
[id: string]: string;
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export declare class ParserFactory {
|
|
28
|
-
/**
|
|
29
|
-
* Parse metadata from tokenizer
|
|
30
|
-
* @param tokenizer - Tokenizer
|
|
31
|
-
* @param opts - Options
|
|
32
|
-
* @returns Native metadata
|
|
33
|
-
*/
|
|
34
|
-
static parseOnContentType(tokenizer: ITokenizer, opts: IOptions): Promise<IAudioMetadata>;
|
|
35
|
-
static parse(tokenizer: ITokenizer, parserId: ParserType, opts: IOptions): Promise<IAudioMetadata>;
|
|
36
|
-
/**
|
|
37
|
-
* @param filePath - Path, filename or extension to audio file
|
|
38
|
-
* @return Parser sub-module name
|
|
39
|
-
*/
|
|
40
|
-
static getParserIdForExtension(filePath: string): ParserType;
|
|
41
|
-
static loadParser(moduleName: ParserType): Promise<ITokenParser>;
|
|
42
|
-
private static getExtension;
|
|
43
|
-
/**
|
|
44
|
-
* @param httpContentType - HTTP Content-Type, extension, path or filename
|
|
45
|
-
* @returns Parser sub-module name
|
|
46
|
-
*/
|
|
47
|
-
private static getParserIdForMimeType;
|
|
48
|
-
}
|
package/lib/aiff/AiffParser.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BasicParser } from '../common/BasicParser';
|
|
2
|
-
import * as iff from '../iff';
|
|
3
|
-
/**
|
|
4
|
-
* AIFF - Audio Interchange File Format
|
|
5
|
-
*
|
|
6
|
-
* Ref:
|
|
7
|
-
* - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/AIFF.html
|
|
8
|
-
* - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/Docs/AIFF-1.3.pdf
|
|
9
|
-
*/
|
|
10
|
-
export declare class AIFFParser extends BasicParser {
|
|
11
|
-
private isCompressed;
|
|
12
|
-
parse(): Promise<void>;
|
|
13
|
-
readData(header: iff.IChunkHeader): Promise<number>;
|
|
14
|
-
}
|
package/lib/aiff/AiffToken.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IGetToken } from 'strtok3';
|
|
3
|
-
import * as iff from '../iff';
|
|
4
|
-
/**
|
|
5
|
-
* The Common Chunk.
|
|
6
|
-
* Describes fundamental parameters of the waveform data such as sample rate, bit resolution, and how many channels of
|
|
7
|
-
* digital audio are stored in the FORM AIFF.
|
|
8
|
-
*/
|
|
9
|
-
export interface ICommon {
|
|
10
|
-
numChannels: number;
|
|
11
|
-
numSampleFrames: number;
|
|
12
|
-
sampleSize: number;
|
|
13
|
-
sampleRate: number;
|
|
14
|
-
compressionType?: string;
|
|
15
|
-
compressionName?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare class Common implements IGetToken<ICommon> {
|
|
18
|
-
private isAifc;
|
|
19
|
-
len: number;
|
|
20
|
-
constructor(header: iff.IChunkHeader, isAifc: boolean);
|
|
21
|
-
get(buf: Buffer, off: number): ICommon;
|
|
22
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import * as strtok3 from 'strtok3/lib/core';
|
|
2
|
-
import { IOptions, IRandomReader, IApeHeader } from '../type';
|
|
3
|
-
import { INativeMetadataCollector } from '../common/MetadataCollector';
|
|
4
|
-
import { BasicParser } from '../common/BasicParser';
|
|
5
|
-
import { IFooter, IHeader } from './APEv2Token';
|
|
6
|
-
export declare class APEv2Parser extends BasicParser {
|
|
7
|
-
static tryParseApeHeader(metadata: INativeMetadataCollector, tokenizer: strtok3.ITokenizer, options: IOptions): Promise<void>;
|
|
8
|
-
/**
|
|
9
|
-
* Calculate the media file duration
|
|
10
|
-
* @param ah ApeHeader
|
|
11
|
-
* @return {number} duration in seconds
|
|
12
|
-
*/
|
|
13
|
-
static calculateDuration(ah: IHeader): number;
|
|
14
|
-
/**
|
|
15
|
-
* Calculates the APEv1 / APEv2 first field offset
|
|
16
|
-
* @param reader
|
|
17
|
-
* @param offset
|
|
18
|
-
*/
|
|
19
|
-
static findApeFooterOffset(reader: IRandomReader, offset: number): Promise<IApeHeader>;
|
|
20
|
-
private static parseTagFooter;
|
|
21
|
-
private ape;
|
|
22
|
-
/**
|
|
23
|
-
* Parse APEv1 / APEv2 header if header signature found
|
|
24
|
-
*/
|
|
25
|
-
tryParseApeHeader(): Promise<void>;
|
|
26
|
-
parse(): Promise<void>;
|
|
27
|
-
parseTags(footer: IFooter): Promise<void>;
|
|
28
|
-
private parseDescriptorExpansion;
|
|
29
|
-
private parseHeader;
|
|
30
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import * as Token from 'token-types';
|
|
2
|
-
import { IGetToken } from 'strtok3/lib/core';
|
|
3
|
-
/**
|
|
4
|
-
* APETag versionIndex history / supported formats
|
|
5
|
-
*
|
|
6
|
-
* 1.0 (1000) - Original APE tag spec. Fully supported by this code.
|
|
7
|
-
* 2.0 (2000) - Refined APE tag spec (better streaming support, UTF StringEncoding). Fully supported by this code.
|
|
8
|
-
*
|
|
9
|
-
* Notes:
|
|
10
|
-
* - also supports reading of ID3v1.1 tags
|
|
11
|
-
* - all saving done in the APE Tag format using CURRENT_APE_TAG_VERSION
|
|
12
|
-
*
|
|
13
|
-
* APE File Format Overview: (pieces in order -- only valid for the latest versionIndex APE files)
|
|
14
|
-
*
|
|
15
|
-
* JUNK - any amount of "junk" before the APE_DESCRIPTOR (so people that put ID3v2 tags on the files aren't hosed)
|
|
16
|
-
* APE_DESCRIPTOR - defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
|
|
17
|
-
* APE_HEADER - describes all of the necessary information about the APE file
|
|
18
|
-
* SEEK TABLE - the table that represents seek offsets [optional]
|
|
19
|
-
* HEADER DATA - the pre-audio data from the original file [optional]
|
|
20
|
-
* APE FRAMES - the actual compressed audio (broken into frames for seekability)
|
|
21
|
-
* TERMINATING DATA - the post-audio data from the original file [optional]
|
|
22
|
-
* TAG - describes all the properties of the file [optional]
|
|
23
|
-
*/
|
|
24
|
-
export interface IDescriptor {
|
|
25
|
-
ID: string;
|
|
26
|
-
version: number;
|
|
27
|
-
descriptorBytes: number;
|
|
28
|
-
headerBytes: number;
|
|
29
|
-
seekTableBytes: number;
|
|
30
|
-
headerDataBytes: number;
|
|
31
|
-
apeFrameDataBytes: number;
|
|
32
|
-
apeFrameDataBytesHigh: number;
|
|
33
|
-
terminatingDataBytes: number;
|
|
34
|
-
fileMD5: Uint8Array;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* APE_HEADER: describes all of the necessary information about the APE file
|
|
38
|
-
*/
|
|
39
|
-
export interface IHeader {
|
|
40
|
-
compressionLevel: number;
|
|
41
|
-
formatFlags: number;
|
|
42
|
-
blocksPerFrame: number;
|
|
43
|
-
finalFrameBlocks: number;
|
|
44
|
-
totalFrames: number;
|
|
45
|
-
bitsPerSample: number;
|
|
46
|
-
channel: number;
|
|
47
|
-
sampleRate: number;
|
|
48
|
-
}
|
|
49
|
-
export interface IFooter {
|
|
50
|
-
ID: string;
|
|
51
|
-
version: number;
|
|
52
|
-
size: number;
|
|
53
|
-
fields: number;
|
|
54
|
-
flags: ITagFlags;
|
|
55
|
-
}
|
|
56
|
-
export declare enum DataType {
|
|
57
|
-
text_utf8 = 0,
|
|
58
|
-
binary = 1,
|
|
59
|
-
external_info = 2,
|
|
60
|
-
reserved = 3
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* APE_DESCRIPTOR: defines the sizes (and offsets) of all the pieces, as well as the MD5 checksum
|
|
64
|
-
*/
|
|
65
|
-
export declare const DescriptorParser: IGetToken<IDescriptor>;
|
|
66
|
-
/**
|
|
67
|
-
* APE_HEADER: describes all of the necessary information about the APE file
|
|
68
|
-
*/
|
|
69
|
-
export declare const Header: IGetToken<IHeader>;
|
|
70
|
-
/**
|
|
71
|
-
* APE Tag Header/Footer Version 2.0
|
|
72
|
-
* TAG: describes all the properties of the file [optional]
|
|
73
|
-
*/
|
|
74
|
-
export declare const TagFooter: IGetToken<IFooter>;
|
|
75
|
-
/**
|
|
76
|
-
* APE Tag v2.0 Item Header
|
|
77
|
-
*/
|
|
78
|
-
export interface ITagItemHeader {
|
|
79
|
-
size: number;
|
|
80
|
-
flags: ITagFlags;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* APE Tag v2.0 Item Header
|
|
84
|
-
*/
|
|
85
|
-
export declare const TagItemHeader: IGetToken<ITagItemHeader>;
|
|
86
|
-
export declare const TagField: (footer: any) => Token.Uint8ArrayType;
|
|
87
|
-
export interface ITagFlags {
|
|
88
|
-
containsHeader: boolean;
|
|
89
|
-
containsFooter: boolean;
|
|
90
|
-
isHeader: boolean;
|
|
91
|
-
readOnly: boolean;
|
|
92
|
-
dataType: DataType;
|
|
93
|
-
}
|
|
94
|
-
export declare function parseTagFlags(flags: any): ITagFlags;
|
|
95
|
-
/**
|
|
96
|
-
* @param num {number}
|
|
97
|
-
* @param bit 0 is least significant bit (LSB)
|
|
98
|
-
* @return {boolean} true if bit is 1; otherwise false
|
|
99
|
-
*/
|
|
100
|
-
export declare function isBitSet(num: any, bit: any): boolean;
|