music-metadata 8.1.5 → 8.3.0

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.
package/README.md CHANGED
@@ -100,6 +100,44 @@ import * as mm from 'music-metadata/lib/core';
100
100
  ### Sponsor
101
101
  [Become a sponsor to Borewit](https://github.com/sponsors/Borewit)
102
102
 
103
+ ## Dependencies
104
+
105
+ Dependency diagram:
106
+ ```mermaid
107
+ graph TD;
108
+ MM(music-metadata)-->S(strtok3)
109
+ MM-->TY(token-types)
110
+ MM-->FT(file-type)
111
+ S(strtok3)-->P(peek-readable)
112
+ S-->TO("@tokenizer/token")
113
+ TY-->TO
114
+ TY-->IE("ieee754")
115
+ FT-->RWNS(readable-web-to-node-stream)
116
+ FT-->S
117
+ FT-->TY
118
+ TY-->NB(node:buffer)
119
+ RWNS-->RS(readable-stream)
120
+ RS-->SD(string_decoder)
121
+ SD-->SB(safe-buffer)
122
+ RS-->UD(util-deprecate)
123
+ RS-->I(inherits)
124
+ style NB fill:#F88,stroke:#A44
125
+ style SB fill:#F88,stroke:#A44
126
+ style SD fill:#CCC,stroke:#888
127
+ style IE fill:#CCC,stroke:#888
128
+ style UD fill:#CCC,stroke:#888
129
+ style I fill:#CCC,stroke:#888
130
+ ```
131
+
132
+ Dependency list:
133
+ * [tokenizer-token](https://github.com/Borewit/tokenizer-token)
134
+ * [strtok3](https://github.com/Borewit/strtok3)
135
+ * [token-types](https://github.com/Borewit/token-types)
136
+ * [file-type](https://github.com/sindresorhus/file-type)
137
+ * [@tokenizer-token](https://github.com/Borewit/tokenizer-token)
138
+ * [peek-readable](https://github.com/Borewit/peek-readable)
139
+ * [readable-web-to-node-stream](https://github.com/Borewit/readable-web-to-node-stream)
140
+
103
141
  ## Usage
104
142
 
105
143
  ### Installation
@@ -15,7 +15,7 @@ const apev2TagMap = {
15
15
  Comment: 'comment',
16
16
  Track: 'track',
17
17
  Disc: 'disk',
18
- DISCNUMBER: 'disk',
18
+ DISCNUMBER: 'disk', // ToDo: backwards compatibility', valid tag?
19
19
  Genre: 'genre',
20
20
  'Cover Art (Front)': 'picture',
21
21
  'Cover Art (Back)': 'picture',
@@ -286,7 +286,7 @@ export class ExtendedStreamPropertiesObjectState extends State {
286
286
  averageTimePerFrame: buf.readInt32LE(off + 52),
287
287
  streamNameCount: buf.readInt32LE(off + 54),
288
288
  payloadExtensionSystems: buf.readInt32LE(off + 56),
289
- streamNames: [],
289
+ streamNames: [], // ToDo
290
290
  streamPropertiesObject: null
291
291
  };
292
292
  }
@@ -8,7 +8,7 @@ const asfTagMap = {
8
8
  Author: 'artist',
9
9
  'WM/AlbumArtist': 'albumartist',
10
10
  'WM/AlbumTitle': 'album',
11
- 'WM/Year': 'date',
11
+ 'WM/Year': 'date', // changed to 'year' to 'date' based on Picard mappings; ToDo: check me
12
12
  'WM/OriginalReleaseTime': 'originaldate',
13
13
  'WM/OriginalReleaseYear': 'originalyear',
14
14
  Description: 'comment',
@@ -79,6 +79,7 @@ export class FrameParser {
79
79
  debug(`Parsing tag type=${type}, encoding=${encoding}, bom=${bom}`);
80
80
  switch (type !== 'TXXX' && type[0] === 'T' ? 'T*' : type) {
81
81
  case 'T*': // 4.2.1. Text information frames - details
82
+ case 'GRP1': // iTunes-specific ID3v2 grouping field
82
83
  case 'IPLS': // v2.3: Involved people list
83
84
  case 'MVIN':
84
85
  case 'MVNM':
@@ -11,7 +11,7 @@ const id3v24TagMap = {
11
11
  'TXXX:Artists': 'artists',
12
12
  TPE2: 'albumartist',
13
13
  TALB: 'album',
14
- TDRV: 'date',
14
+ TDRV: 'date', // [ 'date', 'year' ] ToDo: improve 'year' mapping
15
15
  /**
16
16
  * Original release year
17
17
  */
@@ -20,7 +20,7 @@ const id3v24TagMap = {
20
20
  TCON: 'genre',
21
21
  APIC: 'picture',
22
22
  TCOM: 'composer',
23
- 'USLT:description': 'lyrics',
23
+ USLT: 'lyrics',
24
24
  TSOA: 'albumsort',
25
25
  TSOT: 'titlesort',
26
26
  TOAL: 'originalalbum',
@@ -84,7 +84,7 @@ const id3v24TagMap = {
84
84
  WOAR: 'website',
85
85
  // id3v2.4
86
86
  // ToDo: In same sequence as defined at http://id3.org/id3v2.4.0-frames
87
- TDRC: 'date',
87
+ TDRC: 'date', // date YYYY-MM-DD
88
88
  TYER: 'year',
89
89
  TDOR: 'originaldate',
90
90
  // 'TMCL:instrument': 'performer:instrument',
@@ -135,7 +135,8 @@ const id3v24TagMap = {
135
135
  TDRL: 'releasedate',
136
136
  TGID: 'podcastId',
137
137
  TKWD: 'keywords',
138
- WFED: 'podcasturl'
138
+ WFED: 'podcasturl',
139
+ GRP1: 'grouping'
139
140
  };
140
141
  export class ID3v24TagMapper extends CaseInsensitiveTagMap {
141
142
  static toRating(popm) {
@@ -154,6 +155,7 @@ export class ID3v24TagMapper extends CaseInsensitiveTagMap {
154
155
  * @return Common value e.g. "Buena Vista Social Club"
155
156
  */
156
157
  postMap(tag, warnings) {
158
+ var _a, _b;
157
159
  switch (tag.id) {
158
160
  case 'UFID': // decode MusicBrainz Recording Id
159
161
  if (tag.value.owner_identifier === 'http://musicbrainz.org') {
@@ -177,11 +179,14 @@ export class ID3v24TagMapper extends CaseInsensitiveTagMap {
177
179
  }
178
180
  break;
179
181
  case 'COMM':
180
- tag.value = tag.value ? tag.value.text : null;
182
+ tag.value = (_a = tag.value) === null || _a === void 0 ? void 0 : _a.text;
181
183
  break;
182
184
  case 'POPM':
183
185
  tag.value = ID3v24TagMapper.toRating(tag.value);
184
186
  break;
187
+ case 'USLT':
188
+ tag.value = (_b = tag.value) === null || _b === void 0 ? void 0 : _b.text;
189
+ break;
185
190
  default:
186
191
  break;
187
192
  }
@@ -9,12 +9,12 @@ export const elements = {
9
9
  0x1a45dfa3: {
10
10
  name: 'ebml',
11
11
  container: {
12
- 0x4286: { name: 'ebmlVersion', value: DataType.uint },
13
- 0x42f7: { name: 'ebmlReadVersion', value: DataType.uint },
14
- 0x42f2: { name: 'ebmlMaxIDWidth', value: DataType.uint },
15
- 0x42f3: { name: 'ebmlMaxSizeWidth', value: DataType.uint },
16
- 0x4282: { name: 'docType', value: DataType.string },
17
- 0x4287: { name: 'docTypeVersion', value: DataType.uint },
12
+ 0x4286: { name: 'ebmlVersion', value: DataType.uint }, // 5.1.1
13
+ 0x42f7: { name: 'ebmlReadVersion', value: DataType.uint }, // 5.1.2
14
+ 0x42f2: { name: 'ebmlMaxIDWidth', value: DataType.uint }, // 5.1.3
15
+ 0x42f3: { name: 'ebmlMaxSizeWidth', value: DataType.uint }, // 5.1.4
16
+ 0x4282: { name: 'docType', value: DataType.string }, // 5.1.5
17
+ 0x4287: { name: 'docTypeVersion', value: DataType.uint }, // 5.1.6
18
18
  0x4285: { name: 'docTypeReadVersion', value: DataType.uint } // 5.1.7
19
19
  }
20
20
  },
@@ -77,7 +77,7 @@ export const elements = {
77
77
  0x83: { name: 'trackType', value: DataType.uint },
78
78
  0xb9: { name: 'flagEnabled', value: DataType.bool },
79
79
  0x88: { name: 'flagDefault', value: DataType.bool },
80
- 0x55aa: { name: 'flagForced', value: DataType.bool },
80
+ 0x55aa: { name: 'flagForced', value: DataType.bool }, // extended
81
81
  0x9c: { name: 'flagLacing', value: DataType.bool },
82
82
  0x6de7: { name: 'minCache', value: DataType.uint },
83
83
  0x6de8: { name: 'maxCache', value: DataType.uint },
@@ -114,7 +114,7 @@ export const elements = {
114
114
  container: {
115
115
  0xb5: { name: 'samplingFrequency', value: DataType.float },
116
116
  0x78b5: { name: 'outputSamplingFrequency', value: DataType.float },
117
- 0x9f: { name: 'channels', value: DataType.uint },
117
+ 0x9f: { name: 'channels', value: DataType.uint }, // https://www.matroska.org/technical/specs/index.html
118
118
  0x94: { name: 'channels', value: DataType.uint },
119
119
  0x7d7b: { name: 'channelPositions', value: DataType.binary },
120
120
  0x6264: { name: 'bitDepth', value: DataType.uint }
@@ -250,8 +250,8 @@ export const elements = {
250
250
  0x63c5: { name: 'tagTrackUID', value: DataType.uid },
251
251
  0x63c4: { name: 'tagChapterUID', value: DataType.uint },
252
252
  0x63c6: { name: 'tagAttachmentUID', value: DataType.uid },
253
- 0x63ca: { name: 'targetType', value: DataType.string },
254
- 0x68ca: { name: 'targetTypeValue', value: DataType.uint },
253
+ 0x63ca: { name: 'targetType', value: DataType.string }, // extended
254
+ 0x68ca: { name: 'targetTypeValue', value: DataType.uint }, // extended
255
255
  0x63c9: { name: 'tagEditionUID', value: DataType.uid } // extended
256
256
  }
257
257
  },
@@ -262,8 +262,8 @@ export const elements = {
262
262
  0x45a3: { name: 'name', value: DataType.string },
263
263
  0x4487: { name: 'string', value: DataType.string },
264
264
  0x4485: { name: 'binary', value: DataType.binary },
265
- 0x447a: { name: 'language', value: DataType.string },
266
- 0x447b: { name: 'languageIETF', value: DataType.string },
265
+ 0x447a: { name: 'language', value: DataType.string }, // extended
266
+ 0x447b: { name: 'languageIETF', value: DataType.string }, // extended
267
267
  0x4484: { name: 'default', value: DataType.bool } // extended
268
268
  }
269
269
  }
@@ -341,14 +341,11 @@ export class MP4Parser extends BasicParser {
341
341
  case 'data': // value atom
342
342
  return this.parseValueAtom(tagKey, child);
343
343
  case 'name': // name atom (optional)
344
+ case 'mean':
345
+ case 'rate':
344
346
  const name = await this.tokenizer.readToken(new AtomToken.NameAtom(payLoadLength));
345
347
  tagKey += ':' + name.name;
346
348
  break;
347
- case 'mean': // name atom (optional)
348
- const mean = await this.tokenizer.readToken(new AtomToken.NameAtom(payLoadLength));
349
- // console.log(" %s[%s] = %s", tagKey, header.name, mean.name);
350
- tagKey += ':' + mean.name;
351
- break;
352
349
  default:
353
350
  const dataAtom = await this.tokenizer.readToken(new Token.BufferType(payLoadLength));
354
351
  this.addWarning('Unsupported meta-item: ' + tagKey + '[' + child.header.name + '] => value=' + dataAtom.toString('hex') + ' ascii=' + dataAtom.toString('ascii'));
@@ -378,9 +375,12 @@ export class MP4Parser extends BasicParser {
378
375
  // console.log(" %s[data] = %s", tagKey, genreStr);
379
376
  this.addTag(tagKey, genreStr);
380
377
  break;
378
+ case 'rate':
379
+ const rate = dataAtom.value.toString('ascii');
380
+ this.addTag(tagKey, rate);
381
+ break;
381
382
  default:
382
- // console.log(" reserved-data: name=%s, len=%s, set=%s, type=%s, locale=%s, value{ hex=%s, ascii=%s }",
383
- // header.name, header.length, dataAtom.type.set, dataAtom.type.type, dataAtom.locale, dataAtom.value.toString('hex'), dataAtom.value.toString('ascii'));
383
+ debug('unknown proprietary value type for: ' + metaAtom.atomPath);
384
384
  }
385
385
  break;
386
386
  case 1: // UTF-8: Without any count or NULL terminator
@@ -1,5 +1,8 @@
1
1
  import { CaseInsensitiveTagMap } from '../common/CaseInsensitiveTagMap.js';
2
+ import { ITag } from "../type.js";
3
+ import { INativeMetadataCollector } from "../common/MetadataCollector.js";
2
4
  export declare const tagType = "iTunes";
3
5
  export declare class MP4TagMapper extends CaseInsensitiveTagMap {
4
6
  constructor();
7
+ protected postMap(tag: ITag, warnings: INativeMetadataCollector): void;
5
8
  }
@@ -84,7 +84,7 @@ const mp4TagMap = {
84
84
  '----:com.apple.iTunes:replaygain_album_minmax': 'replaygain_album_minmax',
85
85
  '----:com.apple.iTunes:replaygain_undo': 'replaygain_undo',
86
86
  // Additional mappings:
87
- gnre: 'genre',
87
+ gnre: 'genre', // ToDo: check mapping
88
88
  '----:com.apple.iTunes:ALBUMARTISTSORT': 'albumartistsort',
89
89
  '----:com.apple.iTunes:ARTISTS': 'artists',
90
90
  '----:com.apple.iTunes:ORIGINALDATE': 'originaldate',
@@ -102,12 +102,23 @@ const mp4TagMap = {
102
102
  hdvd: 'hdVideo',
103
103
  keyw: 'keywords',
104
104
  shwm: 'showMovement',
105
- stik: 'stik'
105
+ stik: 'stik',
106
+ rate: 'rating'
106
107
  };
107
108
  export const tagType = 'iTunes';
108
109
  export class MP4TagMapper extends CaseInsensitiveTagMap {
109
110
  constructor() {
110
111
  super([tagType], mp4TagMap);
111
112
  }
113
+ postMap(tag, warnings) {
114
+ switch (tag.id) {
115
+ case 'rate':
116
+ tag.value = {
117
+ source: undefined,
118
+ rating: parseFloat(tag.value) / 100
119
+ };
120
+ break;
121
+ }
122
+ }
112
123
  }
113
124
  //# sourceMappingURL=MP4TagMapper.js.map
@@ -19,8 +19,8 @@ const MPEG4 = {
19
19
  */
20
20
  AudioObjectTypes: [
21
21
  'AAC Main',
22
- 'AAC LC',
23
- 'AAC SSR',
22
+ 'AAC LC', // Low Complexity
23
+ 'AAC SSR', // Scalable Sample Rate
24
24
  'AAC LTP' // Long Term Prediction
25
25
  ],
26
26
  /**
@@ -188,7 +188,7 @@ MpegFrameHeader.sampling_rate_freq_index = {
188
188
  };
189
189
  MpegFrameHeader.samplesInFrameTable = [
190
190
  /* Layer I II III */
191
- [0, 384, 1152, 1152],
191
+ [0, 384, 1152, 1152], // MPEG-1
192
192
  [0, 384, 1152, 576] // MPEG-2(.5
193
193
  ];
194
194
  /**
@@ -1,7 +1,7 @@
1
1
  import { CommonTagMapper } from '../../common/GenericTagMapper.js';
2
2
  import { IRating, ITag } from '../../type.js';
3
3
  export declare class VorbisTagMapper extends CommonTagMapper {
4
- static toRating(email: string, rating: string): IRating;
4
+ static toRating(email: string, rating: string, maxScore: number): IRating;
5
5
  constructor();
6
6
  protected postMap(tag: ITag): void;
7
7
  }
@@ -110,19 +110,23 @@ const vorbisTagMap = {
110
110
  REPLAYGAIN_UNDO: 'replaygain_undo'
111
111
  };
112
112
  export class VorbisTagMapper extends CommonTagMapper {
113
- static toRating(email, rating) {
113
+ static toRating(email, rating, maxScore) {
114
114
  return {
115
115
  source: email ? email.toLowerCase() : email,
116
- rating: parseFloat(rating) * CommonTagMapper.maxRatingScore
116
+ rating: (parseFloat(rating) / maxScore) * CommonTagMapper.maxRatingScore
117
117
  };
118
118
  }
119
119
  constructor() {
120
120
  super(['vorbis'], vorbisTagMap);
121
121
  }
122
122
  postMap(tag) {
123
- if (tag.id.indexOf('RATING:') === 0) {
123
+ if (tag.id === 'RATING') {
124
+ // The way Winamp 5.666 assigns rating
125
+ tag.value = VorbisTagMapper.toRating(undefined, tag.value, 100);
126
+ }
127
+ else if (tag.id.indexOf('RATING:') === 0) {
124
128
  const keys = tag.id.split(':');
125
- tag.value = VorbisTagMapper.toRating(keys[1], tag.value);
129
+ tag.value = VorbisTagMapper.toRating(keys[1], tag.value, 1);
126
130
  tag.id = keys[0];
127
131
  }
128
132
  }
@@ -4,27 +4,27 @@ import { CommonTagMapper } from '../common/GenericTagMapper.js';
4
4
  * Ref: http://owl.phy.queensu.ca/~phil/exiftool/TagNames/RIFF.html#Info
5
5
  */
6
6
  export const riffInfoTagMap = {
7
- IART: 'artist',
8
- ICRD: 'date',
9
- INAM: 'title',
7
+ IART: 'artist', // Artist
8
+ ICRD: 'date', // DateCreated
9
+ INAM: 'title', // Title
10
10
  TITL: 'title',
11
- IPRD: 'album',
11
+ IPRD: 'album', // Product
12
12
  ITRK: 'track',
13
- IPRT: 'track',
14
- COMM: 'comment',
15
- ICMT: 'comment',
13
+ IPRT: 'track', // Additional tag for track index
14
+ COMM: 'comment', // Comments
15
+ ICMT: 'comment', // Country
16
16
  ICNT: 'releasecountry',
17
- GNRE: 'genre',
18
- IWRI: 'writer',
17
+ GNRE: 'genre', // Genre
18
+ IWRI: 'writer', // WrittenBy
19
19
  RATE: 'rating',
20
20
  YEAR: 'year',
21
- ISFT: 'encodedby',
22
- CODE: 'encodedby',
23
- TURL: 'website',
24
- IGNR: 'genre',
25
- IENG: 'engineer',
26
- ITCH: 'technician',
27
- IMED: 'media',
21
+ ISFT: 'encodedby', // Software
22
+ CODE: 'encodedby', // EncodedBy
23
+ TURL: 'website', // URL,
24
+ IGNR: 'genre', // Genre
25
+ IENG: 'engineer', // Engineer
26
+ ITCH: 'technician', // Technician
27
+ IMED: 'media', // Original Media
28
28
  IRPD: 'album' // Product, where the file was intended for
29
29
  };
30
30
  export class RiffInfoTagMapper extends CommonTagMapper {
@@ -63,7 +63,7 @@ WavPack.MetadataIdToken = {
63
63
  len: 1,
64
64
  get: (buf, off) => {
65
65
  return {
66
- functionId: WavPack.getBitAllignedNumber(buf[off], 0, 6),
66
+ functionId: WavPack.getBitAllignedNumber(buf[off], 0, 6), // functionId overlaps with isOptional flag
67
67
  isOptional: WavPack.isBitSet(buf[off], 5),
68
68
  isOddSize: WavPack.isBitSet(buf[off], 6),
69
69
  largeBlock: WavPack.isBitSet(buf[off], 7)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "music-metadata",
3
3
  "description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
4
- "version": "8.1.5",
4
+ "version": "8.3.0",
5
5
  "author": {
6
6
  "name": "Borewit",
7
7
  "url": "https://github.com/Borewit"
@@ -79,7 +79,7 @@
79
79
  "compile-doc": "tsc -p doc-gen",
80
80
  "compile": "npm run compile-src && npm run compile-test && npm run compile-doc",
81
81
  "eslint": "eslint lib/**/*.ts --ignore-pattern lib/**/*.d.ts example/typescript/**/*.ts test/**/*.ts doc-gen/**/*.ts",
82
- "lint-md": "remark -u preset-lint-recommended .",
82
+ "lint-md": "remark -u preset-lint-markdown-style-guide .",
83
83
  "lint": "npm run lint-md && npm run eslint",
84
84
  "test": "mocha",
85
85
  "build": "npm run clean && npm run compile && npm run doc-gen",
@@ -92,39 +92,39 @@
92
92
  "@tokenizer/token": "^0.3.0",
93
93
  "content-type": "^1.0.5",
94
94
  "debug": "^4.3.4",
95
- "file-type": "^18.5.0",
95
+ "file-type": "^18.6.0",
96
96
  "media-typer": "^1.1.0",
97
97
  "strtok3": "^7.0.0",
98
98
  "token-types": "^5.0.1"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@types/chai": "^4.3.9",
102
- "@types/chai-as-promised": "^7.1.7",
103
- "@types/debug": "^4.1.10",
102
+ "@types/chai-as-promised": "^7.1.8",
103
+ "@types/debug": "^4.1.12",
104
104
  "@types/file-type": "^10.9.1",
105
105
  "@types/mocha": "^10.0.3",
106
- "@types/node": "^20.8.10",
106
+ "@types/node": "^20.12.12",
107
107
  "@typescript-eslint/eslint-plugin": "^5.62.0",
108
108
  "@typescript-eslint/parser": "^5.62.0",
109
- "c8": "^8.0.1",
109
+ "c8": "^9.1.0",
110
110
  "chai": "^4.3.10",
111
111
  "chai-as-promised": "^7.1.1",
112
112
  "del-cli": "5.1.0",
113
- "eslint": "^8.52.0",
113
+ "eslint": "^8.57.0",
114
114
  "eslint-config-prettier": "^9.0.0",
115
115
  "eslint-import-resolver-typescript": "^3.6.1",
116
116
  "eslint-plugin-import": "^2.29.0",
117
117
  "eslint-plugin-jsdoc": "^46.8.2",
118
118
  "eslint-plugin-node": "^11.1.0",
119
- "eslint-plugin-unicorn": "^46.0.1",
120
- "mime": "^3.0.0",
119
+ "eslint-plugin-unicorn": "^49.0.0",
120
+ "mime": "^4.0.3",
121
121
  "mocha": "^10.2.0",
122
122
  "npm-run-all": "^4.1.5",
123
- "prettier": "^3.0.3",
123
+ "prettier": "^3.2.5",
124
124
  "remark-cli": "^12.0.0",
125
- "remark-preset-lint-recommended": "^6.1.3",
125
+ "remark-preset-lint-markdown-style-guide": "^5.1.3",
126
126
  "ts-node": "^10.9.1",
127
- "typescript": "^5.2.2"
127
+ "typescript": "^5.4.5"
128
128
  },
129
129
  "engines": {
130
130
  "node": "^14.13.1 || >=16.0.0"