music-metadata 7.11.3 → 7.11.7

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 (152) hide show
  1. package/README.md +432 -432
  2. package/lib/ParserFactory.d.ts +49 -49
  3. package/lib/ParserFactory.js +251 -251
  4. package/lib/aiff/AiffParser.d.ts +15 -15
  5. package/lib/aiff/AiffParser.js +85 -85
  6. package/lib/aiff/AiffToken.d.ts +22 -22
  7. package/lib/aiff/AiffToken.js +43 -43
  8. package/lib/apev2/APEv2Parser.d.ts +30 -30
  9. package/lib/apev2/APEv2Parser.js +162 -162
  10. package/lib/apev2/APEv2TagMapper.d.ts +4 -4
  11. package/lib/apev2/APEv2TagMapper.js +87 -86
  12. package/lib/apev2/APEv2Token.d.ts +100 -100
  13. package/lib/apev2/APEv2Token.js +127 -126
  14. package/lib/asf/AsfObject.d.ts +319 -319
  15. package/lib/asf/AsfObject.js +384 -384
  16. package/lib/asf/AsfParser.d.ts +17 -17
  17. package/lib/asf/AsfParser.js +135 -135
  18. package/lib/asf/AsfTagMapper.d.ts +7 -7
  19. package/lib/asf/AsfTagMapper.js +96 -95
  20. package/lib/asf/AsfUtil.d.ts +13 -13
  21. package/lib/asf/AsfUtil.js +40 -40
  22. package/lib/asf/GUID.d.ts +86 -86
  23. package/lib/asf/GUID.js +123 -123
  24. package/lib/common/BasicParser.d.ts +17 -17
  25. package/lib/common/BasicParser.js +18 -18
  26. package/lib/common/CaseInsensitiveTagMap.d.ts +10 -10
  27. package/lib/common/CaseInsensitiveTagMap.js +22 -21
  28. package/lib/common/CombinedTagMapper.d.ts +19 -19
  29. package/lib/common/CombinedTagMapper.js +52 -51
  30. package/lib/common/FourCC.d.ts +6 -6
  31. package/lib/common/FourCC.js +29 -28
  32. package/lib/common/GenericTagMapper.d.ts +51 -51
  33. package/lib/common/GenericTagMapper.js +56 -55
  34. package/lib/common/GenericTagTypes.d.ts +33 -33
  35. package/lib/common/GenericTagTypes.js +132 -131
  36. package/lib/common/MetadataCollector.d.ts +76 -76
  37. package/lib/common/MetadataCollector.js +276 -274
  38. package/lib/common/RandomFileReader.d.ts +20 -20
  39. package/lib/common/RandomFileReader.js +37 -37
  40. package/lib/common/RandomUint8ArrayReader.d.ts +18 -18
  41. package/lib/common/RandomUint8ArrayReader.js +25 -25
  42. package/lib/common/Util.d.ts +58 -57
  43. package/lib/common/Util.js +163 -169
  44. package/lib/core.d.ts +48 -48
  45. package/lib/core.js +90 -90
  46. package/lib/dsdiff/DsdiffParser.d.ts +14 -14
  47. package/lib/dsdiff/DsdiffParser.js +143 -143
  48. package/lib/dsdiff/DsdiffToken.d.ts +9 -9
  49. package/lib/dsdiff/DsdiffToken.js +21 -21
  50. package/lib/dsf/DsfChunk.d.ts +86 -86
  51. package/lib/dsf/DsfChunk.js +54 -54
  52. package/lib/dsf/DsfParser.d.ts +9 -9
  53. package/lib/dsf/DsfParser.js +56 -56
  54. package/lib/flac/FlacParser.d.ts +28 -28
  55. package/lib/flac/FlacParser.js +175 -175
  56. package/lib/id3v1/ID3v1Parser.d.ts +13 -13
  57. package/lib/id3v1/ID3v1Parser.js +134 -134
  58. package/lib/id3v1/ID3v1TagMap.d.ts +4 -4
  59. package/lib/id3v1/ID3v1TagMap.js +23 -22
  60. package/lib/id3v2/AbstractID3Parser.d.ts +17 -17
  61. package/lib/id3v2/AbstractID3Parser.js +60 -60
  62. package/lib/id3v2/FrameParser.d.ts +32 -32
  63. package/lib/id3v2/FrameParser.js +329 -323
  64. package/lib/id3v2/ID3v22TagMapper.d.ts +9 -9
  65. package/lib/id3v2/ID3v22TagMapper.js +56 -54
  66. package/lib/id3v2/ID3v24TagMapper.d.ts +14 -14
  67. package/lib/id3v2/ID3v24TagMapper.js +194 -193
  68. package/lib/id3v2/ID3v2Parser.d.ts +29 -29
  69. package/lib/id3v2/ID3v2Parser.js +194 -194
  70. package/lib/id3v2/ID3v2Token.d.ts +73 -73
  71. package/lib/id3v2/ID3v2Token.js +106 -106
  72. package/lib/iff/index.d.ts +33 -33
  73. package/lib/iff/index.js +19 -19
  74. package/lib/index.d.ts +45 -34
  75. package/lib/index.js +74 -64
  76. package/lib/lyrics3/Lyrics3.d.ts +3 -3
  77. package/lib/lyrics3/Lyrics3.js +17 -17
  78. package/lib/matroska/MatroskaDtd.d.ts +8 -8
  79. package/lib/matroska/MatroskaDtd.js +279 -279
  80. package/lib/matroska/MatroskaParser.d.ts +37 -37
  81. package/lib/matroska/MatroskaParser.js +235 -234
  82. package/lib/matroska/MatroskaTagMapper.d.ts +4 -4
  83. package/lib/matroska/MatroskaTagMapper.js +36 -35
  84. package/lib/matroska/types.d.ts +175 -175
  85. package/lib/matroska/types.js +32 -32
  86. package/lib/mp4/Atom.d.ts +16 -16
  87. package/lib/mp4/Atom.js +70 -70
  88. package/lib/mp4/AtomToken.d.ts +395 -395
  89. package/lib/mp4/AtomToken.js +406 -406
  90. package/lib/mp4/MP4Parser.d.ts +30 -30
  91. package/lib/mp4/MP4Parser.js +511 -511
  92. package/lib/mp4/MP4TagMapper.d.ts +5 -5
  93. package/lib/mp4/MP4TagMapper.js +116 -115
  94. package/lib/mpeg/ExtendedLameHeader.d.ts +27 -27
  95. package/lib/mpeg/ExtendedLameHeader.js +31 -31
  96. package/lib/mpeg/MpegParser.d.ts +49 -49
  97. package/lib/mpeg/MpegParser.js +529 -529
  98. package/lib/mpeg/ReplayGainDataFormat.d.ts +55 -55
  99. package/lib/mpeg/ReplayGainDataFormat.js +69 -69
  100. package/lib/mpeg/XingTag.d.ts +45 -45
  101. package/lib/mpeg/XingTag.js +69 -69
  102. package/lib/musepack/index.d.ts +5 -5
  103. package/lib/musepack/index.js +32 -32
  104. package/lib/musepack/sv7/BitReader.d.ts +13 -13
  105. package/lib/musepack/sv7/BitReader.js +54 -54
  106. package/lib/musepack/sv7/MpcSv7Parser.d.ts +8 -8
  107. package/lib/musepack/sv7/MpcSv7Parser.js +46 -46
  108. package/lib/musepack/sv7/StreamVersion7.d.ts +28 -28
  109. package/lib/musepack/sv7/StreamVersion7.js +41 -41
  110. package/lib/musepack/sv8/MpcSv8Parser.d.ts +6 -6
  111. package/lib/musepack/sv8/MpcSv8Parser.js +55 -55
  112. package/lib/musepack/sv8/StreamVersion8.d.ts +40 -40
  113. package/lib/musepack/sv8/StreamVersion8.js +80 -80
  114. package/lib/ogg/Ogg.d.ts +72 -72
  115. package/lib/ogg/Ogg.js +2 -2
  116. package/lib/ogg/OggParser.d.ts +23 -23
  117. package/lib/ogg/OggParser.js +126 -126
  118. package/lib/ogg/opus/Opus.d.ts +48 -48
  119. package/lib/ogg/opus/Opus.js +28 -28
  120. package/lib/ogg/opus/OpusParser.d.ts +25 -25
  121. package/lib/ogg/opus/OpusParser.js +56 -56
  122. package/lib/ogg/speex/Speex.d.ts +36 -36
  123. package/lib/ogg/speex/Speex.js +31 -31
  124. package/lib/ogg/speex/SpeexParser.d.ts +22 -22
  125. package/lib/ogg/speex/SpeexParser.js +35 -35
  126. package/lib/ogg/theora/Theora.d.ts +20 -20
  127. package/lib/ogg/theora/Theora.js +23 -23
  128. package/lib/ogg/theora/TheoraParser.d.ts +28 -28
  129. package/lib/ogg/theora/TheoraParser.js +44 -44
  130. package/lib/ogg/vorbis/Vorbis.d.ts +79 -79
  131. package/lib/ogg/vorbis/Vorbis.js +78 -78
  132. package/lib/ogg/vorbis/VorbisDecoder.d.ts +12 -12
  133. package/lib/ogg/vorbis/VorbisDecoder.js +32 -32
  134. package/lib/ogg/vorbis/VorbisParser.d.ts +36 -36
  135. package/lib/ogg/vorbis/VorbisParser.js +128 -128
  136. package/lib/ogg/vorbis/VorbisTagMapper.d.ts +7 -7
  137. package/lib/ogg/vorbis/VorbisTagMapper.js +133 -132
  138. package/lib/riff/RiffChunk.d.ts +16 -16
  139. package/lib/riff/RiffChunk.js +32 -32
  140. package/lib/riff/RiffInfoTagMap.d.ts +10 -10
  141. package/lib/riff/RiffInfoTagMap.js +38 -37
  142. package/lib/type.d.ts +599 -599
  143. package/lib/type.js +14 -13
  144. package/lib/wav/WaveChunk.d.ts +64 -64
  145. package/lib/wav/WaveChunk.js +65 -65
  146. package/lib/wav/WaveParser.d.ts +24 -24
  147. package/lib/wav/WaveParser.js +144 -144
  148. package/lib/wavpack/WavPackParser.d.ts +14 -14
  149. package/lib/wavpack/WavPackParser.js +105 -105
  150. package/lib/wavpack/WavPackToken.d.ts +64 -64
  151. package/lib/wavpack/WavPackToken.js +76 -76
  152. package/package.json +142 -142
@@ -1,106 +1,106 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TextEncodingToken = exports.ExtendedHeader = exports.ID3v2Header = exports.UINT32SYNCSAFE = exports.AttachedPictureType = void 0;
4
- const Token = require("token-types");
5
- const util = require("../common/Util");
6
- /**
7
- * The picture type according to the ID3v2 APIC frame
8
- * Ref: http://id3.org/id3v2.3.0#Attached_picture
9
- */
10
- var AttachedPictureType;
11
- (function (AttachedPictureType) {
12
- AttachedPictureType[AttachedPictureType["Other"] = 0] = "Other";
13
- AttachedPictureType[AttachedPictureType["32x32 pixels 'file icon' (PNG only)"] = 1] = "32x32 pixels 'file icon' (PNG only)";
14
- AttachedPictureType[AttachedPictureType["Other file icon"] = 2] = "Other file icon";
15
- AttachedPictureType[AttachedPictureType["Cover (front)"] = 3] = "Cover (front)";
16
- AttachedPictureType[AttachedPictureType["Cover (back)"] = 4] = "Cover (back)";
17
- AttachedPictureType[AttachedPictureType["Leaflet page"] = 5] = "Leaflet page";
18
- AttachedPictureType[AttachedPictureType["Media (e.g. label side of CD)"] = 6] = "Media (e.g. label side of CD)";
19
- AttachedPictureType[AttachedPictureType["Lead artist/lead performer/soloist"] = 7] = "Lead artist/lead performer/soloist";
20
- AttachedPictureType[AttachedPictureType["Artist/performer"] = 8] = "Artist/performer";
21
- AttachedPictureType[AttachedPictureType["Conductor"] = 9] = "Conductor";
22
- AttachedPictureType[AttachedPictureType["Band/Orchestra"] = 10] = "Band/Orchestra";
23
- AttachedPictureType[AttachedPictureType["Composer"] = 11] = "Composer";
24
- AttachedPictureType[AttachedPictureType["Lyricist/text writer"] = 12] = "Lyricist/text writer";
25
- AttachedPictureType[AttachedPictureType["Recording Location"] = 13] = "Recording Location";
26
- AttachedPictureType[AttachedPictureType["During recording"] = 14] = "During recording";
27
- AttachedPictureType[AttachedPictureType["During performance"] = 15] = "During performance";
28
- AttachedPictureType[AttachedPictureType["Movie/video screen capture"] = 16] = "Movie/video screen capture";
29
- AttachedPictureType[AttachedPictureType["A bright coloured fish"] = 17] = "A bright coloured fish";
30
- AttachedPictureType[AttachedPictureType["Illustration"] = 18] = "Illustration";
31
- AttachedPictureType[AttachedPictureType["Band/artist logotype"] = 19] = "Band/artist logotype";
32
- AttachedPictureType[AttachedPictureType["Publisher/Studio logotype"] = 20] = "Publisher/Studio logotype";
33
- })(AttachedPictureType = exports.AttachedPictureType || (exports.AttachedPictureType = {}));
34
- /**
35
- * 28 bits (representing up to 256MB) integer, the msb is 0 to avoid 'false syncsignals'.
36
- * 4 * %0xxxxxxx
37
- */
38
- exports.UINT32SYNCSAFE = {
39
- get: (buf, off) => {
40
- return buf[off + 3] & 0x7f | ((buf[off + 2]) << 7) |
41
- ((buf[off + 1]) << 14) | ((buf[off]) << 21);
42
- },
43
- len: 4
44
- };
45
- /**
46
- * ID3v2 header
47
- * Ref: http://id3.org/id3v2.3.0#ID3v2_header
48
- * ToDo
49
- */
50
- exports.ID3v2Header = {
51
- len: 10,
52
- get: (buf, off) => {
53
- return {
54
- // ID3v2/file identifier "ID3"
55
- fileIdentifier: new Token.StringType(3, 'ascii').get(buf, off),
56
- // ID3v2 versionIndex
57
- version: {
58
- major: Token.INT8.get(buf, off + 3),
59
- revision: Token.INT8.get(buf, off + 4)
60
- },
61
- // ID3v2 flags
62
- flags: {
63
- // Unsynchronisation
64
- unsynchronisation: util.getBit(buf, off + 5, 7),
65
- // Extended header
66
- isExtendedHeader: util.getBit(buf, off + 5, 6),
67
- // Experimental indicator
68
- expIndicator: util.getBit(buf, off + 5, 5),
69
- footer: util.getBit(buf, off + 5, 4)
70
- },
71
- size: exports.UINT32SYNCSAFE.get(buf, off + 6)
72
- };
73
- }
74
- };
75
- exports.ExtendedHeader = {
76
- len: 10,
77
- get: (buf, off) => {
78
- return {
79
- // Extended header size
80
- size: Token.UINT32_BE.get(buf, off),
81
- // Extended Flags
82
- extendedFlags: Token.UINT16_BE.get(buf, off + 4),
83
- // Size of padding
84
- sizeOfPadding: Token.UINT32_BE.get(buf, off + 6),
85
- // CRC data present
86
- crcDataPresent: util.getBit(buf, off + 4, 31)
87
- };
88
- }
89
- };
90
- exports.TextEncodingToken = {
91
- len: 1,
92
- get: (buf, off) => {
93
- switch (buf.readUInt8(off)) {
94
- case 0x00:
95
- return { encoding: 'latin1' }; // binary
96
- case 0x01:
97
- return { encoding: 'utf16le', bom: true };
98
- case 0x02:
99
- return { encoding: 'utf16le', bom: false };
100
- case 0x03:
101
- return { encoding: 'utf8', bom: false };
102
- default:
103
- return { encoding: 'utf8', bom: false };
104
- }
105
- }
106
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextEncodingToken = exports.ExtendedHeader = exports.ID3v2Header = exports.UINT32SYNCSAFE = exports.AttachedPictureType = void 0;
4
+ const Token = require("token-types");
5
+ const util = require("../common/Util");
6
+ /**
7
+ * The picture type according to the ID3v2 APIC frame
8
+ * Ref: http://id3.org/id3v2.3.0#Attached_picture
9
+ */
10
+ var AttachedPictureType;
11
+ (function (AttachedPictureType) {
12
+ AttachedPictureType[AttachedPictureType["Other"] = 0] = "Other";
13
+ AttachedPictureType[AttachedPictureType["32x32 pixels 'file icon' (PNG only)"] = 1] = "32x32 pixels 'file icon' (PNG only)";
14
+ AttachedPictureType[AttachedPictureType["Other file icon"] = 2] = "Other file icon";
15
+ AttachedPictureType[AttachedPictureType["Cover (front)"] = 3] = "Cover (front)";
16
+ AttachedPictureType[AttachedPictureType["Cover (back)"] = 4] = "Cover (back)";
17
+ AttachedPictureType[AttachedPictureType["Leaflet page"] = 5] = "Leaflet page";
18
+ AttachedPictureType[AttachedPictureType["Media (e.g. label side of CD)"] = 6] = "Media (e.g. label side of CD)";
19
+ AttachedPictureType[AttachedPictureType["Lead artist/lead performer/soloist"] = 7] = "Lead artist/lead performer/soloist";
20
+ AttachedPictureType[AttachedPictureType["Artist/performer"] = 8] = "Artist/performer";
21
+ AttachedPictureType[AttachedPictureType["Conductor"] = 9] = "Conductor";
22
+ AttachedPictureType[AttachedPictureType["Band/Orchestra"] = 10] = "Band/Orchestra";
23
+ AttachedPictureType[AttachedPictureType["Composer"] = 11] = "Composer";
24
+ AttachedPictureType[AttachedPictureType["Lyricist/text writer"] = 12] = "Lyricist/text writer";
25
+ AttachedPictureType[AttachedPictureType["Recording Location"] = 13] = "Recording Location";
26
+ AttachedPictureType[AttachedPictureType["During recording"] = 14] = "During recording";
27
+ AttachedPictureType[AttachedPictureType["During performance"] = 15] = "During performance";
28
+ AttachedPictureType[AttachedPictureType["Movie/video screen capture"] = 16] = "Movie/video screen capture";
29
+ AttachedPictureType[AttachedPictureType["A bright coloured fish"] = 17] = "A bright coloured fish";
30
+ AttachedPictureType[AttachedPictureType["Illustration"] = 18] = "Illustration";
31
+ AttachedPictureType[AttachedPictureType["Band/artist logotype"] = 19] = "Band/artist logotype";
32
+ AttachedPictureType[AttachedPictureType["Publisher/Studio logotype"] = 20] = "Publisher/Studio logotype";
33
+ })(AttachedPictureType = exports.AttachedPictureType || (exports.AttachedPictureType = {}));
34
+ /**
35
+ * 28 bits (representing up to 256MB) integer, the msb is 0 to avoid 'false syncsignals'.
36
+ * 4 * %0xxxxxxx
37
+ */
38
+ exports.UINT32SYNCSAFE = {
39
+ get: (buf, off) => {
40
+ return buf[off + 3] & 0x7f | ((buf[off + 2]) << 7) |
41
+ ((buf[off + 1]) << 14) | ((buf[off]) << 21);
42
+ },
43
+ len: 4
44
+ };
45
+ /**
46
+ * ID3v2 header
47
+ * Ref: http://id3.org/id3v2.3.0#ID3v2_header
48
+ * ToDo
49
+ */
50
+ exports.ID3v2Header = {
51
+ len: 10,
52
+ get: (buf, off) => {
53
+ return {
54
+ // ID3v2/file identifier "ID3"
55
+ fileIdentifier: new Token.StringType(3, 'ascii').get(buf, off),
56
+ // ID3v2 versionIndex
57
+ version: {
58
+ major: Token.INT8.get(buf, off + 3),
59
+ revision: Token.INT8.get(buf, off + 4)
60
+ },
61
+ // ID3v2 flags
62
+ flags: {
63
+ // Unsynchronisation
64
+ unsynchronisation: util.getBit(buf, off + 5, 7),
65
+ // Extended header
66
+ isExtendedHeader: util.getBit(buf, off + 5, 6),
67
+ // Experimental indicator
68
+ expIndicator: util.getBit(buf, off + 5, 5),
69
+ footer: util.getBit(buf, off + 5, 4)
70
+ },
71
+ size: exports.UINT32SYNCSAFE.get(buf, off + 6)
72
+ };
73
+ }
74
+ };
75
+ exports.ExtendedHeader = {
76
+ len: 10,
77
+ get: (buf, off) => {
78
+ return {
79
+ // Extended header size
80
+ size: Token.UINT32_BE.get(buf, off),
81
+ // Extended Flags
82
+ extendedFlags: Token.UINT16_BE.get(buf, off + 4),
83
+ // Size of padding
84
+ sizeOfPadding: Token.UINT32_BE.get(buf, off + 6),
85
+ // CRC data present
86
+ crcDataPresent: util.getBit(buf, off + 4, 31)
87
+ };
88
+ }
89
+ };
90
+ exports.TextEncodingToken = {
91
+ len: 1,
92
+ get: (buf, off) => {
93
+ switch (buf.readUInt8(off)) {
94
+ case 0x00:
95
+ return { encoding: 'latin1' }; // binary
96
+ case 0x01:
97
+ return { encoding: 'utf16le', bom: true };
98
+ case 0x02:
99
+ return { encoding: 'utf16le', bom: false };
100
+ case 0x03:
101
+ return { encoding: 'utf8', bom: false };
102
+ default:
103
+ return { encoding: 'utf8', bom: false };
104
+ }
105
+ }
106
+ };
@@ -1,33 +1,33 @@
1
- import { IGetToken } from "strtok3/lib/core";
2
- /**
3
- * "EA IFF 85" Standard for Interchange Format Files
4
- * Ref: http://www.martinreddy.net/gfx/2d/IFF.txt
5
- */
6
- export interface IChunkHeader {
7
- /**
8
- * A chunk ID (ie, 4 ASCII bytes)
9
- */
10
- chunkID: string;
11
- /**
12
- * Number of data bytes following this data header
13
- */
14
- chunkSize: number;
15
- }
16
- /**
17
- * "EA IFF 85" Standard for Interchange Format Files
18
- * Ref: http://www.martinreddy.net/gfx/2d/IFF.txt
19
- */
20
- export interface IChunkHeader64 {
21
- /**
22
- * A chunk ID (ie, 4 ASCII bytes)
23
- */
24
- chunkID: string;
25
- /**
26
- * Number of data bytes following this data header
27
- */
28
- chunkSize: bigint;
29
- }
30
- /**
31
- * Common AIFF chunk header
32
- */
33
- export declare const Header: IGetToken<IChunkHeader>;
1
+ import { IGetToken } from 'strtok3/lib/core';
2
+ /**
3
+ * "EA IFF 85" Standard for Interchange Format Files
4
+ * Ref: http://www.martinreddy.net/gfx/2d/IFF.txt
5
+ */
6
+ export interface IChunkHeader {
7
+ /**
8
+ * A chunk ID (ie, 4 ASCII bytes)
9
+ */
10
+ chunkID: string;
11
+ /**
12
+ * Number of data bytes following this data header
13
+ */
14
+ chunkSize: number;
15
+ }
16
+ /**
17
+ * "EA IFF 85" Standard for Interchange Format Files
18
+ * Ref: http://www.martinreddy.net/gfx/2d/IFF.txt
19
+ */
20
+ export interface IChunkHeader64 {
21
+ /**
22
+ * A chunk ID (ie, 4 ASCII bytes)
23
+ */
24
+ chunkID: string;
25
+ /**
26
+ * Number of data bytes following this data header
27
+ */
28
+ chunkSize: bigint;
29
+ }
30
+ /**
31
+ * Common AIFF chunk header
32
+ */
33
+ export declare const Header: IGetToken<IChunkHeader>;
package/lib/iff/index.js CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Header = void 0;
4
- const FourCC_1 = require("../common/FourCC");
5
- const Token = require("token-types");
6
- /**
7
- * Common AIFF chunk header
8
- */
9
- exports.Header = {
10
- len: 8,
11
- get: (buf, off) => {
12
- return {
13
- // Chunk type ID
14
- chunkID: FourCC_1.FourCcToken.get(buf, off),
15
- // Chunk size
16
- chunkSize: Number(BigInt(Token.UINT32_BE.get(buf, off + 4)))
17
- };
18
- }
19
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Header = void 0;
4
+ const Token = require("token-types");
5
+ const FourCC_1 = require("../common/FourCC");
6
+ /**
7
+ * Common AIFF chunk header
8
+ */
9
+ exports.Header = {
10
+ len: 8,
11
+ get: (buf, off) => {
12
+ return {
13
+ // Chunk type ID
14
+ chunkID: FourCC_1.FourCcToken.get(buf, off),
15
+ // Chunk size
16
+ chunkSize: Number(BigInt(Token.UINT32_BE.get(buf, off + 4)))
17
+ };
18
+ }
19
+ };
package/lib/index.d.ts CHANGED
@@ -1,34 +1,45 @@
1
- /// <reference types="node" />
2
- import * as Stream from 'stream';
3
- import * as strtok3 from 'strtok3';
4
- import * as Core from './core';
5
- import { IAudioMetadata, IOptions } from './type';
6
- export { IAudioMetadata, IOptions, ITag, INativeTagDict, ICommonTagsResult, IFormat, IPicture, IRatio, IChapter } from './type';
7
- export { parseFromTokenizer, parseBuffer, IFileInfo, selectCover } from './core';
8
- /**
9
- * Parse audio from Node Stream.Readable
10
- * @param stream - Stream to read the audio track from
11
- * @param fileInfo - File information object or MIME-type, e.g.: 'audio/mpeg'
12
- * @param options - Parsing options
13
- * @returns Metadata
14
- */
15
- export declare function parseStream(stream: Stream.Readable, fileInfo?: strtok3.IFileInfo | string, options?: IOptions): Promise<IAudioMetadata>;
16
- /**
17
- * Parse audio from Node file
18
- * @param filePath - Media file to read meta-data from
19
- * @param options - Parsing options
20
- * @returns Metadata
21
- */
22
- export declare function parseFile(filePath: string, options?: IOptions): Promise<IAudioMetadata>;
23
- /**
24
- * Create a dictionary ordered by their tag id (key)
25
- * @param nativeTags - List of tags
26
- * @returns Tags indexed by id
27
- */
28
- export declare const orderTags: typeof Core.orderTags;
29
- /**
30
- * Convert rating to 1-5 star rating
31
- * @param rating - Normalized rating [0..1] (common.rating[n].rating)
32
- * @returns Number of stars: 1, 2, 3, 4 or 5 stars
33
- */
34
- export declare const ratingToStars: typeof Core.ratingToStars;
1
+ /// <reference types="node" />
2
+ import * as Stream from 'stream';
3
+ import * as strtok3 from 'strtok3';
4
+ import * as Core from './core';
5
+ import { IAudioMetadata, IOptions } from './type';
6
+ export { IAudioMetadata, IOptions, ITag, INativeTagDict, ICommonTagsResult, IFormat, IPicture, IRatio, IChapter } from './type';
7
+ export { parseFromTokenizer, parseBuffer, IFileInfo, selectCover } from './core';
8
+ /**
9
+ * Parse audio from Node Stream.Readable
10
+ * @param stream - Stream to read the audio track from
11
+ * @param fileInfo - File information object or MIME-type, e.g.: 'audio/mpeg'
12
+ * @param options - Parsing options
13
+ * @returns Metadata
14
+ */
15
+ export declare function parseStream(stream: Stream.Readable, fileInfo?: strtok3.IFileInfo | string, options?: IOptions): Promise<IAudioMetadata>;
16
+ /**
17
+ * Parse audio from Node file
18
+ * @param filePath - Media file to read meta-data from
19
+ * @param options - Parsing options
20
+ * @returns Metadata
21
+ */
22
+ export declare function parseFile(filePath: string, options?: IOptions): Promise<IAudioMetadata>;
23
+ /**
24
+ * Create a dictionary ordered by their tag id (key)
25
+ * @param nativeTags - List of tags
26
+ * @returns Tags indexed by id
27
+ */
28
+ export declare const orderTags: typeof Core.orderTags;
29
+ /**
30
+ * Convert rating to 1-5 star rating
31
+ * @param rating - Normalized rating [0..1] (common.rating[n].rating)
32
+ * @returns Number of stars: 1, 2, 3, 4 or 5 stars
33
+ */
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
@@ -1,64 +1,74 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ratingToStars = exports.orderTags = exports.parseFile = exports.parseStream = exports.selectCover = exports.parseBuffer = exports.parseFromTokenizer = void 0;
4
- const strtok3 = require("strtok3");
5
- const Core = require("./core");
6
- const ParserFactory_1 = require("./ParserFactory");
7
- const _debug = require("debug");
8
- const RandomFileReader_1 = require("./common/RandomFileReader");
9
- const debug = _debug("music-metadata:parser");
10
- var core_1 = require("./core");
11
- Object.defineProperty(exports, "parseFromTokenizer", { enumerable: true, get: function () { return core_1.parseFromTokenizer; } });
12
- Object.defineProperty(exports, "parseBuffer", { enumerable: true, get: function () { return core_1.parseBuffer; } });
13
- Object.defineProperty(exports, "selectCover", { enumerable: true, get: function () { return core_1.selectCover; } });
14
- /**
15
- * Parse audio from Node Stream.Readable
16
- * @param stream - Stream to read the audio track from
17
- * @param fileInfo - File information object or MIME-type, e.g.: 'audio/mpeg'
18
- * @param options - Parsing options
19
- * @returns Metadata
20
- */
21
- async function parseStream(stream, fileInfo, options = {}) {
22
- const tokenizer = await strtok3.fromStream(stream, typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo);
23
- return Core.parseFromTokenizer(tokenizer, options);
24
- }
25
- exports.parseStream = parseStream;
26
- /**
27
- * Parse audio from Node file
28
- * @param filePath - Media file to read meta-data from
29
- * @param options - Parsing options
30
- * @returns Metadata
31
- */
32
- async function parseFile(filePath, options = {}) {
33
- debug(`parseFile: ${filePath}`);
34
- const fileTokenizer = await strtok3.fromFile(filePath);
35
- const fileReader = new RandomFileReader_1.RandomFileReader(filePath, fileTokenizer.fileInfo.size);
36
- try {
37
- await Core.scanAppendingHeaders(fileReader, options);
38
- }
39
- finally {
40
- fileReader.close();
41
- }
42
- try {
43
- const parserName = ParserFactory_1.ParserFactory.getParserIdForExtension(filePath);
44
- if (!parserName)
45
- debug(' Parser could not be determined by file extension');
46
- return await ParserFactory_1.ParserFactory.parse(fileTokenizer, parserName, options);
47
- }
48
- finally {
49
- await fileTokenizer.close();
50
- }
51
- }
52
- exports.parseFile = parseFile;
53
- /**
54
- * Create a dictionary ordered by their tag id (key)
55
- * @param nativeTags - List of tags
56
- * @returns Tags indexed by id
57
- */
58
- exports.orderTags = Core.orderTags;
59
- /**
60
- * Convert rating to 1-5 star rating
61
- * @param rating - Normalized rating [0..1] (common.rating[n].rating)
62
- * @returns Number of stars: 1, 2, 3, 4 or 5 stars
63
- */
64
- exports.ratingToStars = Core.ratingToStars;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ratingToStars = exports.orderTags = exports.parseFile = exports.parseStream = exports.selectCover = exports.parseBuffer = exports.parseFromTokenizer = void 0;
4
+ const strtok3 = require("strtok3");
5
+ const Core = require("./core");
6
+ const ParserFactory_1 = require("./ParserFactory");
7
+ const _debug = require("debug");
8
+ const RandomFileReader_1 = require("./common/RandomFileReader");
9
+ const debug = _debug("music-metadata:parser");
10
+ var core_1 = require("./core");
11
+ Object.defineProperty(exports, "parseFromTokenizer", { enumerable: true, get: function () { return core_1.parseFromTokenizer; } });
12
+ Object.defineProperty(exports, "parseBuffer", { enumerable: true, get: function () { return core_1.parseBuffer; } });
13
+ Object.defineProperty(exports, "selectCover", { enumerable: true, get: function () { return core_1.selectCover; } });
14
+ /**
15
+ * Parse audio from Node Stream.Readable
16
+ * @param stream - Stream to read the audio track from
17
+ * @param fileInfo - File information object or MIME-type, e.g.: 'audio/mpeg'
18
+ * @param options - Parsing options
19
+ * @returns Metadata
20
+ */
21
+ async function parseStream(stream, fileInfo, options = {}) {
22
+ const tokenizer = await strtok3.fromStream(stream, typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo);
23
+ return Core.parseFromTokenizer(tokenizer, options);
24
+ }
25
+ exports.parseStream = parseStream;
26
+ /**
27
+ * Parse audio from Node file
28
+ * @param filePath - Media file to read meta-data from
29
+ * @param options - Parsing options
30
+ * @returns Metadata
31
+ */
32
+ async function parseFile(filePath, options = {}) {
33
+ debug(`parseFile: ${filePath}`);
34
+ const fileTokenizer = await strtok3.fromFile(filePath);
35
+ const fileReader = new RandomFileReader_1.RandomFileReader(filePath, fileTokenizer.fileInfo.size);
36
+ try {
37
+ await Core.scanAppendingHeaders(fileReader, options);
38
+ }
39
+ finally {
40
+ fileReader.close();
41
+ }
42
+ try {
43
+ const parserName = ParserFactory_1.ParserFactory.getParserIdForExtension(filePath);
44
+ if (!parserName)
45
+ debug(' Parser could not be determined by file extension');
46
+ return await ParserFactory_1.ParserFactory.parse(fileTokenizer, parserName, options);
47
+ }
48
+ finally {
49
+ await fileTokenizer.close();
50
+ }
51
+ }
52
+ exports.parseFile = parseFile;
53
+ /**
54
+ * Create a dictionary ordered by their tag id (key)
55
+ * @param nativeTags - List of tags
56
+ * @returns Tags indexed by id
57
+ */
58
+ exports.orderTags = Core.orderTags;
59
+ /**
60
+ * Convert rating to 1-5 star rating
61
+ * @param rating - Normalized rating [0..1] (common.rating[n].rating)
62
+ * @returns Number of stars: 1, 2, 3, 4 or 5 stars
63
+ */
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
+ };
@@ -1,3 +1,3 @@
1
- import { IRandomReader } from '../type';
2
- export declare const endTag2 = "LYRICS200";
3
- export declare function getLyricsHeaderLength(reader: IRandomReader): Promise<number>;
1
+ import { IRandomReader } from '../type';
2
+ export declare const endTag2 = "LYRICS200";
3
+ export declare function getLyricsHeaderLength(reader: IRandomReader): Promise<number>;
@@ -1,17 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLyricsHeaderLength = exports.endTag2 = void 0;
4
- exports.endTag2 = 'LYRICS200';
5
- async function getLyricsHeaderLength(reader) {
6
- if (reader.fileSize >= 143) {
7
- const buf = Buffer.alloc(15);
8
- await reader.randomRead(buf, 0, buf.length, reader.fileSize - 143);
9
- const txt = buf.toString('binary');
10
- const tag = txt.substr(6);
11
- if (tag === exports.endTag2) {
12
- return parseInt(txt.substr(0, 6), 10) + 15;
13
- }
14
- }
15
- return 0;
16
- }
17
- exports.getLyricsHeaderLength = getLyricsHeaderLength;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLyricsHeaderLength = exports.endTag2 = void 0;
4
+ exports.endTag2 = 'LYRICS200';
5
+ async function getLyricsHeaderLength(reader) {
6
+ if (reader.fileSize >= 143) {
7
+ const buf = Buffer.alloc(15);
8
+ await reader.randomRead(buf, 0, buf.length, reader.fileSize - 143);
9
+ const txt = buf.toString('binary');
10
+ const tag = txt.substr(6);
11
+ if (tag === exports.endTag2) {
12
+ return parseInt(txt.substr(0, 6), 10) + 15;
13
+ }
14
+ }
15
+ return 0;
16
+ }
17
+ exports.getLyricsHeaderLength = getLyricsHeaderLength;
@@ -1,8 +1,8 @@
1
- import { IContainerType } from './types';
2
- /**
3
- * Elements of document type description
4
- * Derived from https://github.com/tungol/EBML/blob/master/doctypes/matroska.dtd
5
- * Extended with:
6
- * https://www.matroska.org/technical/specs/index.html
7
- */
8
- export declare const elements: IContainerType;
1
+ import { IContainerType } from './types';
2
+ /**
3
+ * Elements of document type description
4
+ * Derived from https://github.com/tungol/EBML/blob/master/doctypes/matroska.dtd
5
+ * Extended with:
6
+ * https://www.matroska.org/technical/specs/index.html
7
+ */
8
+ export declare const elements: IContainerType;