music-metadata 7.11.6 → 7.11.9
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 +3 -1
- package/lib/ParserFactory.d.ts +0 -1
- package/lib/ParserFactory.js +9 -8
- package/lib/aiff/AiffParser.d.ts +2 -3
- package/lib/aiff/AiffParser.js +2 -3
- package/lib/apev2/APEv2Parser.js +1 -2
- package/lib/apev2/APEv2Token.d.ts +5 -5
- package/lib/asf/AsfParser.d.ts +5 -5
- package/lib/asf/AsfParser.js +7 -7
- package/lib/asf/GUID.d.ts +14 -16
- package/lib/asf/GUID.js +13 -15
- package/lib/common/CombinedTagMapper.d.ts +3 -3
- package/lib/common/CombinedTagMapper.js +1 -1
- package/lib/common/GenericTagMapper.d.ts +2 -2
- package/lib/common/GenericTagMapper.js +2 -2
- package/lib/common/MetadataCollector.js +2 -2
- package/lib/common/Util.d.ts +5 -4
- package/lib/common/Util.js +12 -24
- package/lib/dsdiff/DsdiffParser.d.ts +1 -1
- package/lib/dsdiff/DsdiffParser.js +1 -1
- package/lib/dsf/DsfParser.d.ts +1 -1
- package/lib/dsf/DsfParser.js +1 -1
- package/lib/flac/FlacParser.d.ts +1 -1
- package/lib/flac/FlacParser.js +12 -12
- package/lib/id3v1/ID3v1Parser.js +39 -39
- package/lib/id3v2/AbstractID3Parser.d.ts +1 -1
- package/lib/id3v2/AbstractID3Parser.js +3 -3
- package/lib/id3v2/FrameParser.js +7 -1
- package/lib/id3v2/ID3v24TagMapper.d.ts +2 -2
- package/lib/id3v2/ID3v24TagMapper.js +2 -2
- package/lib/id3v2/ID3v2Parser.d.ts +3 -3
- package/lib/id3v2/ID3v2Parser.js +5 -15
- package/lib/iff/index.d.ts +2 -2
- package/lib/matroska/MatroskaDtd.d.ts +1 -1
- package/lib/matroska/MatroskaDtd.js +1 -1
- package/lib/matroska/MatroskaParser.js +9 -9
- package/lib/matroska/types.d.ts +2 -2
- package/lib/matroska/types.js +1 -0
- package/lib/mp4/AtomToken.d.ts +6 -6
- package/lib/mp4/AtomToken.js +2 -2
- package/lib/mp4/MP4Parser.js +3 -3
- package/lib/mpeg/MpegParser.d.ts +1 -1
- package/lib/mpeg/MpegParser.js +4 -9
- package/lib/musepack/index.d.ts +1 -1
- package/lib/musepack/index.js +1 -1
- package/lib/ogg/speex/SpeexParser.d.ts +2 -2
- package/lib/ogg/speex/SpeexParser.js +2 -2
- package/lib/ogg/theora/TheoraParser.d.ts +1 -1
- package/lib/ogg/theora/TheoraParser.js +1 -1
- package/lib/ogg/vorbis/Vorbis.d.ts +1 -11
- package/lib/type.d.ts +2 -9
- package/lib/type.js +2 -10
- package/lib/wav/BwfChunk.d.ts +17 -0
- package/lib/wav/BwfChunk.js +28 -0
- package/lib/wav/WaveParser.d.ts +3 -3
- package/lib/wav/WaveParser.js +15 -3
- package/lib/wavpack/WavPackParser.js +1 -7
- package/lib/wavpack/WavPackToken.d.ts +2 -2
- package/lib/wavpack/WavPackToken.js +1 -1
- package/package.json +22 -14
package/lib/id3v1/ID3v1Parser.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasID3v1Header = exports.ID3v1Parser = exports.Genres = void 0;
|
|
4
4
|
const initDebug = require("debug");
|
|
5
|
-
const
|
|
5
|
+
const token_types_1 = require("token-types");
|
|
6
6
|
const util = require("../common/Util");
|
|
7
7
|
const BasicParser_1 = require("../common/BasicParser");
|
|
8
8
|
const APEv2Parser_1 = require("../apev2/APEv2Parser");
|
|
@@ -12,34 +12,34 @@ const debug = initDebug('music-metadata:parser:ID3v1');
|
|
|
12
12
|
* Ref: https://de.wikipedia.org/wiki/Liste_der_ID3v1-Genres
|
|
13
13
|
*/
|
|
14
14
|
exports.Genres = [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
'Blues', 'Classic Rock', 'Country', 'Dance', 'Disco', 'Funk', 'Grunge', 'Hip-Hop',
|
|
16
|
+
'Jazz', 'Metal', 'New Age', 'Oldies', 'Other', 'Pop', 'R&B', 'Rap', 'Reggae', 'Rock',
|
|
17
|
+
'Techno', 'Industrial', 'Alternative', 'Ska', 'Death Metal', 'Pranks', 'Soundtrack',
|
|
18
|
+
'Euro-Techno', 'Ambient', 'Trip-Hop', 'Vocal', 'Jazz+Funk', 'Fusion', 'Trance',
|
|
19
|
+
'Classical', 'Instrumental', 'Acid', 'House', 'Game', 'Sound Clip', 'Gospel', 'Noise',
|
|
20
|
+
'Alt. Rock', 'Bass', 'Soul', 'Punk', 'Space', 'Meditative', 'Instrumental Pop',
|
|
21
|
+
'Instrumental Rock', 'Ethnic', 'Gothic', 'Darkwave', 'Techno-Industrial',
|
|
22
|
+
'Electronic', 'Pop-Folk', 'Eurodance', 'Dream', 'Southern Rock', 'Comedy', 'Cult',
|
|
23
|
+
'Gangsta Rap', 'Top 40', 'Christian Rap', 'Pop/Funk', 'Jungle', 'Native American',
|
|
24
|
+
'Cabaret', 'New Wave', 'Psychedelic', 'Rave', 'Showtunes', 'Trailer', 'Lo-Fi', 'Tribal',
|
|
25
|
+
'Acid Punk', 'Acid Jazz', 'Polka', 'Retro', 'Musical', 'Rock & Roll', 'Hard Rock',
|
|
26
|
+
'Folk', 'Folk/Rock', 'National Folk', 'Swing', 'Fast-Fusion', 'Bebob', 'Latin', 'Revival',
|
|
27
|
+
'Celtic', 'Bluegrass', 'Avantgarde', 'Gothic Rock', 'Progressive Rock', 'Psychedelic Rock',
|
|
28
|
+
'Symphonic Rock', 'Slow Rock', 'Big Band', 'Chorus', 'Easy Listening', 'Acoustic', 'Humour',
|
|
29
|
+
'Speech', 'Chanson', 'Opera', 'Chamber Music', 'Sonata', 'Symphony', 'Booty Bass', 'Primus',
|
|
30
|
+
'Porn Groove', 'Satire', 'Slow Jam', 'Club', 'Tango', 'Samba', 'Folklore',
|
|
31
|
+
'Ballad', 'Power Ballad', 'Rhythmic Soul', 'Freestyle', 'Duet', 'Punk Rock', 'Drum Solo',
|
|
32
|
+
'A Cappella', 'Euro-House', 'Dance Hall', 'Goa', 'Drum & Bass', 'Club-House',
|
|
33
|
+
'Hardcore', 'Terror', 'Indie', 'BritPop', 'Negerpunk', 'Polsk Punk', 'Beat',
|
|
34
|
+
'Christian Gangsta Rap', 'Heavy Metal', 'Black Metal', 'Crossover', 'Contemporary Christian',
|
|
35
|
+
'Christian Rock', 'Merengue', 'Salsa', 'Thrash Metal', 'Anime', 'JPop', 'Synthpop',
|
|
36
|
+
'Abstract', 'Art Rock', 'Baroque', 'Bhangra', 'Big Beat', 'Breakbeat', 'Chillout',
|
|
37
|
+
'Downtempo', 'Dub', 'EBM', 'Eclectic', 'Electro', 'Electroclash', 'Emo', 'Experimental',
|
|
38
|
+
'Garage', 'Global', 'IDM', 'Illbient', 'Industro-Goth', 'Jam Band', 'Krautrock',
|
|
39
|
+
'Leftfield', 'Lounge', 'Math Rock', 'New Romantic', 'Nu-Breakz', 'Post-Punk', 'Post-Rock',
|
|
40
|
+
'Psytrance', 'Shoegaze', 'Space Rock', 'Trop Rock', 'World Music', 'Neoclassical', 'Audiobook',
|
|
41
|
+
'Audio Theatre', 'Neue Deutsche Welle', 'Podcast', 'Indie Rock', 'G-Funk', 'Dubstep',
|
|
42
|
+
'Garage Rock', 'Psybient'
|
|
43
43
|
];
|
|
44
44
|
/**
|
|
45
45
|
* Spec: http://id3.org/ID3v1
|
|
@@ -54,7 +54,7 @@ const Iid3v1Token = {
|
|
|
54
54
|
*/
|
|
55
55
|
get: (buf, off) => {
|
|
56
56
|
const header = new Id3v1StringType(3).get(buf, off);
|
|
57
|
-
return header ===
|
|
57
|
+
return header === 'TAG' ? {
|
|
58
58
|
header,
|
|
59
59
|
title: new Id3v1StringType(30).get(buf, off + 3),
|
|
60
60
|
artist: new Id3v1StringType(30).get(buf, off + 33),
|
|
@@ -62,16 +62,16 @@ const Iid3v1Token = {
|
|
|
62
62
|
year: new Id3v1StringType(4).get(buf, off + 93),
|
|
63
63
|
comment: new Id3v1StringType(28).get(buf, off + 97),
|
|
64
64
|
// ID3v1.1 separator for track
|
|
65
|
-
zeroByte:
|
|
65
|
+
zeroByte: token_types_1.UINT8.get(buf, off + 127),
|
|
66
66
|
// track: ID3v1.1 field added by Michael Mutschler
|
|
67
|
-
track:
|
|
68
|
-
genre:
|
|
67
|
+
track: token_types_1.UINT8.get(buf, off + 126),
|
|
68
|
+
genre: token_types_1.UINT8.get(buf, off + 127)
|
|
69
69
|
} : null;
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
-
class Id3v1StringType extends
|
|
72
|
+
class Id3v1StringType extends token_types_1.StringType {
|
|
73
73
|
constructor(len) {
|
|
74
|
-
super(len,
|
|
74
|
+
super(len, 'binary');
|
|
75
75
|
}
|
|
76
76
|
get(buf, off) {
|
|
77
77
|
let value = super.get(buf, off);
|
|
@@ -105,9 +105,9 @@ class ID3v1Parser extends BasicParser_1.BasicParser {
|
|
|
105
105
|
}
|
|
106
106
|
const header = await this.tokenizer.readToken(Iid3v1Token, offset);
|
|
107
107
|
if (header) {
|
|
108
|
-
debug(
|
|
109
|
-
for (const id of [
|
|
110
|
-
if (header[id] && header[id] !==
|
|
108
|
+
debug('ID3v1 header found at: pos=%s', this.tokenizer.fileInfo.size - Iid3v1Token.len);
|
|
109
|
+
for (const id of ['title', 'artist', 'album', 'comment', 'track', 'year']) {
|
|
110
|
+
if (header[id] && header[id] !== '')
|
|
111
111
|
this.addTag(id, header[id]);
|
|
112
112
|
}
|
|
113
113
|
const genre = ID3v1Parser.getGenre(header.genre);
|
|
@@ -115,7 +115,7 @@ class ID3v1Parser extends BasicParser_1.BasicParser {
|
|
|
115
115
|
this.addTag('genre', genre);
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
|
-
debug(
|
|
118
|
+
debug('ID3v1 header not found at: pos=%s', this.tokenizer.fileInfo.size - Iid3v1Token.len);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
addTag(id, value) {
|
|
@@ -10,7 +10,7 @@ export declare abstract class AbstractID3Parser extends BasicParser {
|
|
|
10
10
|
/**
|
|
11
11
|
* Called after ID3v2 headers are parsed
|
|
12
12
|
*/
|
|
13
|
-
abstract
|
|
13
|
+
abstract postId3v2Parse(): Promise<void>;
|
|
14
14
|
protected finalize(): void;
|
|
15
15
|
private parseID3v2;
|
|
16
16
|
private tryReadId3v2Headers;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractID3Parser = void 0;
|
|
4
4
|
const core_1 = require("strtok3/lib/core");
|
|
5
|
-
const
|
|
5
|
+
const initDebug = require("debug");
|
|
6
6
|
const ID3v2Token_1 = require("./ID3v2Token");
|
|
7
7
|
const ID3v2Parser_1 = require("./ID3v2Parser");
|
|
8
8
|
const ID3v1Parser_1 = require("../id3v1/ID3v1Parser");
|
|
9
9
|
const BasicParser_1 = require("../common/BasicParser");
|
|
10
|
-
const debug =
|
|
10
|
+
const debug = initDebug('music-metadata:parser:ID3');
|
|
11
11
|
/**
|
|
12
12
|
* Abstract parser which tries take ID3v2 and ID3v1 headers.
|
|
13
13
|
*/
|
|
@@ -38,7 +38,7 @@ class AbstractID3Parser extends BasicParser_1.BasicParser {
|
|
|
38
38
|
async parseID3v2() {
|
|
39
39
|
await this.tryReadId3v2Headers();
|
|
40
40
|
debug('End of ID3v2 header, go to MPEG-parser: pos=%s', this.tokenizer.position);
|
|
41
|
-
await this.
|
|
41
|
+
await this.postId3v2Parse();
|
|
42
42
|
if (this.options.skipPostHeaders && this.metadata.hasAny()) {
|
|
43
43
|
this.finalize();
|
|
44
44
|
}
|
package/lib/id3v2/FrameParser.js
CHANGED
|
@@ -88,7 +88,13 @@ class FrameParser {
|
|
|
88
88
|
case 'MVNM':
|
|
89
89
|
case 'PCS':
|
|
90
90
|
case 'PCST':
|
|
91
|
-
|
|
91
|
+
let text;
|
|
92
|
+
try {
|
|
93
|
+
text = util.decodeString(b.subarray(1), encoding).replace(/\x00+$/, '');
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
this.warningCollector.addWarning(`id3v2.${this.major} type=${type} header has invalid string value: ${error.message}`);
|
|
97
|
+
}
|
|
92
98
|
switch (type) {
|
|
93
99
|
case 'TMCL': // Musician credits list
|
|
94
100
|
case 'TIPL': // Involved people list
|
|
@@ -6,8 +6,8 @@ export declare class ID3v24TagMapper extends CaseInsensitiveTagMap {
|
|
|
6
6
|
constructor();
|
|
7
7
|
/**
|
|
8
8
|
* Handle post mapping exceptions / correction
|
|
9
|
-
* @param
|
|
10
|
-
* @param warnings
|
|
9
|
+
* @param tag to post map
|
|
10
|
+
* @param warnings Wil be used to register (collect) warnings
|
|
11
11
|
* @return Common value e.g. "Buena Vista Social Club"
|
|
12
12
|
*/
|
|
13
13
|
protected postMap(tag: ITag, warnings: INativeMetadataCollector): void;
|
|
@@ -152,8 +152,8 @@ class ID3v24TagMapper extends CaseInsensitiveTagMap_1.CaseInsensitiveTagMap {
|
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
154
|
* Handle post mapping exceptions / correction
|
|
155
|
-
* @param
|
|
156
|
-
* @param warnings
|
|
155
|
+
* @param tag to post map
|
|
156
|
+
* @param warnings Wil be used to register (collect) warnings
|
|
157
157
|
* @return Common value e.g. "Buena Vista Social Club"
|
|
158
158
|
*/
|
|
159
159
|
postMap(tag, warnings) {
|
|
@@ -9,9 +9,9 @@ export declare class ID3v2Parser {
|
|
|
9
9
|
private static readFrameData;
|
|
10
10
|
/**
|
|
11
11
|
* Create a combined tag key, of tag & description
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @returns
|
|
12
|
+
* @param tag e.g.: COM
|
|
13
|
+
* @param description e.g. iTunPGAP
|
|
14
|
+
* @returns string e.g. COM:iTunPGAP
|
|
15
15
|
*/
|
|
16
16
|
private static makeDescriptionTagName;
|
|
17
17
|
private tokenizer;
|
package/lib/id3v2/ID3v2Parser.js
CHANGED
|
@@ -68,9 +68,9 @@ class ID3v2Parser {
|
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* Create a combined tag key, of tag & description
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
73
|
-
* @returns
|
|
71
|
+
* @param tag e.g.: COM
|
|
72
|
+
* @param description e.g. iTunPGAP
|
|
73
|
+
* @returns string e.g. COM:iTunPGAP
|
|
74
74
|
*/
|
|
75
75
|
static makeDescriptionTagName(tag, description) {
|
|
76
76
|
return tag + (description ? ':' + description : '');
|
|
@@ -85,22 +85,12 @@ class ID3v2Parser {
|
|
|
85
85
|
}
|
|
86
86
|
this.id3Header = id3Header;
|
|
87
87
|
this.headerType = ('ID3v2.' + id3Header.version.major);
|
|
88
|
-
|
|
89
|
-
return this.parseExtendedHeader();
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
return this.parseId3Data(id3Header.size);
|
|
93
|
-
}
|
|
88
|
+
return id3Header.flags.isExtendedHeader ? this.parseExtendedHeader() : this.parseId3Data(id3Header.size);
|
|
94
89
|
}
|
|
95
90
|
async parseExtendedHeader() {
|
|
96
91
|
const extendedHeader = await this.tokenizer.readToken(ID3v2Token_1.ExtendedHeader);
|
|
97
92
|
const dataRemaining = extendedHeader.size - ID3v2Token_1.ExtendedHeader.len;
|
|
98
|
-
|
|
99
|
-
return this.parseExtendedHeaderData(dataRemaining, extendedHeader.size);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
return this.parseId3Data(this.id3Header.size - extendedHeader.size);
|
|
103
|
-
}
|
|
93
|
+
return dataRemaining > 0 ? this.parseExtendedHeaderData(dataRemaining, extendedHeader.size) : this.parseId3Data(this.id3Header.size - extendedHeader.size);
|
|
104
94
|
}
|
|
105
95
|
async parseExtendedHeaderData(dataRemaining, extendedHeaderSize) {
|
|
106
96
|
const buffer = Buffer.alloc(dataRemaining);
|
package/lib/iff/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { IGetToken } from 'strtok3/lib/core';
|
|
|
5
5
|
*/
|
|
6
6
|
export interface IChunkHeader {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* A chunk ID (ie, 4 ASCII bytes)
|
|
9
9
|
*/
|
|
10
10
|
chunkID: string;
|
|
11
11
|
/**
|
|
@@ -19,7 +19,7 @@ export interface IChunkHeader {
|
|
|
19
19
|
*/
|
|
20
20
|
export interface IChunkHeader64 {
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* A chunk ID (ie, 4 ASCII bytes)
|
|
23
23
|
*/
|
|
24
24
|
chunkID: string;
|
|
25
25
|
/**
|
|
@@ -3,6 +3,6 @@ import { IContainerType } from './types';
|
|
|
3
3
|
* Elements of document type description
|
|
4
4
|
* Derived from https://github.com/tungol/EBML/blob/master/doctypes/matroska.dtd
|
|
5
5
|
* Extended with:
|
|
6
|
-
*
|
|
6
|
+
* - https://www.matroska.org/technical/specs/index.html
|
|
7
7
|
*/
|
|
8
8
|
export declare const elements: IContainerType;
|
|
@@ -6,7 +6,7 @@ const types_1 = require("./types");
|
|
|
6
6
|
* Elements of document type description
|
|
7
7
|
* Derived from https://github.com/tungol/EBML/blob/master/doctypes/matroska.dtd
|
|
8
8
|
* Extended with:
|
|
9
|
-
*
|
|
9
|
+
* - https://www.matroska.org/technical/specs/index.html
|
|
10
10
|
*/
|
|
11
11
|
exports.elements = {
|
|
12
12
|
0x1a45dfa3: {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MatroskaParser = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const token_types_1 = require("token-types");
|
|
5
|
+
const initDebug = require("debug");
|
|
6
6
|
const BasicParser_1 = require("../common/BasicParser");
|
|
7
7
|
const types_1 = require("./types");
|
|
8
8
|
const matroskaDtd = require("./MatroskaDtd");
|
|
9
|
-
const debug =
|
|
9
|
+
const debug = initDebug('music-metadata:parser:matroska');
|
|
10
10
|
/**
|
|
11
11
|
* Extensible Binary Meta Language (EBML) parser
|
|
12
12
|
* https://en.wikipedia.org/wiki/Extensible_Binary_Meta_Language
|
|
@@ -90,7 +90,7 @@ class MatroskaParser extends BasicParser_1.BasicParser {
|
|
|
90
90
|
if (matroska.segment.tags) {
|
|
91
91
|
matroska.segment.tags.tag.forEach(tag => {
|
|
92
92
|
const target = tag.target;
|
|
93
|
-
const targetType = target.targetTypeValue ? types_1.TargetType[target.targetTypeValue] : (target.targetType ? target.targetType : 'track');
|
|
93
|
+
const targetType = (target === null || target === void 0 ? void 0 : target.targetTypeValue) ? types_1.TargetType[target.targetTypeValue] : ((target === null || target === void 0 ? void 0 : target.targetType) ? target.targetType : 'track');
|
|
94
94
|
tag.simpleTags.forEach(simpleTag => {
|
|
95
95
|
const value = simpleTag.string ? simpleTag.string : simpleTag.binary;
|
|
96
96
|
this.addTag(`${targetType}:${simpleTag.name}`, value);
|
|
@@ -162,7 +162,7 @@ class MatroskaParser extends BasicParser_1.BasicParser {
|
|
|
162
162
|
return tree;
|
|
163
163
|
}
|
|
164
164
|
async readVintData(maxLength) {
|
|
165
|
-
const msb = await this.tokenizer.peekNumber(
|
|
165
|
+
const msb = await this.tokenizer.peekNumber(token_types_1.UINT8);
|
|
166
166
|
let mask = 0x80;
|
|
167
167
|
let oc = 1;
|
|
168
168
|
// Calculate VINT_WIDTH
|
|
@@ -202,11 +202,11 @@ class MatroskaParser extends BasicParser_1.BasicParser {
|
|
|
202
202
|
case 0:
|
|
203
203
|
return 0.0;
|
|
204
204
|
case 4:
|
|
205
|
-
return this.tokenizer.readNumber(
|
|
205
|
+
return this.tokenizer.readNumber(token_types_1.Float32_BE);
|
|
206
206
|
case 8:
|
|
207
|
-
return this.tokenizer.readNumber(
|
|
207
|
+
return this.tokenizer.readNumber(token_types_1.Float64_BE);
|
|
208
208
|
case 10:
|
|
209
|
-
return this.tokenizer.readNumber(
|
|
209
|
+
return this.tokenizer.readNumber(token_types_1.Float64_BE);
|
|
210
210
|
default:
|
|
211
211
|
throw new Error(`Invalid IEEE-754 float length: ${e.len}`);
|
|
212
212
|
}
|
|
@@ -220,7 +220,7 @@ class MatroskaParser extends BasicParser_1.BasicParser {
|
|
|
220
220
|
return buf.readUIntBE(e.len - nrLen, nrLen);
|
|
221
221
|
}
|
|
222
222
|
async readString(e) {
|
|
223
|
-
const rawString = await this.tokenizer.readToken(new
|
|
223
|
+
const rawString = await this.tokenizer.readToken(new token_types_1.StringType(e.len, 'utf-8'));
|
|
224
224
|
return rawString.replace(/\00.*$/g, '');
|
|
225
225
|
}
|
|
226
226
|
async readBuffer(e) {
|
package/lib/matroska/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface IHeader {
|
|
|
4
4
|
len: number;
|
|
5
5
|
}
|
|
6
6
|
export declare enum DataType {
|
|
7
|
-
string = 0,
|
|
7
|
+
'string' = 0,
|
|
8
8
|
uint = 1,
|
|
9
9
|
uid = 2,
|
|
10
10
|
bool = 3,
|
|
@@ -99,7 +99,7 @@ export interface ICueReference {
|
|
|
99
99
|
}
|
|
100
100
|
export interface ISimpleTag {
|
|
101
101
|
name?: string;
|
|
102
|
-
string?: string;
|
|
102
|
+
'string'?: string;
|
|
103
103
|
binary?: Buffer;
|
|
104
104
|
language?: string;
|
|
105
105
|
default?: boolean;
|
package/lib/matroska/types.js
CHANGED
package/lib/mp4/AtomToken.d.ts
CHANGED
|
@@ -58,9 +58,9 @@ export interface IAtomMvhd extends IAtomMxhd {
|
|
|
58
58
|
* Reserved: Ten bytes reserved for use by Apple. Set to 0.
|
|
59
59
|
*/
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
61
|
+
* Matrix structure: The matrix structure associated with this movie.
|
|
62
|
+
* A matrix shows how to map points from one coordinate space into another.
|
|
63
|
+
* See Matrices for a discussion of how display matrices are used in QuickTime.
|
|
64
64
|
*/
|
|
65
65
|
/**
|
|
66
66
|
* Preview time: The time value in the movie at which the preview begins.
|
|
@@ -143,8 +143,8 @@ export interface IAtomMdhd extends IAtomMxhd {
|
|
|
143
143
|
/**
|
|
144
144
|
* Token: Media Header Atom
|
|
145
145
|
* Ref:
|
|
146
|
-
*
|
|
147
|
-
*
|
|
146
|
+
* - https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-SW34
|
|
147
|
+
* - https://wiki.multimedia.cx/index.php/QuickTime_container#mdhd
|
|
148
148
|
*/
|
|
149
149
|
export declare class MdhdAtom extends FixedLengthAtom implements IGetToken<IAtomMdhd> {
|
|
150
150
|
len: number;
|
|
@@ -305,7 +305,7 @@ export declare const SoundSampleDescriptionVersion: IGetToken<ISoundSampleDescri
|
|
|
305
305
|
export interface ISoundSampleDescriptionV0 {
|
|
306
306
|
numAudioChannels: number;
|
|
307
307
|
/**
|
|
308
|
-
*
|
|
308
|
+
* Number of bits in each uncompressed sound sample
|
|
309
309
|
*/
|
|
310
310
|
sampleSize: number;
|
|
311
311
|
/**
|
package/lib/mp4/AtomToken.js
CHANGED
|
@@ -89,8 +89,8 @@ const SecondsSinceMacEpoch = {
|
|
|
89
89
|
/**
|
|
90
90
|
* Token: Media Header Atom
|
|
91
91
|
* Ref:
|
|
92
|
-
*
|
|
93
|
-
*
|
|
92
|
+
* - https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-SW34
|
|
93
|
+
* - https://wiki.multimedia.cx/index.php/QuickTime_container#mdhd
|
|
94
94
|
*/
|
|
95
95
|
class MdhdAtom extends FixedLengthAtom {
|
|
96
96
|
constructor(len) {
|
package/lib/mp4/MP4Parser.js
CHANGED
|
@@ -99,9 +99,9 @@ class MP4Parser extends BasicParser_1.BasicParser {
|
|
|
99
99
|
* Ref: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html#//apple_ref/doc/uid/TP40000939-CH204-56313
|
|
100
100
|
*/
|
|
101
101
|
mvhd: async (len) => {
|
|
102
|
-
const
|
|
103
|
-
this.metadata.setFormat('creationTime',
|
|
104
|
-
this.metadata.setFormat('modificationTime',
|
|
102
|
+
const mvhd = await this.tokenizer.readToken(new AtomToken.MvhdAtom(len));
|
|
103
|
+
this.metadata.setFormat('creationTime', mvhd.creationTime);
|
|
104
|
+
this.metadata.setFormat('modificationTime', mvhd.modificationTime);
|
|
105
105
|
},
|
|
106
106
|
/**
|
|
107
107
|
* Parse media header (mdhd) atom
|
package/lib/mpeg/MpegParser.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export declare class MpegParser extends AbstractID3Parser {
|
|
|
20
20
|
/**
|
|
21
21
|
* Called after ID3 headers have been parsed
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
postId3v2Parse(): Promise<void>;
|
|
24
24
|
/**
|
|
25
25
|
* Called after file has been fully parsed, this allows, if present, to exclude the ID3v1.1 header length
|
|
26
26
|
*/
|
package/lib/mpeg/MpegParser.js
CHANGED
|
@@ -224,7 +224,7 @@ class MpegParser extends AbstractID3Parser_1.AbstractID3Parser {
|
|
|
224
224
|
/**
|
|
225
225
|
* Called after ID3 headers have been parsed
|
|
226
226
|
*/
|
|
227
|
-
async
|
|
227
|
+
async postId3v2Parse() {
|
|
228
228
|
this.metadata.setFormat('lossless', false);
|
|
229
229
|
try {
|
|
230
230
|
let quit = false;
|
|
@@ -334,12 +334,7 @@ class MpegParser extends AbstractID3Parser_1.AbstractID3Parser {
|
|
|
334
334
|
this.metadata.setFormat('lossless', false);
|
|
335
335
|
this.metadata.setFormat('sampleRate', header.samplingRate);
|
|
336
336
|
this.frameCount++;
|
|
337
|
-
|
|
338
|
-
return this.parseAdts(header); // ADTS, usually AAC
|
|
339
|
-
}
|
|
340
|
-
else {
|
|
341
|
-
return this.parseAudioFrameHeader(header); // MP3
|
|
342
|
-
}
|
|
337
|
+
return header.version >= 2 && header.layer === 0 ? this.parseAdts(header) : this.parseAudioFrameHeader(header);
|
|
343
338
|
}
|
|
344
339
|
/**
|
|
345
340
|
* @return {Promise<boolean>} true if parser should quit
|
|
@@ -485,9 +480,9 @@ class MpegParser extends AbstractID3Parser_1.AbstractID3Parser {
|
|
|
485
480
|
* @returns {Promise<string>}
|
|
486
481
|
*/
|
|
487
482
|
async readXingInfoHeader() {
|
|
488
|
-
const
|
|
483
|
+
const offset = this.tokenizer.position;
|
|
489
484
|
const infoTag = await (0, XingTag_1.readXingHeader)(this.tokenizer);
|
|
490
|
-
this.offset += this.tokenizer.position -
|
|
485
|
+
this.offset += this.tokenizer.position - offset;
|
|
491
486
|
if (infoTag.lame) {
|
|
492
487
|
this.metadata.setFormat('tool', 'LAME ' + common.stripNulls(infoTag.lame.version));
|
|
493
488
|
if (infoTag.lame.extended) {
|
package/lib/musepack/index.d.ts
CHANGED
package/lib/musepack/index.js
CHANGED
|
@@ -7,7 +7,7 @@ const MpcSv8Parser_1 = require("./sv8/MpcSv8Parser");
|
|
|
7
7
|
const MpcSv7Parser_1 = require("./sv7/MpcSv7Parser");
|
|
8
8
|
const debug = initDebug('music-metadata:parser:musepack');
|
|
9
9
|
class MusepackParser extends AbstractID3Parser_1.AbstractID3Parser {
|
|
10
|
-
async
|
|
10
|
+
async postId3v2Parse() {
|
|
11
11
|
const signature = await this.tokenizer.peekToken(new Token.StringType(3, 'binary'));
|
|
12
12
|
let mpcParser;
|
|
13
13
|
switch (signature) {
|
|
@@ -7,8 +7,8 @@ import { INativeMetadataCollector } from '../../common/MetadataCollector';
|
|
|
7
7
|
/**
|
|
8
8
|
* Speex, RFC 5574
|
|
9
9
|
* Ref:
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* - https://www.speex.org/docs/manual/speex-manual/
|
|
11
|
+
* - https://tools.ietf.org/html/rfc5574
|
|
12
12
|
*/
|
|
13
13
|
export declare class SpeexParser extends VorbisParser {
|
|
14
14
|
private tokenizer;
|
|
@@ -8,8 +8,8 @@ const debug = initDebug('music-metadata:parser:ogg:speex');
|
|
|
8
8
|
/**
|
|
9
9
|
* Speex, RFC 5574
|
|
10
10
|
* Ref:
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* - https://www.speex.org/docs/manual/speex-manual/
|
|
12
|
+
* - https://tools.ietf.org/html/rfc5574
|
|
13
13
|
*/
|
|
14
14
|
class SpeexParser extends VorbisParser_1.VorbisParser {
|
|
15
15
|
constructor(metadata, options, tokenizer) {
|
|
@@ -5,7 +5,7 @@ import { INativeMetadataCollector } from '../../common/MetadataCollector';
|
|
|
5
5
|
import * as Ogg from '../Ogg';
|
|
6
6
|
/**
|
|
7
7
|
* Ref:
|
|
8
|
-
*
|
|
8
|
+
* - https://theora.org/doc/Theora.pdf
|
|
9
9
|
*/
|
|
10
10
|
export declare class TheoraParser implements Ogg.IPageConsumer {
|
|
11
11
|
private metadata;
|
|
@@ -6,7 +6,7 @@ const Theora_1 = require("./Theora");
|
|
|
6
6
|
const debug = initDebug('music-metadata:parser:ogg:theora');
|
|
7
7
|
/**
|
|
8
8
|
* Ref:
|
|
9
|
-
*
|
|
9
|
+
* - https://theora.org/doc/Theora.pdf
|
|
10
10
|
*/
|
|
11
11
|
class TheoraParser {
|
|
12
12
|
constructor(metadata, options, tokenizer) {
|
|
@@ -1,28 +1,18 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IGetToken } from 'strtok3/lib/core';
|
|
3
3
|
import { IPicture } from '../../type';
|
|
4
|
-
export interface IVorbisPicture extends IPicture {
|
|
5
|
-
type: string;
|
|
6
|
-
description: string;
|
|
7
|
-
width: number;
|
|
8
|
-
height: number;
|
|
9
|
-
colour_depth: number;
|
|
10
|
-
indexed_color: number;
|
|
11
|
-
}
|
|
12
4
|
/**
|
|
13
5
|
* Interface to parsed result of METADATA_BLOCK_PICTURE
|
|
14
6
|
* Ref: https://wiki.xiph.org/VorbisComment#METADATA_BLOCK_PICTURE
|
|
15
7
|
* Ref: https://xiph.org/flac/format.html#metadata_block_picture
|
|
16
8
|
*/
|
|
17
|
-
export interface IVorbisPicture {
|
|
9
|
+
export interface IVorbisPicture extends IPicture {
|
|
18
10
|
type: string;
|
|
19
|
-
format: string;
|
|
20
11
|
description: string;
|
|
21
12
|
width: number;
|
|
22
13
|
height: number;
|
|
23
14
|
colour_depth: number;
|
|
24
15
|
indexed_color: number;
|
|
25
|
-
data: Buffer;
|
|
26
16
|
}
|
|
27
17
|
/**
|
|
28
18
|
* Parse the METADATA_BLOCK_PICTURE
|
package/lib/type.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { GenericTagId, TagType } from './common/GenericTagTypes';
|
|
3
3
|
import { IFooter } from './apev2/APEv2Token';
|
|
4
|
+
import { TrackType } from './matroska/types';
|
|
5
|
+
export { TrackType } from './matroska/types';
|
|
4
6
|
/**
|
|
5
7
|
* Attached picture, typically used for cover art
|
|
6
8
|
*/
|
|
@@ -374,15 +376,6 @@ export interface IVideoTrack {
|
|
|
374
376
|
colourSpace?: Buffer;
|
|
375
377
|
gammaValue?: number;
|
|
376
378
|
}
|
|
377
|
-
export declare enum TrackType {
|
|
378
|
-
video = 1,
|
|
379
|
-
audio = 2,
|
|
380
|
-
complex = 3,
|
|
381
|
-
logo = 4,
|
|
382
|
-
subtitle = 17,
|
|
383
|
-
button = 18,
|
|
384
|
-
control = 32
|
|
385
|
-
}
|
|
386
379
|
export interface ITrackInfo {
|
|
387
380
|
type?: TrackType;
|
|
388
381
|
codecName?: string;
|