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
package/README.md CHANGED
@@ -70,9 +70,10 @@ Support for encoding / format details:
70
70
 
71
71
 
72
72
  ## Online demo's
73
- * [<img src="https://gitcdn.xyz/repo/Borewit/audio-tag-analyzer/master/src/assets/icon/audio-tag-analyzer.svg" width="40">Audio Tag Analyzer](https://audio-tag-analyzer.netlify.com/)
73
+ * [<img src="https://raw.githubusercontent.com/Borewit/audio-tag-analyzer/master/src/assets/icon/audio-tag-analyzer.svg" width="40">Audio Tag Analyzer](https://audio-tag-analyzer.netlify.com/)
74
74
  * [<img src="https://cdn.sanity.io/images/3do82whm/next/ba8c847f13a5fa39d88f8bc9b7846b7886531b18-2500x2500.svg" width="40"> Webamp](https://webamp.org/)
75
75
 
76
+
76
77
  ## Compatibility
77
78
 
78
79
  The JavaScript in runtime is compliant with [ECMAScript 2017 (ES8)](https://en.wikipedia.org/wiki/ECMAScript#8th_Edition_-_ECMAScript_2017).
@@ -39,7 +39,6 @@ export declare class ParserFactory {
39
39
  */
40
40
  static getParserIdForExtension(filePath: string): ParserType;
41
41
  static loadParser(moduleName: ParserType): Promise<ITokenParser>;
42
- private static _parse;
43
42
  private static getExtension;
44
43
  /**
45
44
  * @param httpContentType - HTTP Content-Type, extension, path or filename
@@ -31,6 +31,13 @@ function parseHttpContentType(contentType) {
31
31
  };
32
32
  }
33
33
  exports.parseHttpContentType = parseHttpContentType;
34
+ async function parse(tokenizer, parserId, opts = {}) {
35
+ // Parser found, execute parser
36
+ const parser = await ParserFactory.loadParser(parserId);
37
+ const metadata = new MetadataCollector_1.MetadataCollector(opts);
38
+ await parser.init(metadata, tokenizer, opts).parse();
39
+ return metadata.toCommonMetadata();
40
+ }
34
41
  class ParserFactory {
35
42
  /**
36
43
  * Parse metadata from tokenizer
@@ -69,7 +76,7 @@ class ParserFactory {
69
76
  }
70
77
  }
71
78
  // Parser found, execute parser
72
- return this._parse(tokenizer, parserId, opts);
79
+ return parse(tokenizer, parserId, opts);
73
80
  }
74
81
  /**
75
82
  * @param filePath - Path, filename or extension to audio file
@@ -153,13 +160,6 @@ class ParserFactory {
153
160
  throw new Error(`Unknown parser type: ${moduleName}`);
154
161
  }
155
162
  }
156
- static async _parse(tokenizer, parserId, opts = {}) {
157
- // Parser found, execute parser
158
- const parser = await ParserFactory.loadParser(parserId);
159
- const metadata = new MetadataCollector_1.MetadataCollector(opts);
160
- await parser.init(metadata, tokenizer, opts).parse();
161
- return metadata.toCommonMetadata();
162
- }
163
163
  static getExtension(fname) {
164
164
  const i = fname.lastIndexOf('.');
165
165
  return i === -1 ? '' : fname.slice(i);
@@ -4,9 +4,8 @@ import * as iff from '../iff';
4
4
  * AIFF - Audio Interchange File Format
5
5
  *
6
6
  * Ref:
7
- * http://www.onicos.com/staff/iz/formats/aiff.html
8
- * http://muratnkonar.com/aiff/index.html
9
- * http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/AIFF.html
7
+ * - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/AIFF.html
8
+ * - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/Docs/AIFF-1.3.pdf
10
9
  */
11
10
  export declare class AIFFParser extends BasicParser {
12
11
  private isCompressed;
@@ -14,9 +14,8 @@ const debug = initDebug('music-metadata:parser:aiff');
14
14
  * AIFF - Audio Interchange File Format
15
15
  *
16
16
  * Ref:
17
- * http://www.onicos.com/staff/iz/formats/aiff.html
18
- * http://muratnkonar.com/aiff/index.html
19
- * http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/AIFF.html
17
+ * - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/AIFF.html
18
+ * - http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/AIFF/Docs/AIFF-1.3.pdf
20
19
  */
21
20
  class AIFFParser extends BasicParser_1.BasicParser {
22
21
  async parse() {
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
+ import { IGetToken } from 'strtok3';
2
3
  import * as iff from '../iff';
3
- import { IGetToken } from "strtok3";
4
4
  /**
5
5
  * The Common Chunk.
6
6
  * Describes fundamental parameters of the waveform data such as sample rate, bit resolution, and how many channels of
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.APEv2Parser = void 0;
4
4
  const initDebug = require("debug");
5
5
  const strtok3 = require("strtok3/lib/core");
6
+ const token_types_1 = require("token-types");
6
7
  const util = require("../common/Util");
7
8
  const BasicParser_1 = require("../common/BasicParser");
8
9
  const APEv2Token_1 = require("./APEv2Token");
9
- const token_types_1 = require("token-types");
10
10
  const debug = initDebug('music-metadata:parser:APEv2');
11
11
  const tagFormat = 'APEv2';
12
12
  const preamble = 'APETAGEX';
@@ -106,10 +106,9 @@ class APEv2Parser extends BasicParser_1.BasicParser {
106
106
  await this.tokenizer.ignore(1);
107
107
  bytesRemaining -= key.length + 1;
108
108
  switch (tagItemHeader.flags.dataType) {
109
- case APEv2Token_1.DataType.text_utf8: { // utf-8 textstring
109
+ case APEv2Token_1.DataType.text_utf8: { // utf-8 text-string
110
110
  const value = await this.tokenizer.readToken(new token_types_1.StringType(tagItemHeader.size, 'utf8'));
111
111
  const values = value.split(/\x00/g);
112
- /*jshint loopfunc:true */
113
112
  for (const val of values) {
114
113
  this.metadata.addTag(tagFormat, key, val);
115
114
  }
@@ -84,3 +84,4 @@ class APEv2TagMapper extends CaseInsensitiveTagMap_1.CaseInsensitiveTagMap {
84
84
  }
85
85
  }
86
86
  exports.APEv2TagMapper = APEv2TagMapper;
87
+ //# sourceMappingURL=APEv2TagMapper.js.map
@@ -3,12 +3,12 @@ import { IGetToken } from 'strtok3/lib/core';
3
3
  /**
4
4
  * APETag versionIndex history / supported formats
5
5
  *
6
- * 1.0 (1000) - Original APE tag spec. Fully supported by this code.
7
- * 2.0 (2000) - Refined APE tag spec (better streaming support, UTF StringEncoding). Fully supported by this code.
6
+ * 1.0 (1000) - Original APE tag spec. Fully supported by this code.
7
+ * 2.0 (2000) - Refined APE tag spec (better streaming support, UTF StringEncoding). Fully supported by this code.
8
8
  *
9
- * Notes:
10
- * - also supports reading of ID3v1.1 tags
11
- * - all saving done in the APE Tag format using CURRENT_APE_TAG_VERSION
9
+ * Notes:
10
+ * - also supports reading of ID3v1.1 tags
11
+ * - all saving done in the APE Tag format using CURRENT_APE_TAG_VERSION
12
12
  *
13
13
  * APE File Format Overview: (pieces in order -- only valid for the latest versionIndex APE files)
14
14
  *
@@ -124,3 +124,4 @@ function isBitSet(num, bit) {
124
124
  return (num & 1 << bit) !== 0;
125
125
  }
126
126
  exports.isBitSet = isBitSet;
127
+ //# sourceMappingURL=APEv2Token.js.map
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
+ import { IGetToken, ITokenizer } from 'strtok3/lib/core';
2
3
  import { IPicture, ITag } from '../type';
3
4
  import GUID from './GUID';
4
- import { IGetToken, ITokenizer } from 'strtok3/lib/core';
5
5
  /**
6
6
  * Data Type: Specifies the type of information being stored. The following values are recognized.
7
7
  */
@@ -1,13 +1,13 @@
1
1
  import { BasicParser } from '../common/BasicParser';
2
2
  /**
3
3
  * Windows Media Metadata Usage Guidelines
4
- * Ref: https://msdn.microsoft.com/en-us/library/ms867702.aspx
4
+ * - Ref: https://msdn.microsoft.com/en-us/library/ms867702.aspx
5
5
  *
6
6
  * Ref:
7
- * https://tools.ietf.org/html/draft-fleischman-asf-01
8
- * https://hwiegman.home.xs4all.nl/fileformats/asf/ASF_Specification.pdf
9
- * http://drang.s4.xrea.com/program/tips/id3tag/wmp/index.html
10
- * https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575(v=vs.85).aspx
7
+ * - https://tools.ietf.org/html/draft-fleischman-asf-01
8
+ * - https://hwiegman.home.xs4all.nl/fileformats/asf/ASF_Specification.pdf
9
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/index.html
10
+ * - https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575(v=vs.85).aspx
11
11
  */
12
12
  export declare class AsfParser extends BasicParser {
13
13
  parse(): Promise<void>;
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AsfParser = void 0;
4
+ const initDebug = require("debug");
4
5
  const type_1 = require("../type");
5
6
  const GUID_1 = require("./GUID");
6
7
  const AsfObject = require("./AsfObject");
7
- const _debug = require("debug");
8
8
  const BasicParser_1 = require("../common/BasicParser");
9
- const debug = _debug('music-metadata:parser:ASF');
9
+ const debug = initDebug('music-metadata:parser:ASF');
10
10
  const headerType = 'asf';
11
11
  /**
12
12
  * Windows Media Metadata Usage Guidelines
13
- * Ref: https://msdn.microsoft.com/en-us/library/ms867702.aspx
13
+ * - Ref: https://msdn.microsoft.com/en-us/library/ms867702.aspx
14
14
  *
15
15
  * Ref:
16
- * https://tools.ietf.org/html/draft-fleischman-asf-01
17
- * https://hwiegman.home.xs4all.nl/fileformats/asf/ASF_Specification.pdf
18
- * http://drang.s4.xrea.com/program/tips/id3tag/wmp/index.html
19
- * https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575(v=vs.85).aspx
16
+ * - https://tools.ietf.org/html/draft-fleischman-asf-01
17
+ * - https://hwiegman.home.xs4all.nl/fileformats/asf/ASF_Specification.pdf
18
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/index.html
19
+ * - https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575(v=vs.85).aspx
20
20
  */
21
21
  class AsfParser extends BasicParser_1.BasicParser {
22
22
  async parse() {
@@ -93,3 +93,4 @@ class AsfTagMapper extends GenericTagMapper_1.CommonTagMapper {
93
93
  }
94
94
  }
95
95
  exports.AsfTagMapper = AsfTagMapper;
96
+ //# sourceMappingURL=AsfTagMapper.js.map
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { DataType } from "./AsfObject";
2
+ import { DataType } from './AsfObject';
3
3
  export declare type AttributeParser = (buf: Buffer) => boolean | string | number | bigint | Buffer;
4
4
  export declare class AsfUtil {
5
5
  static getParserForAttr(i: DataType): AttributeParser;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AsfUtil = void 0;
4
- const util = require("../common/Util");
5
4
  const Token = require("token-types");
5
+ const util = require("../common/Util");
6
6
  class AsfUtil {
7
7
  static getParserForAttr(i) {
8
8
  return AsfUtil.attributeParsers[i];
package/lib/asf/GUID.d.ts CHANGED
@@ -1,19 +1,17 @@
1
1
  /// <reference types="node" />
2
2
  /**
3
3
  * Ref:
4
- * https://tools.ietf.org/html/draft-fleischman-asf-01, Appendix A: ASF GUIDs
5
- * http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
6
- * http://drang.s4.xrea.com/program/tips/id3tag/wmp/index.html
4
+ * - https://tools.ietf.org/html/draft-fleischman-asf-01, Appendix A: ASF GUIDs
5
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
6
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/index.html
7
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
7
8
  *
8
- * http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
9
+ * ASF File Structure:
10
+ * - https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575(v=vs.85).aspx
9
11
  *
10
- * ASF File Structure:
11
- * https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575(v=vs.85).aspx
12
- *
13
- * ASF GUIDs:
14
- * http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
15
- *
16
- * https://github.com/dji-sdk/FFmpeg/blob/master/libavformat/asf.c
12
+ * ASF GUIDs:
13
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
14
+ * - https://github.com/dji-sdk/FFmpeg/blob/master/libavformat/asf.c
17
15
  */
18
16
  export default class GUID {
19
17
  str: string;
@@ -65,19 +63,19 @@ export default class GUID {
65
63
  * Decode GUID in format like "B503BF5F-2EA9-CF11-8EE3-00C00C205365"
66
64
  * @param objectId Binary GUID
67
65
  * @param offset Read offset in bytes, default 0
68
- * @returns {string} GUID as dashed hexadecimal representation
66
+ * @returns GUID as dashed hexadecimal representation
69
67
  */
70
68
  static decode(objectId: Buffer, offset?: number): string;
71
69
  /**
72
70
  * Decode stream type
73
- * @param {string} mediaType
74
- * @returns {string}
71
+ * @param mediaType Media type GUID
72
+ * @returns Media type
75
73
  */
76
- static decodeMediaType(mediaType: GUID): string;
74
+ static decodeMediaType(mediaType: GUID): 'audio' | 'video' | 'command' | 'degradable-jpeg' | 'file-transfer' | 'binary' | undefined;
77
75
  /**
78
76
  * Encode GUID
79
77
  * @param guid GUID like: "B503BF5F-2EA9-CF11-8EE3-00C00C205365"
80
- * @returns {Buffer} Encoded Bnary GUID
78
+ * @returns Encoded Binary GUID
81
79
  */
82
80
  static encode(str: string): Buffer;
83
81
  constructor(str: string);
package/lib/asf/GUID.js CHANGED
@@ -2,19 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /**
4
4
  * Ref:
5
- * https://tools.ietf.org/html/draft-fleischman-asf-01, Appendix A: ASF GUIDs
6
- * http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
7
- * http://drang.s4.xrea.com/program/tips/id3tag/wmp/index.html
5
+ * - https://tools.ietf.org/html/draft-fleischman-asf-01, Appendix A: ASF GUIDs
6
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
7
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/index.html
8
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
8
9
  *
9
- * http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
10
+ * ASF File Structure:
11
+ * - https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575(v=vs.85).aspx
10
12
  *
11
- * ASF File Structure:
12
- * https://msdn.microsoft.com/en-us/library/windows/desktop/ee663575(v=vs.85).aspx
13
- *
14
- * ASF GUIDs:
15
- * http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
16
- *
17
- * https://github.com/dji-sdk/FFmpeg/blob/master/libavformat/asf.c
13
+ * ASF GUIDs:
14
+ * - http://drang.s4.xrea.com/program/tips/id3tag/wmp/10_asf_guids.html
15
+ * - https://github.com/dji-sdk/FFmpeg/blob/master/libavformat/asf.c
18
16
  */
19
17
  class GUID {
20
18
  constructor(str) {
@@ -27,7 +25,7 @@ class GUID {
27
25
  * Decode GUID in format like "B503BF5F-2EA9-CF11-8EE3-00C00C205365"
28
26
  * @param objectId Binary GUID
29
27
  * @param offset Read offset in bytes, default 0
30
- * @returns {string} GUID as dashed hexadecimal representation
28
+ * @returns GUID as dashed hexadecimal representation
31
29
  */
32
30
  static decode(objectId, offset = 0) {
33
31
  const guid = objectId.readUInt32LE(offset).toString(16) + "-" +
@@ -39,8 +37,8 @@ class GUID {
39
37
  }
40
38
  /**
41
39
  * Decode stream type
42
- * @param {string} mediaType
43
- * @returns {string}
40
+ * @param mediaType Media type GUID
41
+ * @returns Media type
44
42
  */
45
43
  static decodeMediaType(mediaType) {
46
44
  switch (mediaType.str) {
@@ -55,7 +53,7 @@ class GUID {
55
53
  /**
56
54
  * Encode GUID
57
55
  * @param guid GUID like: "B503BF5F-2EA9-CF11-8EE3-00C00C205365"
58
- * @returns {Buffer} Encoded Bnary GUID
56
+ * @returns Encoded Binary GUID
59
57
  */
60
58
  static encode(str) {
61
59
  const bin = Buffer.alloc(16);
@@ -19,3 +19,4 @@ class CaseInsensitiveTagMap extends GenericTagMapper_1.CommonTagMapper {
19
19
  }
20
20
  }
21
21
  exports.CaseInsensitiveTagMap = CaseInsensitiveTagMap;
22
+ //# sourceMappingURL=CaseInsensitiveTagMap.js.map
@@ -1,6 +1,6 @@
1
- import { IGenericTag, TagType } from "./GenericTagTypes";
2
- import { IGenericTagMapper } from "./GenericTagMapper";
3
- import { ITag } from "../type";
1
+ import { IGenericTag, TagType } from './GenericTagTypes';
2
+ import { IGenericTagMapper } from './GenericTagMapper';
3
+ import { ITag } from '../type';
4
4
  import { INativeMetadataCollector } from './MetadataCollector';
5
5
  export declare class CombinedTagMapper {
6
6
  tagMappers: {
@@ -40,7 +40,7 @@ class CombinedTagMapper {
40
40
  if (tagMapper) {
41
41
  return this.tagMappers[tagType].mapGenericTag(tag, warnings);
42
42
  }
43
- throw new Error("No generic tag mapper defined for tag-format: " + tagType);
43
+ throw new Error('No generic tag mapper defined for tag-format: ' + tagType);
44
44
  }
45
45
  registerTagMapper(genericTagMapper) {
46
46
  for (const tagType of genericTagMapper.tagTypes) {
@@ -49,3 +49,4 @@ class CombinedTagMapper {
49
49
  }
50
50
  }
51
51
  exports.CombinedTagMapper = CombinedTagMapper;
52
+ //# sourceMappingURL=CombinedTagMapper.js.map
@@ -1,4 +1,4 @@
1
- import { IToken } from "strtok3/lib/core";
1
+ import { IToken } from 'strtok3/lib/core';
2
2
  /**
3
3
  * Token for read FourCC
4
4
  * Ref: https://en.wikipedia.org/wiki/FourCC
@@ -22,7 +22,8 @@ exports.FourCcToken = {
22
22
  put: (buffer, offset, id) => {
23
23
  const str = Buffer.from(id, 'binary');
24
24
  if (str.length !== 4)
25
- throw new Error("Invalid length");
25
+ throw new Error('Invalid length');
26
26
  return str.copy(buffer, offset);
27
27
  }
28
28
  };
29
+ //# sourceMappingURL=FourCC.js.map
@@ -44,8 +44,8 @@ export declare class CommonTagMapper implements IGenericTagMapper {
44
44
  protected getCommonName(tag: string): generic.GenericTagId;
45
45
  /**
46
46
  * Handle post mapping exceptions / correction
47
- * @param {string} tag Tag e.g. {"©alb", "Buena Vista Social Club")
48
- * @param {warnings} Used to register warnings
47
+ * @param tag Tag e.g. {"©alb", "Buena Vista Social Club")
48
+ * @param warnings Used to register warnings
49
49
  */
50
50
  protected postMap(tag: ITag, warnings: IWarningCollector): void;
51
51
  }
@@ -44,8 +44,8 @@ class CommonTagMapper {
44
44
  }
45
45
  /**
46
46
  * Handle post mapping exceptions / correction
47
- * @param {string} tag Tag e.g. {"©alb", "Buena Vista Social Club")
48
- * @param {warnings} Used to register warnings
47
+ * @param tag Tag e.g. {"©alb", "Buena Vista Social Club")
48
+ * @param warnings Used to register warnings
49
49
  */
50
50
  postMap(tag, warnings) {
51
51
  return;
@@ -53,3 +53,4 @@ class CommonTagMapper {
53
53
  }
54
54
  exports.CommonTagMapper = CommonTagMapper;
55
55
  CommonTagMapper.maxRatingScore = 1;
56
+ //# sourceMappingURL=GenericTagMapper.js.map
@@ -129,3 +129,4 @@ function isUnique(alias) {
129
129
  return !exports.commonTags[alias].multiple || exports.commonTags[alias].unique;
130
130
  }
131
131
  exports.isUnique = isUnique;
132
+ //# sourceMappingURL=GenericTagTypes.js.map
@@ -21,9 +21,9 @@ export interface INativeMetadataCollector extends IWarningCollector {
21
21
  * @returns {boolean} true if one or more tags have been found
22
22
  */
23
23
  hasAny(): boolean;
24
- setFormat(key: FormatId, value: any): any;
25
- addTag(tagType: TagType, tagId: string, value: any): any;
26
- addStreamInfo(streamInfo: ITrackInfo): any;
24
+ setFormat(key: FormatId, value: any): void;
25
+ addTag(tagType: TagType, tagId: string, value: any): void;
26
+ addStreamInfo(streamInfo: ITrackInfo): void;
27
27
  }
28
28
  /**
29
29
  * Provided to the parser to uodate the metadata result.
@@ -61,7 +61,7 @@ export declare class MetadataCollector implements INativeMetadataCollector {
61
61
  toCommonMetadata(): IAudioMetadata;
62
62
  /**
63
63
  * Fix some common issues with picture object
64
- * @param pictureType
64
+ * @param picture Picture
65
65
  */
66
66
  private postFixPicture;
67
67
  /**
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.joinArtists = exports.MetadataCollector = void 0;
4
4
  const type_1 = require("../type");
5
- const _debug = require("debug");
5
+ const initDebug = require("debug");
6
6
  const GenericTagTypes_1 = require("./GenericTagTypes");
7
7
  const CombinedTagMapper_1 = require("./CombinedTagMapper");
8
8
  const GenericTagMapper_1 = require("./GenericTagMapper");
9
9
  const Util_1 = require("./Util");
10
10
  const FileType = require("file-type/core");
11
- const debug = _debug('music-metadata:collector');
11
+ const debug = initDebug('music-metadata:collector');
12
12
  const TagPriority = ['matroska', 'APEv2', 'vorbis', 'ID3v2.4', 'ID3v2.3', 'ID3v2.2', 'exif', 'asf', 'iTunes', 'ID3v1'];
13
13
  /**
14
14
  * Provided to the parser to uodate the metadata result.
@@ -126,6 +126,7 @@ class MetadataCollector {
126
126
  this.common[tag.id] = GenericTagMapper_1.CommonTagMapper.normalizeTrack(tag.value);
127
127
  this.common[tag.id].of = of != null ? of : this.common[tag.id].of;
128
128
  return;
129
+ case 'bpm':
129
130
  case 'year':
130
131
  case 'originalyear':
131
132
  tag.value = parseInt(tag.value, 10);
@@ -191,7 +192,7 @@ class MetadataCollector {
191
192
  }
192
193
  /**
193
194
  * Fix some common issues with picture object
194
- * @param pictureType
195
+ * @param picture Picture
195
196
  */
196
197
  async postFixPicture(picture) {
197
198
  if (picture.data && picture.data.length > 0) {
@@ -272,3 +273,4 @@ function joinArtists(artists) {
272
273
  return artists.join(' & ');
273
274
  }
274
275
  exports.joinArtists = joinArtists;
276
+ //# sourceMappingURL=MetadataCollector.js.map
@@ -1,6 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import { IRatio } from '../type';
3
3
  export declare type StringEncoding = 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64url' | 'latin1' | 'hex';
4
+ export interface ITextEncoding {
5
+ encoding: StringEncoding;
6
+ bom?: boolean;
7
+ }
4
8
  export declare function getBit(buf: Uint8Array, off: number, bit: number): boolean;
5
9
  /**
6
10
  * Found delimiting zero in uint8Array
@@ -13,10 +17,7 @@ export declare function getBit(buf: Uint8Array, off: number, bit: number): boole
13
17
  export declare function findZero(uint8Array: Uint8Array, start: number, end: number, encoding?: StringEncoding): number;
14
18
  export declare function trimRightNull(x: string): string;
15
19
  /**
16
- *
17
- * @param buffer Decoder input data
18
- * @param encoding 'utf16le' | 'utf16' | 'utf8' | 'iso-8859-1'
19
- * @return {string}
20
+ * Decode string
20
21
  */
21
22
  export declare function decodeString(buffer: Buffer, encoding: StringEncoding): string;
22
23
  export declare function stripNulls(str: string): string;
@@ -50,28 +50,21 @@ function swapBytes(uint8Array) {
50
50
  return uint8Array;
51
51
  }
52
52
  /**
53
- *
54
- * @param buffer Decoder input data
55
- * @param encoding 'utf16le' | 'utf16' | 'utf8' | 'iso-8859-1'
56
- * @return {string}
53
+ * Decode string
57
54
  */
58
55
  function decodeString(buffer, encoding) {
59
56
  // annoying workaround for a double BOM issue
60
57
  // https://github.com/leetreveil/musicmetadata/issues/84
61
- let offset = 0;
62
58
  if (buffer[0] === 0xFF && buffer[1] === 0xFE) { // little endian
63
- if (encoding === 'utf16le') {
64
- offset = 2;
65
- }
66
- else if (buffer[2] === 0xFE && buffer[3] === 0xFF) {
67
- offset = 2; // Clear double BOM
68
- }
59
+ return decodeString(buffer.subarray(2), encoding);
69
60
  }
70
61
  else if (encoding === 'utf16le' && buffer[0] === 0xFE && buffer[1] === 0xFF) {
71
62
  // BOM, indicating big endian decoding
63
+ if ((buffer.length & 1) !== 0)
64
+ throw new Error('Expected even number of octets for 16-bit unicode string');
72
65
  return decodeString(swapBytes(buffer), encoding);
73
66
  }
74
- return buffer.toString(encoding, offset);
67
+ return buffer.toString(encoding);
75
68
  }
76
69
  exports.decodeString = decodeString;
77
70
  function stripNulls(str) {
@@ -152,18 +145,14 @@ function toRatio(value) {
152
145
  // @ts-ignore
153
146
  if (ps.length >= 1) {
154
147
  const v = parseFloat(ps[0]);
155
- if (ps.length === 2 && ps[1] === 'db') {
156
- return {
157
- dB: v,
158
- ratio: dbToRatio(v)
159
- };
160
- }
161
- else {
162
- return {
163
- dB: ratioToDb(v),
164
- ratio: v
165
- };
166
- }
148
+ return ps.length === 2 && ps[1] === 'db' ? {
149
+ dB: v,
150
+ ratio: dbToRatio(v)
151
+ } : {
152
+ dB: ratioToDb(v),
153
+ ratio: v
154
+ };
167
155
  }
168
156
  }
169
157
  exports.toRatio = toRatio;
158
+ //# sourceMappingURL=Util.js.map
@@ -3,7 +3,7 @@ import { BasicParser } from '../common/BasicParser';
3
3
  * DSDIFF - Direct Stream Digital Interchange File Format (Phillips)
4
4
  *
5
5
  * Ref:
6
- * http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf
6
+ * - http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf
7
7
  */
8
8
  export declare class DsdiffParser extends BasicParser {
9
9
  parse(): Promise<void>;
@@ -3,17 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DsdiffParser = void 0;
4
4
  const Token = require("token-types");
5
5
  const initDebug = require("debug");
6
+ const strtok3 = require("strtok3/lib/core");
6
7
  const FourCC_1 = require("../common/FourCC");
7
8
  const BasicParser_1 = require("../common/BasicParser");
8
- const DsdiffToken_1 = require("./DsdiffToken");
9
- const strtok3 = require("strtok3/lib/core");
10
9
  const ID3v2Parser_1 = require("../id3v2/ID3v2Parser");
10
+ const DsdiffToken_1 = require("./DsdiffToken");
11
11
  const debug = initDebug('music-metadata:parser:aiff');
12
12
  /**
13
13
  * DSDIFF - Direct Stream Digital Interchange File Format (Phillips)
14
14
  *
15
15
  * Ref:
16
- * http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf
16
+ * - http://www.sonicstudio.com/pdf/dsd/DSDIFF_1.5_Spec.pdf
17
17
  */
18
18
  class DsdiffParser extends BasicParser_1.BasicParser {
19
19
  async parse() {
@@ -1,5 +1,5 @@
1
- import { IChunkHeader64 } from '../iff';
2
1
  import { IGetToken } from 'strtok3/lib/core';
2
+ import { IChunkHeader64 } from '../iff';
3
3
  export { IChunkHeader64 } from '../iff';
4
4
  /**
5
5
  * DSDIFF chunk header
@@ -4,6 +4,6 @@ import { AbstractID3Parser } from '../id3v2/AbstractID3Parser';
4
4
  * Ref: https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf
5
5
  */
6
6
  export declare class DsfParser extends AbstractID3Parser {
7
- _parse(): Promise<void>;
7
+ postId3v2Parse(): Promise<void>;
8
8
  private parseChunks;
9
9
  }