music-metadata 7.12.2 → 7.12.5

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 (155) hide show
  1. package/LICENSE.txt +9 -9
  2. package/README.md +434 -434
  3. package/lib/ParserFactory.d.ts +48 -48
  4. package/lib/ParserFactory.js +252 -252
  5. package/lib/aiff/AiffParser.d.ts +14 -14
  6. package/lib/aiff/AiffParser.js +84 -84
  7. package/lib/aiff/AiffToken.d.ts +22 -22
  8. package/lib/aiff/AiffToken.js +43 -43
  9. package/lib/apev2/APEv2Parser.d.ts +30 -30
  10. package/lib/apev2/APEv2Parser.js +164 -164
  11. package/lib/apev2/APEv2TagMapper.d.ts +4 -4
  12. package/lib/apev2/APEv2TagMapper.js +86 -86
  13. package/lib/apev2/APEv2Token.d.ts +100 -100
  14. package/lib/apev2/APEv2Token.js +126 -126
  15. package/lib/asf/AsfObject.d.ts +319 -319
  16. package/lib/asf/AsfObject.js +381 -381
  17. package/lib/asf/AsfParser.d.ts +17 -17
  18. package/lib/asf/AsfParser.js +135 -135
  19. package/lib/asf/AsfTagMapper.d.ts +7 -7
  20. package/lib/asf/AsfTagMapper.js +95 -95
  21. package/lib/asf/AsfUtil.d.ts +13 -13
  22. package/lib/asf/AsfUtil.js +38 -38
  23. package/lib/asf/GUID.d.ts +84 -84
  24. package/lib/asf/GUID.js +121 -121
  25. package/lib/common/BasicParser.d.ts +17 -17
  26. package/lib/common/BasicParser.js +18 -18
  27. package/lib/common/CaseInsensitiveTagMap.d.ts +10 -10
  28. package/lib/common/CaseInsensitiveTagMap.js +21 -21
  29. package/lib/common/CombinedTagMapper.d.ts +19 -19
  30. package/lib/common/CombinedTagMapper.js +51 -51
  31. package/lib/common/FourCC.d.ts +6 -6
  32. package/lib/common/FourCC.js +28 -28
  33. package/lib/common/GenericTagMapper.d.ts +51 -51
  34. package/lib/common/GenericTagMapper.js +55 -55
  35. package/lib/common/GenericTagTypes.d.ts +33 -33
  36. package/lib/common/GenericTagTypes.js +131 -131
  37. package/lib/common/MetadataCollector.d.ts +76 -76
  38. package/lib/common/MetadataCollector.js +275 -275
  39. package/lib/common/RandomFileReader.d.ts +22 -22
  40. package/lib/common/RandomFileReader.js +34 -34
  41. package/lib/common/RandomUint8ArrayReader.d.ts +18 -18
  42. package/lib/common/RandomUint8ArrayReader.js +25 -25
  43. package/lib/common/Util.d.ts +57 -57
  44. package/lib/common/Util.js +157 -157
  45. package/lib/core.d.ts +48 -48
  46. package/lib/core.js +90 -90
  47. package/lib/dsdiff/DsdiffParser.d.ts +14 -14
  48. package/lib/dsdiff/DsdiffParser.js +143 -143
  49. package/lib/dsdiff/DsdiffToken.d.ts +9 -9
  50. package/lib/dsdiff/DsdiffToken.js +21 -21
  51. package/lib/dsf/DsfChunk.d.ts +86 -86
  52. package/lib/dsf/DsfChunk.js +54 -54
  53. package/lib/dsf/DsfParser.d.ts +9 -9
  54. package/lib/dsf/DsfParser.js +56 -56
  55. package/lib/flac/FlacParser.d.ts +28 -28
  56. package/lib/flac/FlacParser.js +175 -175
  57. package/lib/id3v1/ID3v1Parser.d.ts +13 -13
  58. package/lib/id3v1/ID3v1Parser.js +134 -134
  59. package/lib/id3v1/ID3v1TagMap.d.ts +4 -4
  60. package/lib/id3v1/ID3v1TagMap.js +22 -22
  61. package/lib/id3v2/AbstractID3Parser.d.ts +17 -17
  62. package/lib/id3v2/AbstractID3Parser.js +60 -60
  63. package/lib/id3v2/FrameParser.d.ts +31 -31
  64. package/lib/id3v2/FrameParser.js +329 -329
  65. package/lib/id3v2/ID3v22TagMapper.d.ts +9 -9
  66. package/lib/id3v2/ID3v22TagMapper.js +55 -55
  67. package/lib/id3v2/ID3v24TagMapper.d.ts +14 -14
  68. package/lib/id3v2/ID3v24TagMapper.js +193 -193
  69. package/lib/id3v2/ID3v2Parser.d.ts +28 -28
  70. package/lib/id3v2/ID3v2Parser.js +182 -182
  71. package/lib/id3v2/ID3v2Token.d.ts +73 -73
  72. package/lib/id3v2/ID3v2Token.js +106 -106
  73. package/lib/iff/index.d.ts +33 -33
  74. package/lib/iff/index.js +19 -19
  75. package/lib/index.d.ts +45 -45
  76. package/lib/index.js +74 -74
  77. package/lib/lyrics3/Lyrics3.d.ts +3 -3
  78. package/lib/lyrics3/Lyrics3.js +17 -17
  79. package/lib/matroska/MatroskaDtd.d.ts +8 -8
  80. package/lib/matroska/MatroskaDtd.js +279 -279
  81. package/lib/matroska/MatroskaParser.d.ts +37 -37
  82. package/lib/matroska/MatroskaParser.js +235 -235
  83. package/lib/matroska/MatroskaTagMapper.d.ts +4 -4
  84. package/lib/matroska/MatroskaTagMapper.js +35 -35
  85. package/lib/matroska/types.d.ts +175 -175
  86. package/lib/matroska/types.js +32 -32
  87. package/lib/mp4/Atom.d.ts +16 -16
  88. package/lib/mp4/Atom.js +70 -70
  89. package/lib/mp4/AtomToken.d.ts +395 -395
  90. package/lib/mp4/AtomToken.js +406 -406
  91. package/lib/mp4/MP4Parser.d.ts +30 -30
  92. package/lib/mp4/MP4Parser.js +511 -511
  93. package/lib/mp4/MP4TagMapper.d.ts +5 -5
  94. package/lib/mp4/MP4TagMapper.js +115 -115
  95. package/lib/mpeg/ExtendedLameHeader.d.ts +27 -27
  96. package/lib/mpeg/ExtendedLameHeader.js +31 -31
  97. package/lib/mpeg/MpegParser.d.ts +49 -49
  98. package/lib/mpeg/MpegParser.js +524 -524
  99. package/lib/mpeg/ReplayGainDataFormat.d.ts +55 -55
  100. package/lib/mpeg/ReplayGainDataFormat.js +69 -69
  101. package/lib/mpeg/XingTag.d.ts +45 -45
  102. package/lib/mpeg/XingTag.js +69 -69
  103. package/lib/musepack/index.d.ts +5 -5
  104. package/lib/musepack/index.js +32 -32
  105. package/lib/musepack/sv7/BitReader.d.ts +13 -13
  106. package/lib/musepack/sv7/BitReader.js +54 -54
  107. package/lib/musepack/sv7/MpcSv7Parser.d.ts +8 -8
  108. package/lib/musepack/sv7/MpcSv7Parser.js +46 -46
  109. package/lib/musepack/sv7/StreamVersion7.d.ts +28 -28
  110. package/lib/musepack/sv7/StreamVersion7.js +41 -41
  111. package/lib/musepack/sv8/MpcSv8Parser.d.ts +6 -6
  112. package/lib/musepack/sv8/MpcSv8Parser.js +55 -55
  113. package/lib/musepack/sv8/StreamVersion8.d.ts +40 -40
  114. package/lib/musepack/sv8/StreamVersion8.js +80 -80
  115. package/lib/ogg/Ogg.d.ts +72 -72
  116. package/lib/ogg/Ogg.js +2 -2
  117. package/lib/ogg/OggParser.d.ts +23 -23
  118. package/lib/ogg/OggParser.js +126 -126
  119. package/lib/ogg/opus/Opus.d.ts +48 -48
  120. package/lib/ogg/opus/Opus.js +28 -28
  121. package/lib/ogg/opus/OpusParser.d.ts +25 -25
  122. package/lib/ogg/opus/OpusParser.js +56 -56
  123. package/lib/ogg/speex/Speex.d.ts +36 -36
  124. package/lib/ogg/speex/Speex.js +31 -31
  125. package/lib/ogg/speex/SpeexParser.d.ts +22 -22
  126. package/lib/ogg/speex/SpeexParser.js +35 -35
  127. package/lib/ogg/theora/Theora.d.ts +20 -20
  128. package/lib/ogg/theora/Theora.js +23 -23
  129. package/lib/ogg/theora/TheoraParser.d.ts +28 -28
  130. package/lib/ogg/theora/TheoraParser.js +44 -44
  131. package/lib/ogg/vorbis/Vorbis.d.ts +69 -69
  132. package/lib/ogg/vorbis/Vorbis.js +78 -78
  133. package/lib/ogg/vorbis/VorbisDecoder.d.ts +12 -12
  134. package/lib/ogg/vorbis/VorbisDecoder.js +32 -32
  135. package/lib/ogg/vorbis/VorbisParser.d.ts +36 -36
  136. package/lib/ogg/vorbis/VorbisParser.js +128 -128
  137. package/lib/ogg/vorbis/VorbisTagMapper.d.ts +7 -7
  138. package/lib/ogg/vorbis/VorbisTagMapper.js +132 -132
  139. package/lib/riff/RiffChunk.d.ts +16 -16
  140. package/lib/riff/RiffChunk.js +32 -32
  141. package/lib/riff/RiffInfoTagMap.d.ts +10 -10
  142. package/lib/riff/RiffInfoTagMap.js +37 -37
  143. package/lib/type.d.ts +592 -592
  144. package/lib/type.js +5 -5
  145. package/lib/wav/BwfChunk.d.ts +17 -17
  146. package/lib/wav/BwfChunk.js +29 -28
  147. package/lib/wav/WaveChunk.d.ts +64 -64
  148. package/lib/wav/WaveChunk.js +65 -65
  149. package/lib/wav/WaveParser.d.ts +24 -24
  150. package/lib/wav/WaveParser.js +158 -156
  151. package/lib/wavpack/WavPackParser.d.ts +14 -14
  152. package/lib/wavpack/WavPackParser.js +99 -99
  153. package/lib/wavpack/WavPackToken.d.ts +64 -64
  154. package/lib/wavpack/WavPackToken.js +76 -76
  155. package/package.json +152 -150
@@ -1,134 +1,134 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasID3v1Header = exports.ID3v1Parser = exports.Genres = void 0;
4
- const debug_1 = require("debug");
5
- const token_types_1 = require("token-types");
6
- const util = require("../common/Util");
7
- const BasicParser_1 = require("../common/BasicParser");
8
- const APEv2Parser_1 = require("../apev2/APEv2Parser");
9
- const debug = (0, debug_1.default)('music-metadata:parser:ID3v1');
10
- /**
11
- * ID3v1 Genre mappings
12
- * Ref: https://de.wikipedia.org/wiki/Liste_der_ID3v1-Genres
13
- */
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'
43
- ];
44
- /**
45
- * Spec: http://id3.org/ID3v1
46
- * Wiki: https://en.wikipedia.org/wiki/ID3
47
- */
48
- const Iid3v1Token = {
49
- len: 128,
50
- /**
51
- * @param buf Buffer possibly holding the 128 bytes ID3v1.1 metadata header
52
- * @param off Offset in buffer in bytes
53
- * @returns ID3v1.1 header if first 3 bytes equals 'TAG', otherwise null is returned
54
- */
55
- get: (buf, off) => {
56
- const header = new Id3v1StringType(3).get(buf, off);
57
- return header === 'TAG' ? {
58
- header,
59
- title: new Id3v1StringType(30).get(buf, off + 3),
60
- artist: new Id3v1StringType(30).get(buf, off + 33),
61
- album: new Id3v1StringType(30).get(buf, off + 63),
62
- year: new Id3v1StringType(4).get(buf, off + 93),
63
- comment: new Id3v1StringType(28).get(buf, off + 97),
64
- // ID3v1.1 separator for track
65
- zeroByte: token_types_1.UINT8.get(buf, off + 127),
66
- // track: ID3v1.1 field added by Michael Mutschler
67
- track: token_types_1.UINT8.get(buf, off + 126),
68
- genre: token_types_1.UINT8.get(buf, off + 127)
69
- } : null;
70
- }
71
- };
72
- class Id3v1StringType extends token_types_1.StringType {
73
- constructor(len) {
74
- super(len, 'binary');
75
- }
76
- get(buf, off) {
77
- let value = super.get(buf, off);
78
- value = util.trimRightNull(value);
79
- value = value.trim();
80
- return value.length > 0 ? value : undefined;
81
- }
82
- }
83
- class ID3v1Parser extends BasicParser_1.BasicParser {
84
- static getGenre(genreIndex) {
85
- if (genreIndex < exports.Genres.length) {
86
- return exports.Genres[genreIndex];
87
- }
88
- return undefined; // ToDO: generate warning
89
- }
90
- async parse() {
91
- if (!this.tokenizer.fileInfo.size) {
92
- debug('Skip checking for ID3v1 because the file-size is unknown');
93
- return;
94
- }
95
- if (this.options.apeHeader) {
96
- this.tokenizer.ignore(this.options.apeHeader.offset - this.tokenizer.position);
97
- const apeParser = new APEv2Parser_1.APEv2Parser();
98
- apeParser.init(this.metadata, this.tokenizer, this.options);
99
- await apeParser.parseTags(this.options.apeHeader.footer);
100
- }
101
- const offset = this.tokenizer.fileInfo.size - Iid3v1Token.len;
102
- if (this.tokenizer.position > offset) {
103
- debug('Already consumed the last 128 bytes');
104
- return;
105
- }
106
- const header = await this.tokenizer.readToken(Iid3v1Token, offset);
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] !== '')
111
- this.addTag(id, header[id]);
112
- }
113
- const genre = ID3v1Parser.getGenre(header.genre);
114
- if (genre)
115
- this.addTag('genre', genre);
116
- }
117
- else {
118
- debug('ID3v1 header not found at: pos=%s', this.tokenizer.fileInfo.size - Iid3v1Token.len);
119
- }
120
- }
121
- addTag(id, value) {
122
- this.metadata.addTag('ID3v1', id, value);
123
- }
124
- }
125
- exports.ID3v1Parser = ID3v1Parser;
126
- async function hasID3v1Header(reader) {
127
- if (reader.fileSize >= 128) {
128
- const tag = Buffer.alloc(3);
129
- await reader.randomRead(tag, 0, tag.length, reader.fileSize - 128);
130
- return tag.toString('binary') === 'TAG';
131
- }
132
- return false;
133
- }
134
- exports.hasID3v1Header = hasID3v1Header;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.hasID3v1Header = exports.ID3v1Parser = exports.Genres = void 0;
4
+ const debug_1 = require("debug");
5
+ const token_types_1 = require("token-types");
6
+ const util = require("../common/Util");
7
+ const BasicParser_1 = require("../common/BasicParser");
8
+ const APEv2Parser_1 = require("../apev2/APEv2Parser");
9
+ const debug = (0, debug_1.default)('music-metadata:parser:ID3v1');
10
+ /**
11
+ * ID3v1 Genre mappings
12
+ * Ref: https://de.wikipedia.org/wiki/Liste_der_ID3v1-Genres
13
+ */
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'
43
+ ];
44
+ /**
45
+ * Spec: http://id3.org/ID3v1
46
+ * Wiki: https://en.wikipedia.org/wiki/ID3
47
+ */
48
+ const Iid3v1Token = {
49
+ len: 128,
50
+ /**
51
+ * @param buf Buffer possibly holding the 128 bytes ID3v1.1 metadata header
52
+ * @param off Offset in buffer in bytes
53
+ * @returns ID3v1.1 header if first 3 bytes equals 'TAG', otherwise null is returned
54
+ */
55
+ get: (buf, off) => {
56
+ const header = new Id3v1StringType(3).get(buf, off);
57
+ return header === 'TAG' ? {
58
+ header,
59
+ title: new Id3v1StringType(30).get(buf, off + 3),
60
+ artist: new Id3v1StringType(30).get(buf, off + 33),
61
+ album: new Id3v1StringType(30).get(buf, off + 63),
62
+ year: new Id3v1StringType(4).get(buf, off + 93),
63
+ comment: new Id3v1StringType(28).get(buf, off + 97),
64
+ // ID3v1.1 separator for track
65
+ zeroByte: token_types_1.UINT8.get(buf, off + 127),
66
+ // track: ID3v1.1 field added by Michael Mutschler
67
+ track: token_types_1.UINT8.get(buf, off + 126),
68
+ genre: token_types_1.UINT8.get(buf, off + 127)
69
+ } : null;
70
+ }
71
+ };
72
+ class Id3v1StringType extends token_types_1.StringType {
73
+ constructor(len) {
74
+ super(len, 'binary');
75
+ }
76
+ get(buf, off) {
77
+ let value = super.get(buf, off);
78
+ value = util.trimRightNull(value);
79
+ value = value.trim();
80
+ return value.length > 0 ? value : undefined;
81
+ }
82
+ }
83
+ class ID3v1Parser extends BasicParser_1.BasicParser {
84
+ static getGenre(genreIndex) {
85
+ if (genreIndex < exports.Genres.length) {
86
+ return exports.Genres[genreIndex];
87
+ }
88
+ return undefined; // ToDO: generate warning
89
+ }
90
+ async parse() {
91
+ if (!this.tokenizer.fileInfo.size) {
92
+ debug('Skip checking for ID3v1 because the file-size is unknown');
93
+ return;
94
+ }
95
+ if (this.options.apeHeader) {
96
+ this.tokenizer.ignore(this.options.apeHeader.offset - this.tokenizer.position);
97
+ const apeParser = new APEv2Parser_1.APEv2Parser();
98
+ apeParser.init(this.metadata, this.tokenizer, this.options);
99
+ await apeParser.parseTags(this.options.apeHeader.footer);
100
+ }
101
+ const offset = this.tokenizer.fileInfo.size - Iid3v1Token.len;
102
+ if (this.tokenizer.position > offset) {
103
+ debug('Already consumed the last 128 bytes');
104
+ return;
105
+ }
106
+ const header = await this.tokenizer.readToken(Iid3v1Token, offset);
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] !== '')
111
+ this.addTag(id, header[id]);
112
+ }
113
+ const genre = ID3v1Parser.getGenre(header.genre);
114
+ if (genre)
115
+ this.addTag('genre', genre);
116
+ }
117
+ else {
118
+ debug('ID3v1 header not found at: pos=%s', this.tokenizer.fileInfo.size - Iid3v1Token.len);
119
+ }
120
+ }
121
+ addTag(id, value) {
122
+ this.metadata.addTag('ID3v1', id, value);
123
+ }
124
+ }
125
+ exports.ID3v1Parser = ID3v1Parser;
126
+ async function hasID3v1Header(reader) {
127
+ if (reader.fileSize >= 128) {
128
+ const tag = Buffer.alloc(3);
129
+ await reader.randomRead(tag, 0, tag.length, reader.fileSize - 128);
130
+ return tag.toString('binary') === 'TAG';
131
+ }
132
+ return false;
133
+ }
134
+ exports.hasID3v1Header = hasID3v1Header;
@@ -1,4 +1,4 @@
1
- import { CommonTagMapper } from '../common/GenericTagMapper';
2
- export declare class ID3v1TagMapper extends CommonTagMapper {
3
- constructor();
4
- }
1
+ import { CommonTagMapper } from '../common/GenericTagMapper';
2
+ export declare class ID3v1TagMapper extends CommonTagMapper {
3
+ constructor();
4
+ }
@@ -1,23 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ID3v1TagMapper = void 0;
4
- const GenericTagMapper_1 = require("../common/GenericTagMapper");
5
- /**
6
- * ID3v1 tag mappings
7
- */
8
- const id3v1TagMap = {
9
- title: 'title',
10
- artist: 'artist',
11
- album: 'album',
12
- year: 'year',
13
- comment: 'comment',
14
- track: 'track',
15
- genre: 'genre'
16
- };
17
- class ID3v1TagMapper extends GenericTagMapper_1.CommonTagMapper {
18
- constructor() {
19
- super(['ID3v1'], id3v1TagMap);
20
- }
21
- }
22
- exports.ID3v1TagMapper = ID3v1TagMapper;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ID3v1TagMapper = void 0;
4
+ const GenericTagMapper_1 = require("../common/GenericTagMapper");
5
+ /**
6
+ * ID3v1 tag mappings
7
+ */
8
+ const id3v1TagMap = {
9
+ title: 'title',
10
+ artist: 'artist',
11
+ album: 'album',
12
+ year: 'year',
13
+ comment: 'comment',
14
+ track: 'track',
15
+ genre: 'genre'
16
+ };
17
+ class ID3v1TagMapper extends GenericTagMapper_1.CommonTagMapper {
18
+ constructor() {
19
+ super(['ID3v1'], id3v1TagMap);
20
+ }
21
+ }
22
+ exports.ID3v1TagMapper = ID3v1TagMapper;
23
23
  //# sourceMappingURL=ID3v1TagMap.js.map
@@ -1,17 +1,17 @@
1
- import { ITokenizer } from 'strtok3/lib/core';
2
- import { BasicParser } from '../common/BasicParser';
3
- /**
4
- * Abstract parser which tries take ID3v2 and ID3v1 headers.
5
- */
6
- export declare abstract class AbstractID3Parser extends BasicParser {
7
- static startsWithID3v2Header(tokenizer: ITokenizer): Promise<boolean>;
8
- private id3parser;
9
- parse(): Promise<void>;
10
- /**
11
- * Called after ID3v2 headers are parsed
12
- */
13
- abstract postId3v2Parse(): Promise<void>;
14
- protected finalize(): void;
15
- private parseID3v2;
16
- private tryReadId3v2Headers;
17
- }
1
+ import { ITokenizer } from 'strtok3/lib/core';
2
+ import { BasicParser } from '../common/BasicParser';
3
+ /**
4
+ * Abstract parser which tries take ID3v2 and ID3v1 headers.
5
+ */
6
+ export declare abstract class AbstractID3Parser extends BasicParser {
7
+ static startsWithID3v2Header(tokenizer: ITokenizer): Promise<boolean>;
8
+ private id3parser;
9
+ parse(): Promise<void>;
10
+ /**
11
+ * Called after ID3v2 headers are parsed
12
+ */
13
+ abstract postId3v2Parse(): Promise<void>;
14
+ protected finalize(): void;
15
+ private parseID3v2;
16
+ private tryReadId3v2Headers;
17
+ }
@@ -1,60 +1,60 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractID3Parser = void 0;
4
- const core_1 = require("strtok3/lib/core");
5
- const debug_1 = require("debug");
6
- const ID3v2Token_1 = require("./ID3v2Token");
7
- const ID3v2Parser_1 = require("./ID3v2Parser");
8
- const ID3v1Parser_1 = require("../id3v1/ID3v1Parser");
9
- const BasicParser_1 = require("../common/BasicParser");
10
- const debug = (0, debug_1.default)('music-metadata:parser:ID3');
11
- /**
12
- * Abstract parser which tries take ID3v2 and ID3v1 headers.
13
- */
14
- class AbstractID3Parser extends BasicParser_1.BasicParser {
15
- constructor() {
16
- super(...arguments);
17
- this.id3parser = new ID3v2Parser_1.ID3v2Parser();
18
- }
19
- static async startsWithID3v2Header(tokenizer) {
20
- return (await tokenizer.peekToken(ID3v2Token_1.ID3v2Header)).fileIdentifier === 'ID3';
21
- }
22
- async parse() {
23
- try {
24
- await this.parseID3v2();
25
- }
26
- catch (err) {
27
- if (err instanceof core_1.EndOfStreamError) {
28
- debug(`End-of-stream`);
29
- }
30
- else {
31
- throw err;
32
- }
33
- }
34
- }
35
- finalize() {
36
- return;
37
- }
38
- async parseID3v2() {
39
- await this.tryReadId3v2Headers();
40
- debug('End of ID3v2 header, go to MPEG-parser: pos=%s', this.tokenizer.position);
41
- await this.postId3v2Parse();
42
- if (this.options.skipPostHeaders && this.metadata.hasAny()) {
43
- this.finalize();
44
- }
45
- else {
46
- const id3v1parser = new ID3v1Parser_1.ID3v1Parser();
47
- await id3v1parser.init(this.metadata, this.tokenizer, this.options).parse();
48
- this.finalize();
49
- }
50
- }
51
- async tryReadId3v2Headers() {
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);
55
- await this.id3parser.parse(this.metadata, this.tokenizer, this.options);
56
- return this.tryReadId3v2Headers();
57
- }
58
- }
59
- }
60
- exports.AbstractID3Parser = AbstractID3Parser;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AbstractID3Parser = void 0;
4
+ const core_1 = require("strtok3/lib/core");
5
+ const debug_1 = require("debug");
6
+ const ID3v2Token_1 = require("./ID3v2Token");
7
+ const ID3v2Parser_1 = require("./ID3v2Parser");
8
+ const ID3v1Parser_1 = require("../id3v1/ID3v1Parser");
9
+ const BasicParser_1 = require("../common/BasicParser");
10
+ const debug = (0, debug_1.default)('music-metadata:parser:ID3');
11
+ /**
12
+ * Abstract parser which tries take ID3v2 and ID3v1 headers.
13
+ */
14
+ class AbstractID3Parser extends BasicParser_1.BasicParser {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.id3parser = new ID3v2Parser_1.ID3v2Parser();
18
+ }
19
+ static async startsWithID3v2Header(tokenizer) {
20
+ return (await tokenizer.peekToken(ID3v2Token_1.ID3v2Header)).fileIdentifier === 'ID3';
21
+ }
22
+ async parse() {
23
+ try {
24
+ await this.parseID3v2();
25
+ }
26
+ catch (err) {
27
+ if (err instanceof core_1.EndOfStreamError) {
28
+ debug(`End-of-stream`);
29
+ }
30
+ else {
31
+ throw err;
32
+ }
33
+ }
34
+ }
35
+ finalize() {
36
+ return;
37
+ }
38
+ async parseID3v2() {
39
+ await this.tryReadId3v2Headers();
40
+ debug('End of ID3v2 header, go to MPEG-parser: pos=%s', this.tokenizer.position);
41
+ await this.postId3v2Parse();
42
+ if (this.options.skipPostHeaders && this.metadata.hasAny()) {
43
+ this.finalize();
44
+ }
45
+ else {
46
+ const id3v1parser = new ID3v1Parser_1.ID3v1Parser();
47
+ await id3v1parser.init(this.metadata, this.tokenizer, this.options).parse();
48
+ this.finalize();
49
+ }
50
+ }
51
+ async tryReadId3v2Headers() {
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);
55
+ await this.id3parser.parse(this.metadata, this.tokenizer, this.options);
56
+ return this.tryReadId3v2Headers();
57
+ }
58
+ }
59
+ }
60
+ exports.AbstractID3Parser = AbstractID3Parser;
@@ -1,31 +1,31 @@
1
- import { ID3v2MajorVersion } from './ID3v2Token';
2
- import { IWarningCollector } from '../common/MetadataCollector';
3
- export declare function parseGenre(origVal: string): string[];
4
- export declare class FrameParser {
5
- private major;
6
- private warningCollector;
7
- /**
8
- * Create id3v2 frame parser
9
- * @param major - Major version, e.g. (4) for id3v2.4
10
- * @param warningCollector - Used to collect decode issue
11
- */
12
- constructor(major: ID3v2MajorVersion, warningCollector: IWarningCollector);
13
- readData(uint8Array: Uint8Array, type: string, includeCovers: boolean): any;
14
- protected static fixPictureMimeType(pictureType: string): string;
15
- /**
16
- * Converts TMCL (Musician credits list) or TIPL (Involved people list)
17
- * @param entries
18
- */
19
- private static functionList;
20
- /**
21
- * id3v2.4 defines that multiple T* values are separated by 0x00
22
- * id3v2.3 defines that TCOM, TEXT, TOLY, TOPE & TPE1 values are separated by /
23
- * @param tag - Tag name
24
- * @param text - Concatenated tag value
25
- * @returns Split tag value
26
- */
27
- private splitValue;
28
- private static trimArray;
29
- private static readIdentifierAndData;
30
- private static getNullTerminatorLength;
31
- }
1
+ import { ID3v2MajorVersion } from './ID3v2Token';
2
+ import { IWarningCollector } from '../common/MetadataCollector';
3
+ export declare function parseGenre(origVal: string): string[];
4
+ export declare class FrameParser {
5
+ private major;
6
+ private warningCollector;
7
+ /**
8
+ * Create id3v2 frame parser
9
+ * @param major - Major version, e.g. (4) for id3v2.4
10
+ * @param warningCollector - Used to collect decode issue
11
+ */
12
+ constructor(major: ID3v2MajorVersion, warningCollector: IWarningCollector);
13
+ readData(uint8Array: Uint8Array, type: string, includeCovers: boolean): any;
14
+ protected static fixPictureMimeType(pictureType: string): string;
15
+ /**
16
+ * Converts TMCL (Musician credits list) or TIPL (Involved people list)
17
+ * @param entries
18
+ */
19
+ private static functionList;
20
+ /**
21
+ * id3v2.4 defines that multiple T* values are separated by 0x00
22
+ * id3v2.3 defines that TCOM, TEXT, TOLY, TOPE & TPE1 values are separated by /
23
+ * @param tag - Tag name
24
+ * @param text - Concatenated tag value
25
+ * @returns Split tag value
26
+ */
27
+ private splitValue;
28
+ private static trimArray;
29
+ private static readIdentifierAndData;
30
+ private static getNullTerminatorLength;
31
+ }