music-metadata 7.13.5 → 7.14.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/lib/mp4/MP4Parser.js
CHANGED
|
@@ -344,14 +344,11 @@ class MP4Parser extends BasicParser_1.BasicParser {
|
|
|
344
344
|
case 'data': // value atom
|
|
345
345
|
return this.parseValueAtom(tagKey, child);
|
|
346
346
|
case 'name': // name atom (optional)
|
|
347
|
+
case 'mean':
|
|
348
|
+
case 'rate':
|
|
347
349
|
const name = await this.tokenizer.readToken(new AtomToken.NameAtom(payLoadLength));
|
|
348
350
|
tagKey += ':' + name.name;
|
|
349
351
|
break;
|
|
350
|
-
case 'mean': // name atom (optional)
|
|
351
|
-
const mean = await this.tokenizer.readToken(new AtomToken.NameAtom(payLoadLength));
|
|
352
|
-
// console.log(" %s[%s] = %s", tagKey, header.name, mean.name);
|
|
353
|
-
tagKey += ':' + mean.name;
|
|
354
|
-
break;
|
|
355
352
|
default:
|
|
356
353
|
const dataAtom = await this.tokenizer.readToken(new Token.BufferType(payLoadLength));
|
|
357
354
|
this.addWarning('Unsupported meta-item: ' + tagKey + '[' + child.header.name + '] => value=' + dataAtom.toString('hex') + ' ascii=' + dataAtom.toString('ascii'));
|
|
@@ -381,9 +378,12 @@ class MP4Parser extends BasicParser_1.BasicParser {
|
|
|
381
378
|
// console.log(" %s[data] = %s", tagKey, genreStr);
|
|
382
379
|
this.addTag(tagKey, genreStr);
|
|
383
380
|
break;
|
|
381
|
+
case 'rate':
|
|
382
|
+
const rate = dataAtom.value.toString('ascii');
|
|
383
|
+
this.addTag(tagKey, rate);
|
|
384
|
+
break;
|
|
384
385
|
default:
|
|
385
|
-
|
|
386
|
-
// header.name, header.length, dataAtom.type.set, dataAtom.type.type, dataAtom.locale, dataAtom.value.toString('hex'), dataAtom.value.toString('ascii'));
|
|
386
|
+
debug('unknown proprietary value type for: ' + metaAtom.atomPath);
|
|
387
387
|
}
|
|
388
388
|
break;
|
|
389
389
|
case 1: // UTF-8: Without any count or NULL terminator
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { CaseInsensitiveTagMap } from '../common/CaseInsensitiveTagMap';
|
|
2
|
+
import { ITag } from "../type";
|
|
3
|
+
import { INativeMetadataCollector } from "../common/MetadataCollector";
|
|
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
|
}
|
package/lib/mp4/MP4TagMapper.js
CHANGED
|
@@ -104,13 +104,24 @@ const mp4TagMap = {
|
|
|
104
104
|
hdvd: 'hdVideo',
|
|
105
105
|
keyw: 'keywords',
|
|
106
106
|
shwm: 'showMovement',
|
|
107
|
-
stik: 'stik'
|
|
107
|
+
stik: 'stik',
|
|
108
|
+
rate: 'rating'
|
|
108
109
|
};
|
|
109
110
|
exports.tagType = 'iTunes';
|
|
110
111
|
class MP4TagMapper extends CaseInsensitiveTagMap_1.CaseInsensitiveTagMap {
|
|
111
112
|
constructor() {
|
|
112
113
|
super([exports.tagType], mp4TagMap);
|
|
113
114
|
}
|
|
115
|
+
postMap(tag, warnings) {
|
|
116
|
+
switch (tag.id) {
|
|
117
|
+
case 'rate':
|
|
118
|
+
tag.value = {
|
|
119
|
+
source: undefined,
|
|
120
|
+
rating: parseFloat(tag.value) / 100
|
|
121
|
+
};
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
114
125
|
}
|
|
115
126
|
exports.MP4TagMapper = MP4TagMapper;
|
|
116
127
|
//# sourceMappingURL=MP4TagMapper.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommonTagMapper } from '../../common/GenericTagMapper';
|
|
2
2
|
import { IRating, ITag } from '../../type';
|
|
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
|
}
|
|
@@ -112,19 +112,23 @@ const vorbisTagMap = {
|
|
|
112
112
|
REPLAYGAIN_UNDO: 'replaygain_undo'
|
|
113
113
|
};
|
|
114
114
|
class VorbisTagMapper extends GenericTagMapper_1.CommonTagMapper {
|
|
115
|
-
static toRating(email, rating) {
|
|
115
|
+
static toRating(email, rating, maxScore) {
|
|
116
116
|
return {
|
|
117
117
|
source: email ? email.toLowerCase() : email,
|
|
118
|
-
rating: parseFloat(rating) * GenericTagMapper_1.CommonTagMapper.maxRatingScore
|
|
118
|
+
rating: (parseFloat(rating) / maxScore) * GenericTagMapper_1.CommonTagMapper.maxRatingScore
|
|
119
119
|
};
|
|
120
120
|
}
|
|
121
121
|
constructor() {
|
|
122
122
|
super(['vorbis'], vorbisTagMap);
|
|
123
123
|
}
|
|
124
124
|
postMap(tag) {
|
|
125
|
-
if (tag.id
|
|
125
|
+
if (tag.id === 'RATING') {
|
|
126
|
+
// The way Winamp 5.666 assigns rating
|
|
127
|
+
tag.value = VorbisTagMapper.toRating(undefined, tag.value, 100);
|
|
128
|
+
}
|
|
129
|
+
else if (tag.id.indexOf('RATING:') === 0) {
|
|
126
130
|
const keys = tag.id.split(':');
|
|
127
|
-
tag.value = VorbisTagMapper.toRating(keys[1], tag.value);
|
|
131
|
+
tag.value = VorbisTagMapper.toRating(keys[1], tag.value, 1);
|
|
128
132
|
tag.id = keys[0];
|
|
129
133
|
}
|
|
130
134
|
}
|
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": "7.
|
|
4
|
+
"version": "7.14.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Borewit",
|
|
7
7
|
"url": "https://github.com/Borewit"
|
|
@@ -103,13 +103,13 @@
|
|
|
103
103
|
"chai": "^4.3.10",
|
|
104
104
|
"chai-as-promised": "^7.1.1",
|
|
105
105
|
"del-cli": "5.1.0",
|
|
106
|
-
"eslint": "^8.
|
|
106
|
+
"eslint": "^8.53.0",
|
|
107
107
|
"eslint-config-prettier": "^9.0.0",
|
|
108
108
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
109
109
|
"eslint-plugin-import": "^2.29.0",
|
|
110
110
|
"eslint-plugin-jsdoc": "^46.8.2",
|
|
111
111
|
"eslint-plugin-node": "^11.1.0",
|
|
112
|
-
"eslint-plugin-unicorn": "^
|
|
112
|
+
"eslint-plugin-unicorn": "^49.0.0",
|
|
113
113
|
"mime": "^3.0.0",
|
|
114
114
|
"mocha": "^9.2.2",
|
|
115
115
|
"npm-run-all": "^4.1.5",
|