music-metadata 9.0.1 → 9.0.3
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/LICENSE.txt +9 -9
- package/README.md +519 -519
- package/lib/core.d.ts +4 -1
- package/lib/core.js +6 -3
- package/lib/index.d.ts +4 -1
- package/lib/index.js +5 -2
- package/lib/matroska/MatroskaParser.js +3 -1
- package/package.json +148 -141
package/lib/core.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primary entry point, Node.js specific entry point is index.ts
|
|
3
|
+
*/
|
|
1
4
|
import * as strtok3 from 'strtok3';
|
|
2
5
|
import type { IAudioMetadata, INativeTagDict, IOptions, IPicture, IPrivateOptions, IRandomReader, ITag } from './type.js';
|
|
3
6
|
import type { ReadableStream as NodeReadableStream } from 'node:stream/web';
|
|
@@ -43,7 +46,7 @@ export declare function parseFromTokenizer(tokenizer: strtok3.ITokenizer, option
|
|
|
43
46
|
export declare function orderTags(nativeTags: ITag[]): INativeTagDict;
|
|
44
47
|
/**
|
|
45
48
|
* Convert rating to 1-5 star rating
|
|
46
|
-
* @param rating
|
|
49
|
+
* @param rating Normalized rating [0..1] (common.rating[n].rating)
|
|
47
50
|
* @returns Number of stars: 1, 2, 3, 4 or 5 stars
|
|
48
51
|
*/
|
|
49
52
|
export declare function ratingToStars(rating: number): number;
|
package/lib/core.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Primary entry point, Node.js specific entry point is index.ts
|
|
3
|
+
*/
|
|
1
4
|
import * as strtok3 from 'strtok3';
|
|
2
5
|
import { ParserFactory } from './ParserFactory.js';
|
|
3
6
|
import { RandomUint8ArrayReader } from './common/RandomUint8ArrayReader.js';
|
|
@@ -26,7 +29,7 @@ export async function parseBlob(blob, options = {}) {
|
|
|
26
29
|
* @returns Metadata
|
|
27
30
|
*/
|
|
28
31
|
export function parseWebStream(webStream, fileInfo, options = {}) {
|
|
29
|
-
return parseFromTokenizer(strtok3.fromWebStream(webStream, typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo), options);
|
|
32
|
+
return parseFromTokenizer(strtok3.fromWebStream(webStream, { fileInfo: typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo }), options);
|
|
30
33
|
}
|
|
31
34
|
/**
|
|
32
35
|
* Parse audio from Node Buffer
|
|
@@ -39,7 +42,7 @@ export function parseWebStream(webStream, fileInfo, options = {}) {
|
|
|
39
42
|
export async function parseBuffer(uint8Array, fileInfo, options = {}) {
|
|
40
43
|
const bufferReader = new RandomUint8ArrayReader(uint8Array);
|
|
41
44
|
await scanAppendingHeaders(bufferReader, options);
|
|
42
|
-
const tokenizer = strtok3.fromBuffer(uint8Array, typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo);
|
|
45
|
+
const tokenizer = strtok3.fromBuffer(uint8Array, { fileInfo: typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo });
|
|
43
46
|
return parseFromTokenizer(tokenizer, options);
|
|
44
47
|
}
|
|
45
48
|
/**
|
|
@@ -65,7 +68,7 @@ export function orderTags(nativeTags) {
|
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
70
|
* Convert rating to 1-5 star rating
|
|
68
|
-
* @param rating
|
|
71
|
+
* @param rating Normalized rating [0..1] (common.rating[n].rating)
|
|
69
72
|
* @returns Number of stars: 1, 2, 3, 4 or 5 stars
|
|
70
73
|
*/
|
|
71
74
|
export function ratingToStars(rating) {
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js specific entry point.
|
|
3
|
+
*/
|
|
1
4
|
import * as Stream from 'stream';
|
|
2
5
|
import * as strtok3 from 'strtok3';
|
|
3
6
|
import { IAudioMetadata, IOptions } from './type.js';
|
|
4
7
|
export { IAudioMetadata, IOptions, ITag, INativeTagDict, ICommonTagsResult, IFormat, IPicture, IRatio, IChapter } from './type.js';
|
|
5
|
-
export { parseFromTokenizer, parseBuffer, parseBlob, selectCover, orderTags, ratingToStars, IFileInfo } from './core.js';
|
|
8
|
+
export { parseFromTokenizer, parseBuffer, parseBlob, parseWebStream, selectCover, orderTags, ratingToStars, IFileInfo } from './core.js';
|
|
6
9
|
/**
|
|
7
10
|
* Parse audio from Node Stream.Readable
|
|
8
11
|
* @param stream - Stream to read the audio track from
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js specific entry point.
|
|
3
|
+
*/
|
|
1
4
|
import * as strtok3 from 'strtok3';
|
|
2
5
|
import initDebug from 'debug';
|
|
3
6
|
import { parseFromTokenizer, scanAppendingHeaders } from './core.js';
|
|
4
7
|
import { ParserFactory } from './ParserFactory.js';
|
|
5
8
|
import { RandomFileReader } from './common/RandomFileReader.js';
|
|
6
|
-
export { parseFromTokenizer, parseBuffer, parseBlob, selectCover, orderTags, ratingToStars } from './core.js';
|
|
9
|
+
export { parseFromTokenizer, parseBuffer, parseBlob, parseWebStream, selectCover, orderTags, ratingToStars } from './core.js';
|
|
7
10
|
const debug = initDebug('music-metadata:parser');
|
|
8
11
|
/**
|
|
9
12
|
* Parse audio from Node Stream.Readable
|
|
@@ -13,7 +16,7 @@ const debug = initDebug('music-metadata:parser');
|
|
|
13
16
|
* @returns Metadata
|
|
14
17
|
*/
|
|
15
18
|
export async function parseStream(stream, fileInfo, options = {}) {
|
|
16
|
-
const tokenizer = await strtok3.fromStream(stream, typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo);
|
|
19
|
+
const tokenizer = await strtok3.fromStream(stream, { fileInfo: typeof fileInfo === 'string' ? { mimeType: fileInfo } : fileInfo });
|
|
17
20
|
return parseFromTokenizer(tokenizer, options);
|
|
18
21
|
}
|
|
19
22
|
/**
|
|
@@ -37,7 +37,9 @@ export class MatroskaParser extends BasicParser {
|
|
|
37
37
|
return this;
|
|
38
38
|
}
|
|
39
39
|
async parse() {
|
|
40
|
-
|
|
40
|
+
var _a;
|
|
41
|
+
const containerSize = (_a = this.tokenizer.fileInfo.size) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER;
|
|
42
|
+
const matroska = await this.parseContainer(matroskaDtd.elements, containerSize, []);
|
|
41
43
|
this.metadata.setFormat('container', `EBML/${matroska.ebml.docType}`);
|
|
42
44
|
if (matroska.segment) {
|
|
43
45
|
const info = matroska.segment.info;
|
package/package.json
CHANGED
|
@@ -1,141 +1,148 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "music-metadata",
|
|
3
|
-
"description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
|
|
4
|
-
"version": "9.0.
|
|
5
|
-
"author": {
|
|
6
|
-
"name": "Borewit",
|
|
7
|
-
"url": "https://github.com/Borewit"
|
|
8
|
-
},
|
|
9
|
-
"funding":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"test": "
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
"token
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"@
|
|
109
|
-
"@
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
"eslint": "^
|
|
115
|
-
"eslint
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
"eslint
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
"
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "music-metadata",
|
|
3
|
+
"description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
|
|
4
|
+
"version": "9.0.3",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Borewit",
|
|
7
|
+
"url": "https://github.com/Borewit"
|
|
8
|
+
},
|
|
9
|
+
"funding": [
|
|
10
|
+
{
|
|
11
|
+
"type": "github",
|
|
12
|
+
"url": "https://github.com/sponsors/Borewit"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"type": "buymeacoffee",
|
|
16
|
+
"url": "https://buymeacoffee.com/borewit"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"node": "./lib/index.js",
|
|
23
|
+
"default": "./lib/core.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"types": "lib/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"lib/**/*.js",
|
|
29
|
+
"lib/**/*.d.ts"
|
|
30
|
+
],
|
|
31
|
+
"keywords": [
|
|
32
|
+
"music",
|
|
33
|
+
"metadata",
|
|
34
|
+
"meta",
|
|
35
|
+
"audio",
|
|
36
|
+
"tag",
|
|
37
|
+
"tags",
|
|
38
|
+
"duration",
|
|
39
|
+
"MusicBrainz",
|
|
40
|
+
"Discogs",
|
|
41
|
+
"Picard",
|
|
42
|
+
"ID3",
|
|
43
|
+
"ID3v1",
|
|
44
|
+
"ID3v2",
|
|
45
|
+
"m4a",
|
|
46
|
+
"m4b",
|
|
47
|
+
"mp3",
|
|
48
|
+
"mp4",
|
|
49
|
+
"Vorbis",
|
|
50
|
+
"ogg",
|
|
51
|
+
"flac",
|
|
52
|
+
"Matroska",
|
|
53
|
+
"WebM",
|
|
54
|
+
"EBML",
|
|
55
|
+
"asf",
|
|
56
|
+
"wma",
|
|
57
|
+
"wmv",
|
|
58
|
+
"ape",
|
|
59
|
+
"MonkeyAudio",
|
|
60
|
+
"aiff",
|
|
61
|
+
"wav",
|
|
62
|
+
"WavPack",
|
|
63
|
+
"Opus",
|
|
64
|
+
"speex",
|
|
65
|
+
"musepack",
|
|
66
|
+
"mpc",
|
|
67
|
+
"dsd",
|
|
68
|
+
"dsf",
|
|
69
|
+
"mpc",
|
|
70
|
+
"dff",
|
|
71
|
+
"dsdiff",
|
|
72
|
+
"aac",
|
|
73
|
+
"adts",
|
|
74
|
+
"length",
|
|
75
|
+
"chapter",
|
|
76
|
+
"info",
|
|
77
|
+
"parse",
|
|
78
|
+
"parser",
|
|
79
|
+
"bwf"
|
|
80
|
+
],
|
|
81
|
+
"scripts": {
|
|
82
|
+
"clean": "del-cli 'lib/**/*.js' 'lib/**/*.js.map' 'lib/**/*.d.ts' 'src/**/*.d.ts' 'test/**/*.js' 'test/**/*.js.map' 'test/**/*.js' 'test/**/*.js.map' 'doc-gen/**/*.js' 'doc-gen/**/*.js.map'",
|
|
83
|
+
"compile-src": "tsc -p lib",
|
|
84
|
+
"compile-test": "tsc -p test",
|
|
85
|
+
"compile-doc": "tsc -p doc-gen",
|
|
86
|
+
"compile": "npm run compile-src && npm run compile-test && npm run compile-doc",
|
|
87
|
+
"eslint": "eslint lib/**/*.ts --ignore-pattern lib/**/*.d.ts example/typescript/**/*.ts test/**/*.ts doc-gen/**/*.ts",
|
|
88
|
+
"lint-md": "remark -u preset-lint-markdown-style-guide .",
|
|
89
|
+
"lint": "npm run lint-md && npm run eslint",
|
|
90
|
+
"test": "mocha",
|
|
91
|
+
"build": "npm run clean && npm run compile && npm run doc-gen",
|
|
92
|
+
"start": "npm-run-all compile lint cover-test",
|
|
93
|
+
"test-coverage": "c8 npm run test",
|
|
94
|
+
"send-codacy": "c8 report --reporter=text-lcov | codacy-coverage",
|
|
95
|
+
"doc-gen": "node doc-gen/gen.js"
|
|
96
|
+
},
|
|
97
|
+
"dependencies": {
|
|
98
|
+
"@tokenizer/token": "^0.3.0",
|
|
99
|
+
"content-type": "^1.0.5",
|
|
100
|
+
"debug": "^4.3.4",
|
|
101
|
+
"file-type": "^19.2.0",
|
|
102
|
+
"media-typer": "^1.1.0",
|
|
103
|
+
"strtok3": "^8.0.0",
|
|
104
|
+
"token-types": "^6.0.0",
|
|
105
|
+
"uint8array-extras": "^1.4.0"
|
|
106
|
+
},
|
|
107
|
+
"devDependencies": {
|
|
108
|
+
"@types/chai": "^4.3.16",
|
|
109
|
+
"@types/chai-as-promised": "^7.1.8",
|
|
110
|
+
"@types/debug": "^4.1.12",
|
|
111
|
+
"@types/file-type": "^10.9.1",
|
|
112
|
+
"@types/mocha": "^10.0.7",
|
|
113
|
+
"@types/node": "^20.14.11",
|
|
114
|
+
"@typescript-eslint/eslint-plugin": "^7.16.0",
|
|
115
|
+
"@typescript-eslint/parser": "^7.16.0",
|
|
116
|
+
"c8": "^10.1.2",
|
|
117
|
+
"chai": "^5.1.1",
|
|
118
|
+
"chai-as-promised": "^8.0.0",
|
|
119
|
+
"del-cli": "^5.1.0",
|
|
120
|
+
"eslint": "^8.57.0",
|
|
121
|
+
"eslint-config-prettier": "^9.1.0",
|
|
122
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
123
|
+
"eslint-plugin-import": "^2.29.1",
|
|
124
|
+
"eslint-plugin-jsdoc": "^48.7.0",
|
|
125
|
+
"eslint-plugin-node": "^11.1.0",
|
|
126
|
+
"eslint-plugin-unicorn": "^54.0.0",
|
|
127
|
+
"mime": "^4.0.4",
|
|
128
|
+
"mocha": "^10.6.0",
|
|
129
|
+
"npm-run-all": "^4.1.5",
|
|
130
|
+
"prettier": "^3.3.3",
|
|
131
|
+
"remark-cli": "^12.0.1",
|
|
132
|
+
"remark-preset-lint-markdown-style-guide": "^6.0.0",
|
|
133
|
+
"ts-node": "^10.9.2",
|
|
134
|
+
"typescript": "^5.5.3"
|
|
135
|
+
},
|
|
136
|
+
"engines": {
|
|
137
|
+
"node": ">=16.0.0"
|
|
138
|
+
},
|
|
139
|
+
"repository": {
|
|
140
|
+
"type": "git",
|
|
141
|
+
"url": "git+https://github.com/borewit/music-metadata.git"
|
|
142
|
+
},
|
|
143
|
+
"license": "MIT",
|
|
144
|
+
"bugs": {
|
|
145
|
+
"url": "https://github.com/Borewit/music-metadata/issues"
|
|
146
|
+
},
|
|
147
|
+
"packageManager": "yarn@4.3.1"
|
|
148
|
+
}
|