music-metadata 12.2.0 → 12.2.2
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 +10 -0
- package/lib/ParserFactory.d.ts +1 -1
- package/lib/ParserFactory.js +4 -3
- package/lib/aiff/AiffParser.js +2 -5
- package/lib/common/Allocation.js +2 -2
- package/lib/common/CombinedTagMapper.js +0 -1
- package/lib/common/MetadataCollector.d.ts +5 -5
- package/lib/common/MetadataCollector.js +12 -4
- package/lib/dsdiff/DsdiffLoader.js +1 -1
- package/lib/dsdiff/DsdiffParser.js +2 -6
- package/lib/dsf/DsfParser.js +1 -1
- package/lib/ebml/EbmlIterator.d.ts +20 -15
- package/lib/ebml/EbmlIterator.js +75 -38
- package/lib/ebml/types.d.ts +36 -8
- package/lib/ebml/types.js +2 -1
- package/lib/flac/FlacParser.js +4 -12
- package/lib/id3v1/ID3v1Parser.d.ts +1 -1
- package/lib/id3v1/ID3v1Parser.js +2 -1
- package/lib/id3v2/EmbeddedID3v2.d.ts +5 -0
- package/lib/id3v2/EmbeddedID3v2.js +29 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +6 -1
- package/lib/matroska/MatroskaDtd.d.ts +630 -2
- package/lib/matroska/MatroskaDtd.js +57 -40
- package/lib/matroska/MatroskaParser.js +119 -55
- package/lib/matroska/types.d.ts +31 -106
- package/lib/mp4/MP4Parser.js +13 -3
- package/lib/mpeg/MpegParser.js +2 -2
- package/lib/ogg/OggStreamMetadata.d.ts +2 -2
- package/lib/ogg/vorbis/VorbisDecoder.d.ts +10 -0
- package/lib/ogg/vorbis/VorbisDecoder.js +15 -0
- package/lib/ogg/vorbis/VorbisStream.js +3 -9
- package/lib/type.d.ts +4 -2
- package/lib/wav/WaveParser.js +2 -5
- package/package.json +5 -5
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ITokenizer } from 'strtok3';
|
|
2
|
+
import type { INativeMetadataCollector } from '../common/MetadataCollector.js';
|
|
3
|
+
import type { IOptions } from '../type.js';
|
|
4
|
+
/** Borrow the chunk payload; consume its remainder while leaving container padding to the caller. */
|
|
5
|
+
export declare function parseEmbeddedID3v2(metadata: INativeMetadataCollector, tokenizer: ITokenizer, options: IOptions, size: number): Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createTokenizerView, EndOfStreamError, TokenizerBoundaryError } from 'strtok3';
|
|
2
|
+
import { validateAllocation } from '../common/Allocation.js';
|
|
3
|
+
import { Id3v2ContentError } from './FrameParser.js';
|
|
4
|
+
import { ID3v2Parser } from './ID3v2Parser.js';
|
|
5
|
+
import { ID3v2Header } from './ID3v2Token.js';
|
|
6
|
+
/** Borrow the chunk payload; consume its remainder while leaving container padding to the caller. */
|
|
7
|
+
export async function parseEmbeddedID3v2(metadata, tokenizer, options, size) {
|
|
8
|
+
// Retain the metadata payload limit, including for caller-provided tokenizers.
|
|
9
|
+
validateAllocation(size, options);
|
|
10
|
+
if (size < ID3v2Header.len ||
|
|
11
|
+
(tokenizer.fileInfo.size !== undefined && size > tokenizer.fileInfo.size - tokenizer.position)) {
|
|
12
|
+
throw new EndOfStreamError();
|
|
13
|
+
}
|
|
14
|
+
const embeddedTokenizer = createTokenizerView(tokenizer, size);
|
|
15
|
+
try {
|
|
16
|
+
await new ID3v2Parser().parse(metadata, embeddedTokenizer, options);
|
|
17
|
+
await embeddedTokenizer.consumeRemainder();
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof TokenizerBoundaryError) {
|
|
21
|
+
throw new Id3v2ContentError(`Embedded ID3v2 read exceeds chunk boundary: ${error.message}`);
|
|
22
|
+
}
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
// Closing the borrowed view never closes the container's input.
|
|
27
|
+
await embeddedTokenizer.close();
|
|
28
|
+
}
|
|
29
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -15,8 +15,10 @@ export * from './core.js';
|
|
|
15
15
|
export declare function parseStream(stream: Readable, fileInfo?: IFileInfo | string, options?: IOptions): Promise<IAudioMetadata>;
|
|
16
16
|
/**
|
|
17
17
|
* Parse audio from Node file
|
|
18
|
+
* Requires a regular file; symlinks to regular files are supported.
|
|
18
19
|
* @param filePath - Media file to read meta-data from
|
|
19
20
|
* @param options - Parsing options
|
|
20
21
|
* @returns Metadata
|
|
22
|
+
* @throws {NotRegularFileError} If the opened filesystem object is not a regular file.
|
|
21
23
|
*/
|
|
22
24
|
export declare function parseFile(filePath: string, options?: IOptions): Promise<IAudioMetadata>;
|
package/lib/index.js
CHANGED
|
@@ -26,13 +26,18 @@ export async function parseStream(stream, fileInfo, options = {}) {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Parse audio from Node file
|
|
29
|
+
* Requires a regular file; symlinks to regular files are supported.
|
|
29
30
|
* @param filePath - Media file to read meta-data from
|
|
30
31
|
* @param options - Parsing options
|
|
31
32
|
* @returns Metadata
|
|
33
|
+
* @throws {NotRegularFileError} If the opened filesystem object is not a regular file.
|
|
32
34
|
*/
|
|
33
35
|
export async function parseFile(filePath, options = {}) {
|
|
34
36
|
debug(`parseFile: ${filePath}`);
|
|
35
|
-
const fileTokenizer = await fromFile(filePath,
|
|
37
|
+
const fileTokenizer = await fromFile(filePath, {
|
|
38
|
+
...getTokenizerOptions(options),
|
|
39
|
+
regularFileOnly: true
|
|
40
|
+
});
|
|
36
41
|
const parserFactory = new ParserFactory();
|
|
37
42
|
try {
|
|
38
43
|
const parserLoader = parserFactory.findLoaderForExtension(filePath);
|