music-metadata 11.8.0 → 11.8.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/lib/apev2/APEv2Parser.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import initDebug from 'debug';
|
|
2
2
|
import * as strtok3 from 'strtok3';
|
|
3
3
|
import { StringType } from 'token-types';
|
|
4
|
-
import { uint8ArrayToString } from 'uint8array-extras';
|
|
5
4
|
import * as util from '../common/Util.js';
|
|
6
5
|
import { BasicParser } from '../common/BasicParser.js';
|
|
7
6
|
import { DataType, DescriptorParser, Header, TagFooter, TagItemHeader } from './APEv2Token.js';
|
|
8
7
|
import { makeUnexpectedFileContentError } from '../ParseError.js';
|
|
8
|
+
import { TextDecoder } from '@kayahr/text-encoding';
|
|
9
9
|
const debug = initDebug('music-metadata:parser:APEv2');
|
|
10
10
|
const tagFormat = 'APEv2';
|
|
11
11
|
const preamble = 'APETAGEX';
|
|
@@ -132,7 +132,7 @@ export class APEv2Parser extends BasicParser {
|
|
|
132
132
|
const picData = new Uint8Array(tagItemHeader.size);
|
|
133
133
|
await this.tokenizer.readBuffer(picData);
|
|
134
134
|
zero = util.findZero(picData, 0, picData.length);
|
|
135
|
-
const description =
|
|
135
|
+
const description = new TextDecoder('utf-8').decode(picData.slice(0, zero));
|
|
136
136
|
const data = picData.slice(zero + 1);
|
|
137
137
|
await this.metadata.addTag(tagFormat, key, {
|
|
138
138
|
description,
|
package/lib/common/FourCC.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TextDecoder, TextEncoder } from '@kayahr/text-encoding';
|
|
2
2
|
import * as util from './Util.js';
|
|
3
3
|
import { InternalParserError, FieldDecodingError } from '../ParseError.js';
|
|
4
4
|
const validFourCC = /^[\x21-\x7e©][\x20-\x7e\x00()]{3}/;
|
|
@@ -9,14 +9,14 @@ const validFourCC = /^[\x21-\x7e©][\x20-\x7e\x00()]{3}/;
|
|
|
9
9
|
export const FourCcToken = {
|
|
10
10
|
len: 4,
|
|
11
11
|
get: (buf, off) => {
|
|
12
|
-
const id =
|
|
12
|
+
const id = new TextDecoder('latin1').decode(buf.slice(off, off + FourCcToken.len));
|
|
13
13
|
if (!id.match(validFourCC)) {
|
|
14
14
|
throw new FieldDecodingError(`FourCC contains invalid characters: ${util.a2hex(id)} "${id}"`);
|
|
15
15
|
}
|
|
16
16
|
return id;
|
|
17
17
|
},
|
|
18
18
|
put: (buffer, offset, id) => {
|
|
19
|
-
const str =
|
|
19
|
+
const str = new TextEncoder('latin1').encode(id);
|
|
20
20
|
if (str.length !== 4)
|
|
21
21
|
throw new InternalParserError('Invalid length');
|
|
22
22
|
buffer.set(str, offset);
|
package/lib/common/Util.d.ts
CHANGED
package/lib/common/Util.js
CHANGED
|
@@ -141,3 +141,13 @@ export function toRatio(value) {
|
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
+
const byteToHexLookupTable = Array.from({ length: 256 }, (_, index) => index.toString(16).padStart(2, '0'));
|
|
145
|
+
export function uint8ArrayToHex(array) {
|
|
146
|
+
// Concatenating a string is faster than using an array.
|
|
147
|
+
let hexString = '';
|
|
148
|
+
// eslint-disable-next-line unicorn/no-for-loop -- Max performance is critical.
|
|
149
|
+
for (let index = 0; index < array.length; index++) {
|
|
150
|
+
hexString += byteToHexLookupTable[array[index]];
|
|
151
|
+
}
|
|
152
|
+
return hexString;
|
|
153
|
+
}
|
package/lib/mp4/MP4Parser.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Atom } from './Atom.js';
|
|
|
6
6
|
import * as AtomToken from './AtomToken.js';
|
|
7
7
|
import { ChapterTrackReferenceBox, Mp4ContentError, } from './AtomToken.js';
|
|
8
8
|
import { TrackType } from '../type.js';
|
|
9
|
-
import { uint8ArrayToHex
|
|
9
|
+
import { uint8ArrayToHex } from '../common/Util.js';
|
|
10
10
|
import { TextDecoder } from '@kayahr/text-encoding';
|
|
11
11
|
const debug = initDebug('music-metadata:parser:MP4');
|
|
12
12
|
const tagFormat = 'iTunes';
|
|
@@ -354,7 +354,7 @@ export class MP4Parser extends BasicParser {
|
|
|
354
354
|
}
|
|
355
355
|
default: {
|
|
356
356
|
const uint8Array = await this.tokenizer.readToken(new Token.Uint8ArrayType(payLoadLength));
|
|
357
|
-
this.addWarning(`Unsupported meta-item: ${tagKey}[${child.header.name}] => value=${uint8ArrayToHex(uint8Array)} ascii=${
|
|
357
|
+
this.addWarning(`Unsupported meta-item: ${tagKey}[${child.header.name}] => value=${uint8ArrayToHex(uint8Array)} ascii=${new TextDecoder('ascii').decode(uint8Array)}`);
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
360
|
}, metaAtom.getPayloadLength(0));
|
|
@@ -4,7 +4,7 @@ import { FourCcToken } from '../common/FourCC.js';
|
|
|
4
4
|
import { BasicParser } from '../common/BasicParser.js';
|
|
5
5
|
import { BlockHeaderToken, MetadataIdToken } from './WavPackToken.js';
|
|
6
6
|
import initDebug from 'debug';
|
|
7
|
-
import { uint8ArrayToHex } from '
|
|
7
|
+
import { uint8ArrayToHex } from '../common/Util.js';
|
|
8
8
|
import { makeUnexpectedFileContentError } from '../ParseError.js';
|
|
9
9
|
const debug = initDebug('music-metadata:parser:WavPack');
|
|
10
10
|
export class WavPackContentError extends makeUnexpectedFileContentError('WavPack') {
|
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": "11.8.
|
|
4
|
+
"version": "11.8.1",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Borewit",
|
|
7
7
|
"url": "https://github.com/Borewit"
|
|
@@ -113,8 +113,7 @@
|
|
|
113
113
|
"file-type": "^21.0.0",
|
|
114
114
|
"media-typer": "^1.1.0",
|
|
115
115
|
"strtok3": "^10.3.4",
|
|
116
|
-
"token-types": "^6.1.0"
|
|
117
|
-
"uint8array-extras": "^1.4.0"
|
|
116
|
+
"token-types": "^6.1.0"
|
|
118
117
|
},
|
|
119
118
|
"devDependencies": {
|
|
120
119
|
"@biomejs/biome": "2.1.4",
|