music-metadata 7.11.6 → 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 +86 -86
  12. package/lib/apev2/APEv2Token.d.ts +100 -100
  13. package/lib/apev2/APEv2Token.js +126 -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 +95 -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 +21 -21
  28. package/lib/common/CombinedTagMapper.d.ts +19 -19
  29. package/lib/common/CombinedTagMapper.js +51 -51
  30. package/lib/common/FourCC.d.ts +6 -6
  31. package/lib/common/FourCC.js +28 -28
  32. package/lib/common/GenericTagMapper.d.ts +51 -51
  33. package/lib/common/GenericTagMapper.js +55 -55
  34. package/lib/common/GenericTagTypes.d.ts +33 -33
  35. package/lib/common/GenericTagTypes.js +131 -131
  36. package/lib/common/MetadataCollector.d.ts +76 -76
  37. package/lib/common/MetadataCollector.js +275 -275
  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 +162 -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 +22 -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 +55 -55
  66. package/lib/id3v2/ID3v24TagMapper.d.ts +14 -14
  67. package/lib/id3v2/ID3v24TagMapper.js +193 -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 -45
  75. package/lib/index.js +74 -74
  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 -235
  82. package/lib/matroska/MatroskaTagMapper.d.ts +4 -4
  83. package/lib/matroska/MatroskaTagMapper.js +35 -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 +115 -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 +132 -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 +37 -37
  142. package/lib/type.d.ts +599 -599
  143. package/lib/type.js +13 -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,134 +1,134 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasID3v1Header = exports.ID3v1Parser = exports.Genres = void 0;
4
- const initDebug = require("debug");
5
- const Token = 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 = initDebug('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.UINT8.get(buf, off + 127),
66
- // track: ID3v1.1 field added by Michael Mutschler
67
- track: Token.UINT8.get(buf, off + 126),
68
- genre: Token.UINT8.get(buf, off + 127)
69
- } : null;
70
- }
71
- };
72
- class Id3v1StringType extends Token.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 initDebug = require("debug");
5
+ const Token = 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 = initDebug('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.UINT8.get(buf, off + 127),
66
+ // track: ID3v1.1 field added by Michael Mutschler
67
+ track: Token.UINT8.get(buf, off + 126),
68
+ genre: Token.UINT8.get(buf, off + 127)
69
+ } : null;
70
+ }
71
+ };
72
+ class Id3v1StringType extends Token.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 _parse(): 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 _parse(): 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 = 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 = _debug('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._parse();
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 = 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 = _debug('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._parse();
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,32 +1,32 @@
1
- /// <reference types="node" />
2
- import { ID3v2MajorVersion } from './ID3v2Token';
3
- import { IWarningCollector } from '../common/MetadataCollector';
4
- export declare function parseGenre(origVal: string): string[];
5
- export declare class FrameParser {
6
- private major;
7
- private warningCollector;
8
- /**
9
- * Create id3v2 frame parser
10
- * @param major - Major version, e.g. (4) for id3v2.4
11
- * @param warningCollector - Used to collect decode issue
12
- */
13
- constructor(major: ID3v2MajorVersion, warningCollector: IWarningCollector);
14
- readData(b: Buffer, type: string, includeCovers: boolean): any;
15
- protected static fixPictureMimeType(pictureType: string): string;
16
- /**
17
- * Converts TMCL (Musician credits list) or TIPL (Involved people list)
18
- * @param entries
19
- */
20
- private static functionList;
21
- /**
22
- * id3v2.4 defines that multiple T* values are separated by 0x00
23
- * id3v2.3 defines that TCOM, TEXT, TOLY, TOPE & TPE1 values are separated by /
24
- * @param tag - Tag name
25
- * @param text - Concatenated tag value
26
- * @returns Split tag value
27
- */
28
- private splitValue;
29
- private static trimArray;
30
- private static readIdentifierAndData;
31
- private static getNullTerminatorLength;
32
- }
1
+ /// <reference types="node" />
2
+ import { ID3v2MajorVersion } from './ID3v2Token';
3
+ import { IWarningCollector } from '../common/MetadataCollector';
4
+ export declare function parseGenre(origVal: string): string[];
5
+ export declare class FrameParser {
6
+ private major;
7
+ private warningCollector;
8
+ /**
9
+ * Create id3v2 frame parser
10
+ * @param major - Major version, e.g. (4) for id3v2.4
11
+ * @param warningCollector - Used to collect decode issue
12
+ */
13
+ constructor(major: ID3v2MajorVersion, warningCollector: IWarningCollector);
14
+ readData(b: Buffer, type: string, includeCovers: boolean): any;
15
+ protected static fixPictureMimeType(pictureType: string): string;
16
+ /**
17
+ * Converts TMCL (Musician credits list) or TIPL (Involved people list)
18
+ * @param entries
19
+ */
20
+ private static functionList;
21
+ /**
22
+ * id3v2.4 defines that multiple T* values are separated by 0x00
23
+ * id3v2.3 defines that TCOM, TEXT, TOLY, TOPE & TPE1 values are separated by /
24
+ * @param tag - Tag name
25
+ * @param text - Concatenated tag value
26
+ * @returns Split tag value
27
+ */
28
+ private splitValue;
29
+ private static trimArray;
30
+ private static readIdentifierAndData;
31
+ private static getNullTerminatorLength;
32
+ }