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/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: Normalized rating [0..1] (common.rating[n].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: Normalized rating [0..1] (common.rating[n].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
- const matroska = await this.parseContainer(matroskaDtd.elements, this.tokenizer.fileInfo.size, []);
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.1",
5
- "author": {
6
- "name": "Borewit",
7
- "url": "https://github.com/Borewit"
8
- },
9
- "funding": {
10
- "type": "github",
11
- "url": "https://github.com/sponsors/Borewit"
12
- },
13
- "type": "module",
14
- "exports": {
15
- ".": {
16
- "node": "./lib/index.js",
17
- "default": "./lib/core.js"
18
- }
19
- },
20
- "types": "lib/index.d.ts",
21
- "files": [
22
- "lib/**/*.js",
23
- "lib/**/*.d.ts"
24
- ],
25
- "keywords": [
26
- "music",
27
- "metadata",
28
- "meta",
29
- "audio",
30
- "tag",
31
- "tags",
32
- "duration",
33
- "MusicBrainz",
34
- "Discogs",
35
- "Picard",
36
- "ID3",
37
- "ID3v1",
38
- "ID3v2",
39
- "m4a",
40
- "m4b",
41
- "mp3",
42
- "mp4",
43
- "Vorbis",
44
- "ogg",
45
- "flac",
46
- "Matroska",
47
- "WebM",
48
- "EBML",
49
- "asf",
50
- "wma",
51
- "wmv",
52
- "ape",
53
- "MonkeyAudio",
54
- "aiff",
55
- "wav",
56
- "WavPack",
57
- "Opus",
58
- "speex",
59
- "musepack",
60
- "mpc",
61
- "dsd",
62
- "dsf",
63
- "mpc",
64
- "dff",
65
- "dsdiff",
66
- "aac",
67
- "adts",
68
- "length",
69
- "chapter",
70
- "info",
71
- "parse",
72
- "parser",
73
- "bwf"
74
- ],
75
- "scripts": {
76
- "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",
77
- "compile-src": "tsc -p lib",
78
- "compile-test": "tsc -p test",
79
- "compile-doc": "tsc -p doc-gen",
80
- "compile": "npm run compile-src && npm run compile-test && npm run compile-doc",
81
- "eslint": "npx eslint lib/**/*.ts --ignore-pattern lib/**/*.d.ts example/typescript/**/*.ts test/**/*.ts doc-gen/**/*.ts",
82
- "lint-md": "remark -u preset-lint-markdown-style-guide .",
83
- "lint": "npm run lint-md && npm run eslint",
84
- "test": "mocha",
85
- "build": "npm run clean && npm run compile && npm run doc-gen",
86
- "start": "npm-run-all compile lint cover-test",
87
- "test-coverage": "c8 npm run test",
88
- "send-codacy": "c8 report --reporter=text-lcov | codacy-coverage",
89
- "doc-gen": "node doc-gen/gen.js"
90
- },
91
- "dependencies": {
92
- "@tokenizer/token": "^0.3.0",
93
- "content-type": "^1.0.5",
94
- "debug": "^4.3.4",
95
- "file-type": "^19.1.1",
96
- "media-typer": "^1.1.0",
97
- "strtok3": "^7.1.0",
98
- "token-types": "^6.0.0",
99
- "uint8array-extras": "^1.3.0"
100
- },
101
- "devDependencies": {
102
- "@types/chai": "^4.3.16",
103
- "@types/chai-as-promised": "^7.1.8",
104
- "@types/debug": "^4.1.12",
105
- "@types/file-type": "^10.9.1",
106
- "@types/mocha": "^10.0.7",
107
- "@types/node": "^20.14.10",
108
- "@typescript-eslint/eslint-plugin": "^7.16.0",
109
- "@typescript-eslint/parser": "^7.16.0",
110
- "c8": "^10.1.2",
111
- "chai": "^5.1.1",
112
- "chai-as-promised": "^8.0.0",
113
- "del-cli": "^5.1.0",
114
- "eslint": "^8.57.0",
115
- "eslint-config-prettier": "^9.1.0",
116
- "eslint-import-resolver-typescript": "^3.6.1",
117
- "eslint-plugin-import": "^2.29.1",
118
- "eslint-plugin-jsdoc": "^48.7.0",
119
- "eslint-plugin-node": "^11.1.0",
120
- "eslint-plugin-unicorn": "^54.0.0",
121
- "mime": "^4.0.4",
122
- "mocha": "^10.6.0",
123
- "npm-run-all": "^4.1.5",
124
- "prettier": "^3.3.2",
125
- "remark-cli": "^12.0.1",
126
- "remark-preset-lint-markdown-style-guide": "^6.0.0",
127
- "ts-node": "^10.9.2",
128
- "typescript": "^5.5.3"
129
- },
130
- "engines": {
131
- "node": ">=16.0.0"
132
- },
133
- "repository": {
134
- "type": "git",
135
- "url": "git+https://github.com/borewit/music-metadata.git"
136
- },
137
- "license": "MIT",
138
- "bugs": {
139
- "url": "https://github.com/Borewit/music-metadata/issues"
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
+ }