music-metadata 10.2.0 → 10.3.1
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 +435 -126
- package/lib/ParseError.d.ts +87 -0
- package/lib/ParseError.js +39 -0
- package/lib/ParserFactory.d.ts +1 -1
- package/lib/ParserFactory.js +8 -7
- package/lib/aiff/AiffParser.js +4 -4
- package/lib/aiff/AiffToken.d.ts +15 -0
- package/lib/aiff/AiffToken.js +5 -2
- package/lib/apev2/APEv2Parser.d.ts +15 -0
- package/lib/apev2/APEv2Parser.js +6 -3
- package/lib/asf/AsfObject.d.ts +15 -0
- package/lib/asf/AsfObject.js +4 -1
- package/lib/asf/AsfParser.js +2 -1
- package/lib/common/CombinedTagMapper.js +2 -1
- package/lib/common/FourCC.js +3 -2
- package/lib/common/Util.js +3 -2
- package/lib/core.d.ts +3 -1
- package/lib/core.js +1 -1
- package/lib/default.cjs +5 -0
- package/lib/dsdiff/DsdiffParser.d.ts +15 -0
- package/lib/dsdiff/DsdiffParser.js +6 -3
- package/lib/dsf/DsfParser.d.ts +15 -0
- package/lib/dsf/DsfParser.js +4 -1
- package/lib/ebml/EbmlIterator.d.ts +15 -0
- package/lib/ebml/EbmlIterator.js +5 -2
- package/lib/flac/FlacParser.js +5 -2
- package/lib/id3v2/FrameParser.d.ts +14 -0
- package/lib/id3v2/FrameParser.js +7 -1
- package/lib/id3v2/ID3v2Parser.js +8 -5
- package/lib/mp4/AtomToken.d.ts +14 -0
- package/lib/mp4/AtomToken.js +6 -3
- package/lib/mp4/MP4Parser.js +4 -3
- package/lib/mpeg/MpegParser.d.ts +15 -0
- package/lib/mpeg/MpegParser.js +7 -4
- package/lib/musepack/MusepackConentError.d.ts +15 -0
- package/lib/musepack/MusepackConentError.js +4 -0
- package/lib/musepack/index.js +4 -3
- package/lib/musepack/sv7/MpcSv7Parser.js +2 -1
- package/lib/musepack/sv8/MpcSv8Parser.js +3 -2
- package/lib/node.cjs +5 -0
- package/lib/ogg/OggParser.d.ts +15 -0
- package/lib/ogg/OggParser.js +5 -2
- package/lib/ogg/opus/Opus.d.ts +15 -0
- package/lib/ogg/opus/Opus.js +4 -1
- package/lib/ogg/opus/OpusParser.js +2 -1
- package/lib/ogg/vorbis/VorbisParser.d.ts +15 -0
- package/lib/ogg/vorbis/VorbisParser.js +6 -3
- package/lib/wav/WaveChunk.d.ts +15 -0
- package/lib/wav/WaveChunk.js +5 -2
- package/lib/wav/WaveParser.js +3 -2
- package/lib/wavpack/WavPackParser.d.ts +15 -0
- package/lib/wavpack/WavPackParser.js +6 -3
- package/package.json +16 -7
package/lib/wav/WaveParser.js
CHANGED
|
@@ -8,6 +8,7 @@ import * as util from '../common/Util.js';
|
|
|
8
8
|
import { FourCcToken } from '../common/FourCC.js';
|
|
9
9
|
import { BasicParser } from '../common/BasicParser.js';
|
|
10
10
|
import { BroadcastAudioExtensionChunk } from './BwfChunk.js';
|
|
11
|
+
import { WaveContentError } from './WaveChunk.js';
|
|
11
12
|
const debug = initDebug('music-metadata:parser:RIFF');
|
|
12
13
|
/**
|
|
13
14
|
* Resource Interchange File Format (RIFF) Parser
|
|
@@ -43,7 +44,7 @@ export class WaveParser extends BasicParser {
|
|
|
43
44
|
case 'WAVE':
|
|
44
45
|
return this.readWaveChunk(chunkSize - FourCcToken.len);
|
|
45
46
|
default:
|
|
46
|
-
throw new
|
|
47
|
+
throw new WaveContentError(`Unsupported RIFF format: RIFF/${type}`);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
async readWaveChunk(remaining) {
|
|
@@ -159,7 +160,7 @@ export class WaveParser extends BasicParser {
|
|
|
159
160
|
chunkSize -= (8 + valueToken.len);
|
|
160
161
|
}
|
|
161
162
|
if (chunkSize !== 0) {
|
|
162
|
-
throw new
|
|
163
|
+
throw new WaveContentError(`Illegal remaining size: ${chunkSize}`);
|
|
163
164
|
}
|
|
164
165
|
}
|
|
165
166
|
addTag(id, value) {
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { BasicParser } from '../common/BasicParser.js';
|
|
2
|
+
declare const WavPackContentError_base: {
|
|
3
|
+
new (message: string): {
|
|
4
|
+
readonly fileType: string;
|
|
5
|
+
toString(): string;
|
|
6
|
+
name: "UnexpectedFileContentError";
|
|
7
|
+
message: string;
|
|
8
|
+
stack?: string;
|
|
9
|
+
};
|
|
10
|
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
|
11
|
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
|
12
|
+
stackTraceLimit: number;
|
|
13
|
+
};
|
|
14
|
+
export declare class WavPackContentError extends WavPackContentError_base {
|
|
15
|
+
}
|
|
2
16
|
/**
|
|
3
17
|
* WavPack Parser
|
|
4
18
|
*/
|
|
@@ -13,3 +27,4 @@ export declare class WavPackParser extends BasicParser {
|
|
|
13
27
|
*/
|
|
14
28
|
private parseMetadataSubBlock;
|
|
15
29
|
}
|
|
30
|
+
export {};
|
|
@@ -5,7 +5,10 @@ import { BasicParser } from '../common/BasicParser.js';
|
|
|
5
5
|
import { BlockHeaderToken, MetadataIdToken } from './WavPackToken.js';
|
|
6
6
|
import initDebug from 'debug';
|
|
7
7
|
import { uint8ArrayToHex } from 'uint8array-extras';
|
|
8
|
+
import { makeUnexpectedFileContentError } from '../ParseError.js';
|
|
8
9
|
const debug = initDebug('music-metadata:parser:WavPack');
|
|
10
|
+
export class WavPackContentError extends makeUnexpectedFileContentError('WavPack') {
|
|
11
|
+
}
|
|
9
12
|
/**
|
|
10
13
|
* WavPack Parser
|
|
11
14
|
*/
|
|
@@ -28,7 +31,7 @@ export class WavPackParser extends BasicParser {
|
|
|
28
31
|
break;
|
|
29
32
|
const header = await this.tokenizer.readToken(BlockHeaderToken);
|
|
30
33
|
if (header.BlockID !== 'wvpk')
|
|
31
|
-
throw new
|
|
34
|
+
throw new WavPackContentError('Invalid WavPack Block-ID');
|
|
32
35
|
debug(`WavPack header blockIndex=${header.blockIndex}, len=${BlockHeaderToken.len}`);
|
|
33
36
|
if (header.blockIndex === 0 && !this.metadata.format.container) {
|
|
34
37
|
this.metadata.setFormat('container', 'WavPack');
|
|
@@ -76,7 +79,7 @@ export class WavPackParser extends BasicParser {
|
|
|
76
79
|
const mp = 1 << Token.UINT8.get(data, 0);
|
|
77
80
|
const samplingRate = header.flags.samplingRate * mp * 8; // ToDo: second factor should be read from DSD-metadata block https://github.com/dbry/WavPack/issues/71#issuecomment-483094813
|
|
78
81
|
if (!header.flags.isDSD)
|
|
79
|
-
throw new
|
|
82
|
+
throw new WavPackContentError('Only expect DSD block if DSD-flag is set');
|
|
80
83
|
this.metadata.setFormat('sampleRate', samplingRate);
|
|
81
84
|
this.metadata.setFormat('duration', header.totalSamples / samplingRate);
|
|
82
85
|
break;
|
|
@@ -100,7 +103,7 @@ export class WavPackParser extends BasicParser {
|
|
|
100
103
|
this.tokenizer.ignore(1);
|
|
101
104
|
}
|
|
102
105
|
if (remaining !== 0)
|
|
103
|
-
throw new
|
|
106
|
+
throw new WavPackContentError('metadata-sub-block should fit it remaining length');
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
//# sourceMappingURL=WavPackParser.js.map
|
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": "10.
|
|
4
|
+
"version": "10.3.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Borewit",
|
|
7
7
|
"url": "https://github.com/Borewit"
|
|
@@ -19,14 +19,23 @@
|
|
|
19
19
|
"type": "module",
|
|
20
20
|
"exports": {
|
|
21
21
|
".": {
|
|
22
|
-
"node":
|
|
23
|
-
|
|
22
|
+
"node": {
|
|
23
|
+
"import": "./lib/index.js",
|
|
24
|
+
"require": "./lib/node.cjs",
|
|
25
|
+
"types": "./lib/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"default": {
|
|
28
|
+
"import": "./lib/core.js",
|
|
29
|
+
"require": "./lib/default.cjs",
|
|
30
|
+
"types": "./lib/core.d.ts"
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
},
|
|
26
34
|
"types": "lib/index.d.ts",
|
|
27
35
|
"files": [
|
|
28
36
|
"lib/**/*.js",
|
|
29
|
-
"lib/**/*.d.ts"
|
|
37
|
+
"lib/**/*.d.ts",
|
|
38
|
+
"lib/*.cjs"
|
|
30
39
|
],
|
|
31
40
|
"keywords": [
|
|
32
41
|
"music",
|
|
@@ -105,13 +114,13 @@
|
|
|
105
114
|
},
|
|
106
115
|
"devDependencies": {
|
|
107
116
|
"@biomejs/biome": "1.8.3",
|
|
108
|
-
"@types/chai": "^4.3.
|
|
109
|
-
"@types/chai-as-promised": "^
|
|
117
|
+
"@types/chai": "^4.3.19",
|
|
118
|
+
"@types/chai-as-promised": "^8.0.0",
|
|
110
119
|
"@types/content-type": "^1.1.8",
|
|
111
120
|
"@types/debug": "^4.1.12",
|
|
112
121
|
"@types/media-typer": "^1.1.3",
|
|
113
122
|
"@types/mocha": "^10.0.7",
|
|
114
|
-
"@types/node": "^22.
|
|
123
|
+
"@types/node": "^22.5.1",
|
|
115
124
|
"c8": "^10.1.2",
|
|
116
125
|
"chai": "^5.1.1",
|
|
117
126
|
"chai-as-promised": "^8.0.0",
|