music-metadata 10.0.1 → 10.1.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/LICENSE.txt +9 -9
- package/README.md +520 -520
- package/lib/ParserFactory.d.ts +20 -28
- package/lib/ParserFactory.js +204 -207
- package/lib/aiff/AiffParser.js +20 -18
- package/lib/aiff/AiffToken.d.ts +14 -2
- package/lib/aiff/AiffToken.js +12 -0
- package/lib/apev2/APEv2Parser.d.ts +4 -4
- package/lib/apev2/APEv2Parser.js +12 -10
- package/lib/apev2/APEv2Token.d.ts +2 -4
- package/lib/apev2/APEv2Token.js +0 -3
- package/lib/asf/AsfObject.d.ts +7 -16
- package/lib/asf/AsfObject.js +8 -34
- package/lib/asf/AsfParser.js +17 -10
- package/lib/asf/AsfTagMapper.d.ts +1 -1
- package/lib/asf/AsfTagMapper.js +3 -2
- package/lib/asf/AsfUtil.d.ts +3 -11
- package/lib/asf/AsfUtil.js +29 -30
- package/lib/asf/GUID.js +6 -9
- package/lib/common/BasicParser.d.ts +4 -4
- package/lib/common/BasicParser.js +6 -0
- package/lib/common/CaseInsensitiveTagMap.d.ts +1 -1
- package/lib/common/CombinedTagMapper.d.ts +5 -5
- package/lib/common/CombinedTagMapper.js +1 -1
- package/lib/common/FourCC.d.ts +1 -1
- package/lib/common/GenericTagMapper.d.ts +8 -8
- package/lib/common/GenericTagMapper.js +4 -4
- package/lib/common/GenericTagTypes.d.ts +5 -4
- package/lib/common/GenericTagTypes.js +2 -2
- package/lib/common/MetadataCollector.d.ts +9 -9
- package/lib/common/MetadataCollector.js +24 -17
- package/lib/common/RandomFileReader.d.ts +1 -1
- package/lib/common/RandomFileReader.js +1 -1
- package/lib/common/RandomUint8ArrayReader.d.ts +1 -1
- package/lib/common/Util.d.ts +2 -6
- package/lib/common/Util.js +9 -11
- package/lib/core.d.ts +7 -9
- package/lib/core.js +10 -7
- package/lib/dsdiff/DsdiffParser.js +26 -14
- package/lib/dsdiff/DsdiffToken.d.ts +2 -2
- package/lib/dsdiff/DsdiffToken.js +1 -0
- package/lib/dsf/DsfChunk.js +1 -0
- package/lib/dsf/DsfParser.js +4 -2
- package/lib/flac/FlacParser.d.ts +3 -3
- package/lib/flac/FlacParser.js +9 -12
- package/lib/id3v1/ID3v1Parser.d.ts +1 -1
- package/lib/id3v1/ID3v1Parser.js +7 -4
- package/lib/id3v2/AbstractID3Parser.d.ts +1 -1
- package/lib/id3v2/AbstractID3Parser.js +2 -1
- package/lib/id3v2/FrameParser.d.ts +28 -3
- package/lib/id3v2/FrameParser.js +50 -28
- package/lib/id3v2/ID3v22TagMapper.d.ts +1 -1
- package/lib/id3v2/ID3v24TagMapper.d.ts +2 -1
- package/lib/id3v2/ID3v24TagMapper.js +23 -16
- package/lib/id3v2/ID3v2Parser.d.ts +2 -2
- package/lib/id3v2/ID3v2Parser.js +19 -8
- package/lib/iff/index.js +1 -0
- package/lib/index.d.ts +5 -6
- package/lib/index.js +7 -8
- package/lib/lyrics3/Lyrics3.d.ts +1 -1
- package/lib/lyrics3/Lyrics3.js +1 -1
- package/lib/matroska/MatroskaDtd.d.ts +1 -1
- package/lib/matroska/MatroskaDtd.js +139 -138
- package/lib/matroska/MatroskaParser.d.ts +4 -4
- package/lib/matroska/MatroskaParser.js +12 -12
- package/lib/matroska/types.d.ts +6 -4
- package/lib/mp4/Atom.d.ts +3 -3
- package/lib/mp4/Atom.js +4 -7
- package/lib/mp4/AtomToken.js +2 -1
- package/lib/mp4/MP4Parser.js +29 -20
- package/lib/mp4/MP4TagMapper.d.ts +2 -2
- package/lib/mp4/MP4TagMapper.js +1 -1
- package/lib/mpeg/ExtendedLameHeader.d.ts +4 -4
- package/lib/mpeg/ExtendedLameHeader.js +2 -1
- package/lib/mpeg/MpegParser.d.ts +1 -1
- package/lib/mpeg/MpegParser.js +145 -96
- package/lib/mpeg/ReplayGainDataFormat.d.ts +1 -1
- package/lib/mpeg/ReplayGainDataFormat.js +1 -0
- package/lib/mpeg/XingTag.d.ts +4 -4
- package/lib/mpeg/XingTag.js +5 -4
- package/lib/musepack/index.js +1 -0
- package/lib/musepack/sv7/BitReader.js +14 -17
- package/lib/musepack/sv7/MpcSv7Parser.js +6 -1
- package/lib/musepack/sv7/StreamVersion7.js +1 -0
- package/lib/musepack/sv8/MpcSv8Parser.js +6 -2
- package/lib/musepack/sv8/StreamVersion8.d.ts +1 -1
- package/lib/musepack/sv8/StreamVersion8.js +1 -0
- package/lib/ogg/Ogg.d.ts +1 -1
- package/lib/ogg/Ogg.js +1 -0
- package/lib/ogg/OggParser.d.ts +3 -3
- package/lib/ogg/OggParser.js +25 -16
- package/lib/ogg/opus/Opus.d.ts +1 -1
- package/lib/ogg/opus/Opus.js +1 -0
- package/lib/ogg/opus/OpusParser.d.ts +4 -4
- package/lib/ogg/opus/OpusParser.js +2 -0
- package/lib/ogg/speex/Speex.js +1 -0
- package/lib/ogg/speex/SpeexParser.d.ts +4 -4
- package/lib/ogg/speex/SpeexParser.js +1 -0
- package/lib/ogg/theora/Theora.js +1 -0
- package/lib/ogg/theora/TheoraParser.d.ts +4 -4
- package/lib/ogg/theora/TheoraParser.js +1 -0
- package/lib/ogg/vorbis/Vorbis.d.ts +3 -3
- package/lib/ogg/vorbis/Vorbis.js +22 -11
- package/lib/ogg/vorbis/VorbisDecoder.d.ts +1 -1
- package/lib/ogg/vorbis/VorbisDecoder.js +1 -0
- package/lib/ogg/vorbis/VorbisParser.d.ts +4 -4
- package/lib/ogg/vorbis/VorbisParser.js +3 -2
- package/lib/ogg/vorbis/VorbisTagMapper.d.ts +2 -2
- package/lib/ogg/vorbis/VorbisTagMapper.js +2 -2
- package/lib/riff/RiffChunk.d.ts +3 -3
- package/lib/riff/RiffChunk.js +1 -0
- package/lib/riff/RiffInfoTagMap.d.ts +1 -1
- package/lib/type.d.ts +35 -25
- package/lib/wav/BwfChunk.js +1 -0
- package/lib/wav/WaveChunk.d.ts +1 -1
- package/lib/wav/WaveChunk.js +1 -0
- package/lib/wav/WaveParser.js +27 -17
- package/lib/wavpack/WavPackParser.d.ts +1 -1
- package/lib/wavpack/WavPackParser.js +22 -13
- package/lib/wavpack/WavPackToken.d.ts +13 -17
- package/lib/wavpack/WavPackToken.js +22 -23
- package/package.json +139 -150
package/lib/mp4/Atom.js
CHANGED
|
@@ -23,7 +23,7 @@ export class Atom {
|
|
|
23
23
|
this.extended = extended;
|
|
24
24
|
this.parent = parent;
|
|
25
25
|
this.children = [];
|
|
26
|
-
this.atomPath = (this.parent ? this.parent.atomPath
|
|
26
|
+
this.atomPath = (this.parent ? `${this.parent.atomPath}.` : '') + this.header.name;
|
|
27
27
|
}
|
|
28
28
|
getHeaderLength() {
|
|
29
29
|
return this.extended ? 16 : 8;
|
|
@@ -51,19 +51,16 @@ export class Atom {
|
|
|
51
51
|
case 'ilst':
|
|
52
52
|
case 'tref':
|
|
53
53
|
return this.readAtoms(tokenizer, dataHandler, this.getPayloadLength(remaining));
|
|
54
|
-
case 'meta': // Metadata Atom, ref: https://developer.apple.com/library/content/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW8
|
|
54
|
+
case 'meta': { // Metadata Atom, ref: https://developer.apple.com/library/content/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW8
|
|
55
55
|
// meta has 4 bytes of padding, ignore
|
|
56
56
|
const peekHeader = await tokenizer.peekToken(Header);
|
|
57
57
|
const paddingLength = peekHeader.name === 'hdlr' ? 0 : 4;
|
|
58
58
|
await tokenizer.ignore(paddingLength);
|
|
59
59
|
return this.readAtoms(tokenizer, dataHandler, this.getPayloadLength(remaining) - paddingLength);
|
|
60
|
-
|
|
61
|
-
case 'mvhd': // 'movie' => 'mvhd': movie header atom; child of Movie Atom
|
|
62
|
-
case 'tkhd':
|
|
63
|
-
case 'stsz':
|
|
64
|
-
case 'mdat':
|
|
60
|
+
}
|
|
65
61
|
default:
|
|
66
62
|
return dataHandler(this, remaining);
|
|
67
63
|
}
|
|
68
64
|
}
|
|
69
65
|
}
|
|
66
|
+
//# sourceMappingURL=Atom.js.map
|
package/lib/mp4/AtomToken.js
CHANGED
|
@@ -68,7 +68,7 @@ export class FixedLengthAtom {
|
|
|
68
68
|
if (len < expLen) {
|
|
69
69
|
throw new Error(`Atom ${atomId} expected to be ${expLen}, but specifies ${len} bytes long.`);
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
if (len > expLen) {
|
|
72
72
|
debug(`Warning: atom ${atomId} expected to be ${expLen}, but was actually ${len} bytes long.`);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -390,3 +390,4 @@ function readTokenTable(buf, token, off, remainingLen, numberOfEntries) {
|
|
|
390
390
|
}
|
|
391
391
|
return entries;
|
|
392
392
|
}
|
|
393
|
+
//# sourceMappingURL=AtomToken.js.map
|
package/lib/mp4/MP4Parser.js
CHANGED
|
@@ -91,6 +91,7 @@ function distinct(value, index, self) {
|
|
|
91
91
|
export class MP4Parser extends BasicParser {
|
|
92
92
|
constructor() {
|
|
93
93
|
super(...arguments);
|
|
94
|
+
this.tracks = [];
|
|
94
95
|
this.atomParsers = {
|
|
95
96
|
/**
|
|
96
97
|
* Parse movie header (mvhd) atom
|
|
@@ -208,13 +209,13 @@ export class MP4Parser extends BasicParser {
|
|
|
208
209
|
const integerType = (signed ? 'INT' : 'UINT') + array.length * 8 + (array.length > 1 ? '_BE' : '');
|
|
209
210
|
const token = Token[integerType];
|
|
210
211
|
if (!token) {
|
|
211
|
-
throw new Error(
|
|
212
|
+
throw new Error(`Token for integer type not found: "${integerType}"`);
|
|
212
213
|
}
|
|
213
214
|
return Number(token.get(array, 0));
|
|
214
215
|
}
|
|
215
216
|
async parse() {
|
|
216
217
|
this.tracks = [];
|
|
217
|
-
let remainingFileSize = this.tokenizer.fileInfo.size;
|
|
218
|
+
let remainingFileSize = this.tokenizer.fileInfo.size || 0;
|
|
218
219
|
while (!this.tokenizer.fileInfo.size || remainingFileSize > 0) {
|
|
219
220
|
try {
|
|
220
221
|
const token = await this.tokenizer.peekToken(AtomToken.Header);
|
|
@@ -226,9 +227,13 @@ export class MP4Parser extends BasicParser {
|
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
229
|
catch (error) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
if (error instanceof Error) {
|
|
231
|
+
const errMsg = `Error at offset=${this.tokenizer.position}: ${error.message}`;
|
|
232
|
+
debug(errMsg);
|
|
233
|
+
this.addWarning(errMsg);
|
|
234
|
+
}
|
|
235
|
+
else
|
|
236
|
+
throw error;
|
|
232
237
|
break;
|
|
233
238
|
}
|
|
234
239
|
const rootAtom = await Atom.readAtom(this.tokenizer, (atom, remaining) => this.handleAtom(atom, remaining), null, remainingFileSize);
|
|
@@ -309,10 +314,8 @@ export class MP4Parser extends BasicParser {
|
|
|
309
314
|
if (this.atomParsers[atom.header.name]) {
|
|
310
315
|
return this.atomParsers[atom.header.name](remaining);
|
|
311
316
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
await this.tokenizer.ignore(remaining);
|
|
315
|
-
}
|
|
317
|
+
debug(`No parser for atom path=${atom.atomPath}, payload-len=${remaining}, ignoring atom`);
|
|
318
|
+
await this.tokenizer.ignore(remaining);
|
|
316
319
|
}
|
|
317
320
|
getTrackDescription() {
|
|
318
321
|
return this.tracks[this.tracks.length - 1];
|
|
@@ -326,7 +329,7 @@ export class MP4Parser extends BasicParser {
|
|
|
326
329
|
await this.metadata.addTag(tagFormat, id, value);
|
|
327
330
|
}
|
|
328
331
|
addWarning(message) {
|
|
329
|
-
debug(
|
|
332
|
+
debug(`Warning: ${message}`);
|
|
330
333
|
this.metadata.addWarning(message);
|
|
331
334
|
}
|
|
332
335
|
/**
|
|
@@ -343,20 +346,22 @@ export class MP4Parser extends BasicParser {
|
|
|
343
346
|
return this.parseValueAtom(tagKey, child);
|
|
344
347
|
case 'name': // name atom (optional)
|
|
345
348
|
case 'mean':
|
|
346
|
-
case 'rate':
|
|
349
|
+
case 'rate': {
|
|
347
350
|
const name = await this.tokenizer.readToken(new AtomToken.NameAtom(payLoadLength));
|
|
348
|
-
tagKey +=
|
|
351
|
+
tagKey += `:${name.name}`;
|
|
349
352
|
break;
|
|
350
|
-
|
|
353
|
+
}
|
|
354
|
+
default: {
|
|
351
355
|
const uint8Array = await this.tokenizer.readToken(new Token.Uint8ArrayType(payLoadLength));
|
|
352
|
-
this.addWarning(
|
|
356
|
+
this.addWarning(`Unsupported meta-item: ${tagKey}[${child.header.name}] => value=${uint8ArrayToHex(uint8Array)} ascii=${uint8ArrayToString(uint8Array, 'ascii')}`);
|
|
357
|
+
}
|
|
353
358
|
}
|
|
354
359
|
}, metaAtom.getPayloadLength(0));
|
|
355
360
|
}
|
|
356
361
|
async parseValueAtom(tagKey, metaAtom) {
|
|
357
362
|
const dataAtom = await this.tokenizer.readToken(new AtomToken.DataAtom(Number(metaAtom.header.length) - AtomToken.Header.len));
|
|
358
363
|
if (dataAtom.type.set !== 0) {
|
|
359
|
-
throw new Error(
|
|
364
|
+
throw new Error(`Unsupported type-set != 0: ${dataAtom.type.set}`);
|
|
360
365
|
}
|
|
361
366
|
// Use well-known-type table
|
|
362
367
|
// Ref: https://developer.apple.com/library/content/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW35
|
|
@@ -364,24 +369,27 @@ export class MP4Parser extends BasicParser {
|
|
|
364
369
|
case 0: // reserved: Reserved for use where no type needs to be indicated
|
|
365
370
|
switch (tagKey) {
|
|
366
371
|
case 'trkn':
|
|
367
|
-
case 'disk':
|
|
372
|
+
case 'disk': {
|
|
368
373
|
const num = Token.UINT8.get(dataAtom.value, 3);
|
|
369
374
|
const of = Token.UINT8.get(dataAtom.value, 5);
|
|
370
375
|
// console.log(" %s[data] = %s/%s", tagKey, num, of);
|
|
371
|
-
await this.addTag(tagKey, num
|
|
376
|
+
await this.addTag(tagKey, `${num}/${of}`);
|
|
372
377
|
break;
|
|
373
|
-
|
|
378
|
+
}
|
|
379
|
+
case 'gnre': {
|
|
374
380
|
const genreInt = Token.UINT8.get(dataAtom.value, 1);
|
|
375
381
|
const genreStr = Genres[genreInt - 1];
|
|
376
382
|
// console.log(" %s[data] = %s", tagKey, genreStr);
|
|
377
383
|
await this.addTag(tagKey, genreStr);
|
|
378
384
|
break;
|
|
379
|
-
|
|
385
|
+
}
|
|
386
|
+
case 'rate': {
|
|
380
387
|
const rate = new TextDecoder('ascii').decode(dataAtom.value);
|
|
381
388
|
await this.addTag(tagKey, rate);
|
|
382
389
|
break;
|
|
390
|
+
}
|
|
383
391
|
default:
|
|
384
|
-
debug(
|
|
392
|
+
debug(`unknown proprietary value type for: ${metaAtom.atomPath}`);
|
|
385
393
|
}
|
|
386
394
|
break;
|
|
387
395
|
case 1: // UTF-8: Without any count or NULL terminator
|
|
@@ -515,3 +523,4 @@ export class MP4Parser extends BasicParser {
|
|
|
515
523
|
return stcTable[stcTable.length - 1].samplesPerChunk;
|
|
516
524
|
}
|
|
517
525
|
}
|
|
526
|
+
//# sourceMappingURL=MP4Parser.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CaseInsensitiveTagMap } from '../common/CaseInsensitiveTagMap.js';
|
|
2
|
-
import { ITag } from "../type.js";
|
|
3
|
-
import { INativeMetadataCollector } from "../common/MetadataCollector.js";
|
|
2
|
+
import type { ITag } from "../type.js";
|
|
3
|
+
import type { INativeMetadataCollector } from "../common/MetadataCollector.js";
|
|
4
4
|
export declare const tagType = "iTunes";
|
|
5
5
|
export declare class MP4TagMapper extends CaseInsensitiveTagMap {
|
|
6
6
|
constructor();
|
package/lib/mp4/MP4TagMapper.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Extended Lame Header
|
|
3
3
|
*/
|
|
4
4
|
import type { IGetToken } from 'strtok3';
|
|
5
|
-
import { IReplayGain } from './ReplayGainDataFormat.js';
|
|
5
|
+
import { type IReplayGain } from './ReplayGainDataFormat.js';
|
|
6
6
|
/**
|
|
7
7
|
* LAME Tag, extends the Xing header format
|
|
8
8
|
* First added in LAME 3.12 for VBR
|
|
@@ -12,9 +12,9 @@ export interface IExtendedLameHeader {
|
|
|
12
12
|
revision: number;
|
|
13
13
|
vbr_method: number;
|
|
14
14
|
lowpass_filter: number;
|
|
15
|
-
track_peak?: number;
|
|
16
|
-
track_gain
|
|
17
|
-
album_gain
|
|
15
|
+
track_peak?: number | null;
|
|
16
|
+
track_gain?: IReplayGain;
|
|
17
|
+
album_gain?: IReplayGain;
|
|
18
18
|
music_length: number;
|
|
19
19
|
music_crc: number;
|
|
20
20
|
header_crc: number;
|
|
@@ -17,7 +17,7 @@ export const ExtendedLameHeader = {
|
|
|
17
17
|
revision: common.getBitAllignedNumber(buf, off, 0, 4),
|
|
18
18
|
vbr_method: common.getBitAllignedNumber(buf, off, 4, 4),
|
|
19
19
|
lowpass_filter: 100 * Token.UINT8.get(buf, off + 1),
|
|
20
|
-
track_peak: track_peak === 0 ?
|
|
20
|
+
track_peak: track_peak === 0 ? null : track_peak / 2 ** 23,
|
|
21
21
|
track_gain: ReplayGain.get(buf, 6),
|
|
22
22
|
album_gain: ReplayGain.get(buf, 8),
|
|
23
23
|
music_length: Token.UINT32_BE.get(buf, off + 20),
|
|
@@ -26,3 +26,4 @@ export const ExtendedLameHeader = {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
+
//# sourceMappingURL=ExtendedLameHeader.js.map
|
package/lib/mpeg/MpegParser.d.ts
CHANGED