music-metadata 8.1.5 → 8.2.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
@@ -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
  }
@@ -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
@@ -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
  }
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.2.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,7 +92,7 @@
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"
@@ -100,7 +100,7 @@
100
100
  "devDependencies": {
101
101
  "@types/chai": "^4.3.9",
102
102
  "@types/chai-as-promised": "^7.1.7",
103
- "@types/debug": "^4.1.10",
103
+ "@types/debug": "^4.1.11",
104
104
  "@types/file-type": "^10.9.1",
105
105
  "@types/mocha": "^10.0.3",
106
106
  "@types/node": "^20.8.10",
@@ -110,19 +110,19 @@
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.53.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",
119
+ "eslint-plugin-unicorn": "^49.0.0",
120
120
  "mime": "^3.0.0",
121
121
  "mocha": "^10.2.0",
122
122
  "npm-run-all": "^4.1.5",
123
123
  "prettier": "^3.0.3",
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
127
  "typescript": "^5.2.2"
128
128
  },