music-metadata 7.11.4 → 7.11.8

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.
Files changed (92) hide show
  1. package/README.md +2 -1
  2. package/lib/ParserFactory.d.ts +0 -1
  3. package/lib/ParserFactory.js +8 -8
  4. package/lib/aiff/AiffParser.d.ts +2 -3
  5. package/lib/aiff/AiffParser.js +2 -3
  6. package/lib/aiff/AiffToken.d.ts +1 -1
  7. package/lib/apev2/APEv2Parser.js +2 -3
  8. package/lib/apev2/APEv2TagMapper.js +1 -0
  9. package/lib/apev2/APEv2Token.d.ts +5 -5
  10. package/lib/apev2/APEv2Token.js +1 -0
  11. package/lib/asf/AsfObject.d.ts +1 -1
  12. package/lib/asf/AsfParser.d.ts +5 -5
  13. package/lib/asf/AsfParser.js +7 -7
  14. package/lib/asf/AsfTagMapper.js +1 -0
  15. package/lib/asf/AsfUtil.d.ts +1 -1
  16. package/lib/asf/AsfUtil.js +1 -1
  17. package/lib/asf/GUID.d.ts +14 -16
  18. package/lib/asf/GUID.js +13 -15
  19. package/lib/common/CaseInsensitiveTagMap.js +1 -0
  20. package/lib/common/CombinedTagMapper.d.ts +3 -3
  21. package/lib/common/CombinedTagMapper.js +2 -1
  22. package/lib/common/FourCC.d.ts +1 -1
  23. package/lib/common/FourCC.js +2 -1
  24. package/lib/common/GenericTagMapper.d.ts +2 -2
  25. package/lib/common/GenericTagMapper.js +3 -2
  26. package/lib/common/GenericTagTypes.js +1 -0
  27. package/lib/common/MetadataCollector.d.ts +4 -4
  28. package/lib/common/MetadataCollector.js +5 -3
  29. package/lib/common/Util.d.ts +5 -4
  30. package/lib/common/Util.js +13 -24
  31. package/lib/dsdiff/DsdiffParser.d.ts +1 -1
  32. package/lib/dsdiff/DsdiffParser.js +3 -3
  33. package/lib/dsdiff/DsdiffToken.d.ts +1 -1
  34. package/lib/dsf/DsfParser.d.ts +1 -1
  35. package/lib/dsf/DsfParser.js +3 -3
  36. package/lib/flac/FlacParser.d.ts +2 -2
  37. package/lib/flac/FlacParser.js +13 -13
  38. package/lib/id3v1/ID3v1Parser.js +39 -39
  39. package/lib/id3v1/ID3v1TagMap.d.ts +1 -1
  40. package/lib/id3v1/ID3v1TagMap.js +1 -0
  41. package/lib/id3v2/AbstractID3Parser.d.ts +1 -1
  42. package/lib/id3v2/AbstractID3Parser.js +6 -6
  43. package/lib/id3v2/FrameParser.js +7 -1
  44. package/lib/id3v2/ID3v22TagMapper.js +3 -1
  45. package/lib/id3v2/ID3v24TagMapper.d.ts +3 -3
  46. package/lib/id3v2/ID3v24TagMapper.js +4 -3
  47. package/lib/id3v2/ID3v2Parser.d.ts +3 -3
  48. package/lib/id3v2/ID3v2Parser.js +5 -15
  49. package/lib/id3v2/ID3v2Token.d.ts +1 -1
  50. package/lib/iff/index.d.ts +3 -3
  51. package/lib/iff/index.js +1 -1
  52. package/lib/index.d.ts +11 -0
  53. package/lib/index.js +10 -0
  54. package/lib/matroska/MatroskaDtd.d.ts +1 -1
  55. package/lib/matroska/MatroskaDtd.js +1 -1
  56. package/lib/matroska/MatroskaParser.d.ts +1 -1
  57. package/lib/matroska/MatroskaParser.js +9 -9
  58. package/lib/matroska/MatroskaTagMapper.js +1 -0
  59. package/lib/matroska/types.d.ts +2 -2
  60. package/lib/matroska/types.js +1 -0
  61. package/lib/mp4/AtomToken.d.ts +6 -6
  62. package/lib/mp4/AtomToken.js +3 -3
  63. package/lib/mp4/MP4Parser.js +5 -5
  64. package/lib/mp4/MP4TagMapper.js +1 -0
  65. package/lib/mpeg/MpegParser.d.ts +1 -1
  66. package/lib/mpeg/MpegParser.js +4 -9
  67. package/lib/mpeg/XingTag.d.ts +1 -1
  68. package/lib/musepack/index.d.ts +1 -1
  69. package/lib/musepack/index.js +2 -2
  70. package/lib/musepack/sv7/MpcSv7Parser.js +2 -2
  71. package/lib/musepack/sv8/MpcSv8Parser.js +1 -1
  72. package/lib/musepack/sv8/StreamVersion8.js +1 -1
  73. package/lib/ogg/OggParser.d.ts +2 -2
  74. package/lib/ogg/OggParser.js +2 -2
  75. package/lib/ogg/opus/OpusParser.js +1 -1
  76. package/lib/ogg/speex/SpeexParser.d.ts +2 -2
  77. package/lib/ogg/speex/SpeexParser.js +3 -3
  78. package/lib/ogg/theora/TheoraParser.d.ts +1 -1
  79. package/lib/ogg/theora/TheoraParser.js +1 -1
  80. package/lib/ogg/vorbis/Vorbis.d.ts +2 -12
  81. package/lib/ogg/vorbis/VorbisTagMapper.js +1 -0
  82. package/lib/riff/RiffChunk.d.ts +1 -1
  83. package/lib/riff/RiffInfoTagMap.js +1 -0
  84. package/lib/type.d.ts +3 -10
  85. package/lib/type.js +3 -10
  86. package/lib/wav/WaveChunk.d.ts +1 -1
  87. package/lib/wav/WaveParser.d.ts +3 -3
  88. package/lib/wav/WaveParser.js +3 -3
  89. package/lib/wavpack/WavPackParser.js +1 -7
  90. package/lib/wavpack/WavPackToken.d.ts +2 -2
  91. package/lib/wavpack/WavPackToken.js +1 -1
  92. package/package.json +27 -19
@@ -1,8 +1,8 @@
1
- 'use strict';
1
+ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DsfParser = void 0;
4
- const AbstractID3Parser_1 = require("../id3v2/AbstractID3Parser");
5
4
  const _debug = require("debug");
5
+ const AbstractID3Parser_1 = require("../id3v2/AbstractID3Parser");
6
6
  const DsfChunk_1 = require("./DsfChunk");
7
7
  const ID3v2Parser_1 = require("../id3v2/ID3v2Parser");
8
8
  const debug = _debug('music-metadata:parser:DSF');
@@ -11,7 +11,7 @@ const debug = _debug('music-metadata:parser:DSF');
11
11
  * Ref: https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf
12
12
  */
13
13
  class DsfParser extends AbstractID3Parser_1.AbstractID3Parser {
14
- async _parse() {
14
+ async postId3v2Parse() {
15
15
  const p0 = this.tokenizer.position; // mark start position, normally 0
16
16
  const chunkHeader = await this.tokenizer.readToken(DsfChunk_1.ChunkHeader);
17
17
  if (chunkHeader.id !== 'DSD ')
@@ -1,6 +1,6 @@
1
+ import { ITokenizer } from 'strtok3/lib/core';
1
2
  import { AbstractID3Parser } from '../id3v2/AbstractID3Parser';
2
3
  import { INativeMetadataCollector } from '../common/MetadataCollector';
3
- import { ITokenizer } from 'strtok3/lib/core';
4
4
  import { IOptions } from '../type';
5
5
  import { ITokenParser } from '../ParserFactory';
6
6
  export declare class FlacParser extends AbstractID3Parser {
@@ -13,7 +13,7 @@ export declare class FlacParser extends AbstractID3Parser {
13
13
  * @param {IOptions} options Parsing options
14
14
  */
15
15
  init(metadata: INativeMetadataCollector, tokenizer: ITokenizer, options: IOptions): ITokenParser;
16
- _parse(): Promise<void>;
16
+ postId3v2Parse(): Promise<void>;
17
17
  private parseDataBlock;
18
18
  /**
19
19
  * Parse STREAMINFO
@@ -1,15 +1,15 @@
1
- 'use strict';
1
+ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FlacParser = void 0;
4
+ const token_types_1 = require("token-types");
5
+ const initDebug = require("debug");
4
6
  const util = require("../common/Util");
5
- const Token = require("token-types");
6
7
  const Vorbis_1 = require("../ogg/vorbis/Vorbis");
7
8
  const AbstractID3Parser_1 = require("../id3v2/AbstractID3Parser");
8
9
  const FourCC_1 = require("../common/FourCC");
9
- const _debug = require("debug");
10
10
  const VorbisParser_1 = require("../ogg/vorbis/VorbisParser");
11
11
  const VorbisDecoder_1 = require("../ogg/vorbis/VorbisDecoder");
12
- const debug = _debug('music-metadata:parser:FLAC');
12
+ const debug = initDebug('music-metadata:parser:FLAC');
13
13
  /**
14
14
  * FLAC supports up to 128 kinds of metadata blocks; currently the following are defined:
15
15
  * ref: https://xiph.org/flac/format.html#metadata_block
@@ -40,7 +40,7 @@ class FlacParser extends AbstractID3Parser_1.AbstractID3Parser {
40
40
  this.vorbisParser = new VorbisParser_1.VorbisParser(metadata, options);
41
41
  return this;
42
42
  }
43
- async _parse() {
43
+ async postId3v2Parse() {
44
44
  const fourCC = await this.tokenizer.readToken(FourCC_1.FourCcToken);
45
45
  if (fourCC.toString() !== 'fLaC') {
46
46
  throw new Error('Invalid FLAC preamble');
@@ -103,7 +103,7 @@ class FlacParser extends AbstractID3Parser_1.AbstractID3Parser {
103
103
  * Ref: https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-640004.2.3
104
104
  */
105
105
  async parseComment(dataLen) {
106
- const data = await this.tokenizer.readToken(new Token.Uint8ArrayType(dataLen));
106
+ const data = await this.tokenizer.readToken(new token_types_1.Uint8ArrayType(dataLen));
107
107
  const decoder = new VorbisDecoder_1.VorbisDecoder(data, 0);
108
108
  decoder.readStringUtf8(); // vendor (skip)
109
109
  const commentListLength = decoder.readInt32();
@@ -131,7 +131,7 @@ Metadata.BlockHeader = {
131
131
  return {
132
132
  lastBlock: util.getBit(buf, off, 7),
133
133
  type: util.getBitAllignedNumber(buf, off, 1, 7),
134
- length: Token.UINT24_BE.get(buf, off + 1)
134
+ length: token_types_1.UINT24_BE.get(buf, off + 1)
135
135
  };
136
136
  }
137
137
  };
@@ -144,20 +144,20 @@ Metadata.BlockStreamInfo = {
144
144
  get: (buf, off) => {
145
145
  return {
146
146
  // The minimum block size (in samples) used in the stream.
147
- minimumBlockSize: Token.UINT16_BE.get(buf, off),
147
+ minimumBlockSize: token_types_1.UINT16_BE.get(buf, off),
148
148
  // The maximum block size (in samples) used in the stream.
149
149
  // (Minimum blocksize == maximum blocksize) implies a fixed-blocksize stream.
150
- maximumBlockSize: Token.UINT16_BE.get(buf, off + 2) / 1000,
150
+ maximumBlockSize: token_types_1.UINT16_BE.get(buf, off + 2) / 1000,
151
151
  // The minimum frame size (in bytes) used in the stream.
152
152
  // May be 0 to imply the value is not known.
153
- minimumFrameSize: Token.UINT24_BE.get(buf, off + 4),
153
+ minimumFrameSize: token_types_1.UINT24_BE.get(buf, off + 4),
154
154
  // The maximum frame size (in bytes) used in the stream.
155
155
  // May be 0 to imply the value is not known.
156
- maximumFrameSize: Token.UINT24_BE.get(buf, off + 7),
156
+ maximumFrameSize: token_types_1.UINT24_BE.get(buf, off + 7),
157
157
  // Sample rate in Hz. Though 20 bits are available,
158
158
  // the maximum sample rate is limited by the structure of frame headers to 655350Hz.
159
159
  // Also, a value of 0 is invalid.
160
- sampleRate: Token.UINT24_BE.get(buf, off + 10) >> 4,
160
+ sampleRate: token_types_1.UINT24_BE.get(buf, off + 10) >> 4,
161
161
  // probably slower: sampleRate: common.getBitAllignedNumber(buf, off + 10, 0, 20),
162
162
  // (number of channels)-1. FLAC supports from 1 to 8 channels
163
163
  channels: util.getBitAllignedNumber(buf, off + 12, 4, 3) + 1,
@@ -169,7 +169,7 @@ Metadata.BlockStreamInfo = {
169
169
  // A value of zero here means the number of total samples is unknown.
170
170
  totalSamples: util.getBitAllignedNumber(buf, off + 13, 4, 36),
171
171
  // the MD5 hash of the file (see notes for usage... it's a littly tricky)
172
- fileMD5: new Token.Uint8ArrayType(16).get(buf, off + 18)
172
+ fileMD5: new token_types_1.Uint8ArrayType(16).get(buf, off + 18)
173
173
  };
174
174
  }
175
175
  };
@@ -2,8 +2,8 @@
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 token_types_1 = require("token-types");
5
6
  const util = require("../common/Util");
6
- const Token = require("token-types");
7
7
  const BasicParser_1 = require("../common/BasicParser");
8
8
  const APEv2Parser_1 = require("../apev2/APEv2Parser");
9
9
  const debug = initDebug('music-metadata:parser:ID3v1');
@@ -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
- "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"
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 === "TAG" ? {
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: Token.UINT8.get(buf, off + 127),
65
+ zeroByte: token_types_1.UINT8.get(buf, off + 127),
66
66
  // track: ID3v1.1 field added by Michael Mutschler
67
- track: Token.UINT8.get(buf, off + 126),
68
- genre: Token.UINT8.get(buf, off + 127)
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 Token.StringType {
72
+ class Id3v1StringType extends token_types_1.StringType {
73
73
  constructor(len) {
74
- super(len, "binary");
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("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] !== "")
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("ID3v1 header not found at: pos=%s", this.tokenizer.fileInfo.size - Iid3v1Token.len);
118
+ debug('ID3v1 header not found at: pos=%s', this.tokenizer.fileInfo.size - Iid3v1Token.len);
119
119
  }
120
120
  }
121
121
  addTag(id, value) {
@@ -1,4 +1,4 @@
1
- import { CommonTagMapper } from "../common/GenericTagMapper";
1
+ import { CommonTagMapper } from '../common/GenericTagMapper';
2
2
  export declare class ID3v1TagMapper extends CommonTagMapper {
3
3
  constructor();
4
4
  }
@@ -20,3 +20,4 @@ class ID3v1TagMapper extends GenericTagMapper_1.CommonTagMapper {
20
20
  }
21
21
  }
22
22
  exports.ID3v1TagMapper = ID3v1TagMapper;
23
+ //# sourceMappingURL=ID3v1TagMap.js.map
@@ -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 _parse(): Promise<void>;
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 initDebug = require("debug");
5
6
  const ID3v2Token_1 = require("./ID3v2Token");
6
7
  const ID3v2Parser_1 = require("./ID3v2Parser");
7
8
  const ID3v1Parser_1 = require("../id3v1/ID3v1Parser");
8
- const _debug = require("debug");
9
9
  const BasicParser_1 = require("../common/BasicParser");
10
- const debug = _debug('music-metadata:parser:ID3');
10
+ const debug = initDebug('music-metadata:parser:ID3');
11
11
  /**
12
12
  * Abstract parser which tries take ID3v2 and ID3v1 headers.
13
13
  */
@@ -37,8 +37,8 @@ class AbstractID3Parser extends BasicParser_1.BasicParser {
37
37
  }
38
38
  async parseID3v2() {
39
39
  await this.tryReadId3v2Headers();
40
- debug("End of ID3v2 header, go to MPEG-parser: pos=%s", this.tokenizer.position);
41
- await this._parse();
40
+ debug('End of ID3v2 header, go to MPEG-parser: pos=%s', this.tokenizer.position);
41
+ await this.postId3v2Parse();
42
42
  if (this.options.skipPostHeaders && this.metadata.hasAny()) {
43
43
  this.finalize();
44
44
  }
@@ -50,8 +50,8 @@ class AbstractID3Parser extends BasicParser_1.BasicParser {
50
50
  }
51
51
  async tryReadId3v2Headers() {
52
52
  const id3Header = await this.tokenizer.peekToken(ID3v2Token_1.ID3v2Header);
53
- if (id3Header.fileIdentifier === "ID3") {
54
- debug("Found ID3v2 header, pos=%s", this.tokenizer.position);
53
+ if (id3Header.fileIdentifier === 'ID3') {
54
+ debug('Found ID3v2 header, pos=%s', this.tokenizer.position);
55
55
  await this.id3parser.parse(this.metadata, this.tokenizer, this.options);
56
56
  return this.tryReadId3v2Headers();
57
57
  }
@@ -88,7 +88,13 @@ class FrameParser {
88
88
  case 'MVNM':
89
89
  case 'PCS':
90
90
  case 'PCST':
91
- const text = util.decodeString(b.slice(1), encoding).replace(/\x00+$/, '');
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
@@ -44,7 +44,8 @@ exports.id3v22TagMap = {
44
44
  TSC: 'composersort',
45
45
  TSP: 'artistsort',
46
46
  TST: 'titlesort',
47
- WFD: 'podcasturl'
47
+ WFD: 'podcasturl',
48
+ TBP: 'bpm'
48
49
  };
49
50
  class ID3v22TagMapper extends CaseInsensitiveTagMap_1.CaseInsensitiveTagMap {
50
51
  constructor() {
@@ -52,3 +53,4 @@ class ID3v22TagMapper extends CaseInsensitiveTagMap_1.CaseInsensitiveTagMap {
52
53
  }
53
54
  }
54
55
  exports.ID3v22TagMapper = ID3v22TagMapper;
56
+ //# sourceMappingURL=ID3v22TagMapper.js.map
@@ -1,13 +1,13 @@
1
- import { IRating, ITag } from '../type';
2
1
  import { INativeMetadataCollector } from '../common/MetadataCollector';
3
2
  import { CaseInsensitiveTagMap } from '../common/CaseInsensitiveTagMap';
3
+ import { IRating, ITag } from '../type';
4
4
  export declare class ID3v24TagMapper extends CaseInsensitiveTagMap {
5
5
  static toRating(popm: any): IRating;
6
6
  constructor();
7
7
  /**
8
8
  * Handle post mapping exceptions / correction
9
- * @param {string} tag to post map
10
- * @param warnings USed to register 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;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ID3v24TagMapper = void 0;
4
4
  const GenericTagMapper_1 = require("../common/GenericTagMapper");
5
- const util = require("../common/Util");
6
5
  const CaseInsensitiveTagMap_1 = require("../common/CaseInsensitiveTagMap");
6
+ const util = require("../common/Util");
7
7
  /**
8
8
  * ID3v2.3/ID3v2.4 tag mappings
9
9
  */
@@ -152,8 +152,8 @@ class ID3v24TagMapper extends CaseInsensitiveTagMap_1.CaseInsensitiveTagMap {
152
152
  }
153
153
  /**
154
154
  * Handle post mapping exceptions / correction
155
- * @param {string} tag to post map
156
- * @param warnings USed to register 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) {
@@ -191,3 +191,4 @@ class ID3v24TagMapper extends CaseInsensitiveTagMap_1.CaseInsensitiveTagMap {
191
191
  }
192
192
  }
193
193
  exports.ID3v24TagMapper = ID3v24TagMapper;
194
+ //# sourceMappingURL=ID3v24TagMapper.js.map
@@ -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 {string} tag e.g.: COM
13
- * @param {string} description e.g. iTunPGAP
14
- * @returns {string} e.g. COM:iTunPGAP
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;
@@ -68,9 +68,9 @@ class ID3v2Parser {
68
68
  }
69
69
  /**
70
70
  * Create a combined tag key, of tag & description
71
- * @param {string} tag e.g.: COM
72
- * @param {string} description e.g. iTunPGAP
73
- * @returns {string} e.g. COM:iTunPGAP
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
- if (id3Header.flags.isExtendedHeader) {
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
- if (dataRemaining > 0) {
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);
@@ -1,5 +1,5 @@
1
- import * as util from '../common/Util';
2
1
  import { IGetToken } from 'strtok3/lib/core';
2
+ import * as util from '../common/Util';
3
3
  /**
4
4
  * The picture type according to the ID3v2 APIC frame
5
5
  * Ref: http://id3.org/id3v2.3.0#Attached_picture
@@ -1,11 +1,11 @@
1
- import { IGetToken } from "strtok3/lib/core";
1
+ import { IGetToken } from 'strtok3/lib/core';
2
2
  /**
3
3
  * "EA IFF 85" Standard for Interchange Format Files
4
4
  * Ref: http://www.martinreddy.net/gfx/2d/IFF.txt
5
5
  */
6
6
  export interface IChunkHeader {
7
7
  /**
8
- * A chunk ID (ie, 4 ASCII bytes)
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
- * A chunk ID (ie, 4 ASCII bytes)
22
+ * A chunk ID (ie, 4 ASCII bytes)
23
23
  */
24
24
  chunkID: string;
25
25
  /**
package/lib/iff/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Header = void 0;
4
- const FourCC_1 = require("../common/FourCC");
5
4
  const Token = require("token-types");
5
+ const FourCC_1 = require("../common/FourCC");
6
6
  /**
7
7
  * Common AIFF chunk header
8
8
  */
package/lib/index.d.ts CHANGED
@@ -32,3 +32,14 @@ export declare const orderTags: typeof Core.orderTags;
32
32
  * @returns Number of stars: 1, 2, 3, 4 or 5 stars
33
33
  */
34
34
  export declare const ratingToStars: typeof Core.ratingToStars;
35
+ declare const _default: {
36
+ parseStream: typeof parseStream;
37
+ parseFile: typeof parseFile;
38
+ parseFromTokenizer: typeof Core.parseFromTokenizer;
39
+ parseBuffer: typeof Core.parseBuffer;
40
+ selectCover: typeof Core.selectCover;
41
+ };
42
+ /**
43
+ * Define default module exports
44
+ */
45
+ export default _default;
package/lib/index.js CHANGED
@@ -62,3 +62,13 @@ exports.orderTags = Core.orderTags;
62
62
  * @returns Number of stars: 1, 2, 3, 4 or 5 stars
63
63
  */
64
64
  exports.ratingToStars = Core.ratingToStars;
65
+ /**
66
+ * Define default module exports
67
+ */
68
+ exports.default = {
69
+ parseStream,
70
+ parseFile,
71
+ parseFromTokenizer: Core.parseFromTokenizer,
72
+ parseBuffer: Core.parseBuffer,
73
+ selectCover: Core.selectCover
74
+ };
@@ -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
- * https://www.matroska.org/technical/specs/index.html
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
- * https://www.matroska.org/technical/specs/index.html
9
+ * - https://www.matroska.org/technical/specs/index.html
10
10
  */
11
11
  exports.elements = {
12
12
  0x1a45dfa3: {
@@ -1,5 +1,5 @@
1
- import { INativeMetadataCollector } from '../common/MetadataCollector';
2
1
  import { ITokenizer } from 'strtok3/lib/core';
2
+ import { INativeMetadataCollector } from '../common/MetadataCollector';
3
3
  import { IOptions } from '../type';
4
4
  import { ITokenParser } from '../ParserFactory';
5
5
  import { BasicParser } from '../common/BasicParser';
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MatroskaParser = void 0;
4
- const Token = require("token-types");
5
- const _debug = require("debug");
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 = _debug('music-metadata:parser:matroska');
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(Token.UINT8);
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(Token.Float32_BE);
205
+ return this.tokenizer.readNumber(token_types_1.Float32_BE);
206
206
  case 8:
207
- return this.tokenizer.readNumber(Token.Float64_BE);
207
+ return this.tokenizer.readNumber(token_types_1.Float64_BE);
208
208
  case 10:
209
- return this.tokenizer.readNumber(Token.Float64_BE);
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 Token.StringType(e.len, 'utf-8'));
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) {
@@ -33,3 +33,4 @@ class MatroskaTagMapper extends CaseInsensitiveTagMap_1.CaseInsensitiveTagMap {
33
33
  }
34
34
  }
35
35
  exports.MatroskaTagMapper = MatroskaTagMapper;
36
+ //# sourceMappingURL=MatroskaTagMapper.js.map