music-metadata 7.13.3 → 7.13.5

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.
@@ -121,8 +121,8 @@ class FilePropertiesObject extends State {
121
121
  };
122
122
  }
123
123
  }
124
- exports.FilePropertiesObject = FilePropertiesObject;
125
124
  FilePropertiesObject.guid = GUID_1.default.FilePropertiesObject;
125
+ exports.FilePropertiesObject = FilePropertiesObject;
126
126
  /**
127
127
  * Token for: 3.3 Stream Properties Object (mandatory, one per stream)
128
128
  * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_3
@@ -139,8 +139,8 @@ class StreamPropertiesObject extends State {
139
139
  };
140
140
  }
141
141
  }
142
- exports.StreamPropertiesObject = StreamPropertiesObject;
143
142
  StreamPropertiesObject.guid = GUID_1.default.StreamPropertiesObject;
143
+ exports.StreamPropertiesObject = StreamPropertiesObject;
144
144
  /**
145
145
  * 3.4: Header Extension Object (mandatory, one only)
146
146
  * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_4
@@ -157,8 +157,8 @@ class HeaderExtensionObject {
157
157
  };
158
158
  }
159
159
  }
160
- exports.HeaderExtensionObject = HeaderExtensionObject;
161
160
  HeaderExtensionObject.guid = GUID_1.default.HeaderExtensionObject;
161
+ exports.HeaderExtensionObject = HeaderExtensionObject;
162
162
  /**
163
163
  * 3.5: The Codec List Object provides user-friendly information about the codecs and formats used to encode the content found in the ASF file.
164
164
  * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_5
@@ -233,9 +233,9 @@ class ContentDescriptionObjectState extends State {
233
233
  return tags;
234
234
  }
235
235
  }
236
- exports.ContentDescriptionObjectState = ContentDescriptionObjectState;
237
236
  ContentDescriptionObjectState.guid = GUID_1.default.ContentDescriptionObject;
238
237
  ContentDescriptionObjectState.contentDescTags = ['Title', 'Author', 'Copyright', 'Description', 'Rating'];
238
+ exports.ContentDescriptionObjectState = ContentDescriptionObjectState;
239
239
  /**
240
240
  * 3.11 Extended Content Description Object (optional, one only)
241
241
  * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/03_asf_top_level_header_object.html#3_11
@@ -264,8 +264,8 @@ class ExtendedContentDescriptionObjectState extends State {
264
264
  return tags;
265
265
  }
266
266
  }
267
- exports.ExtendedContentDescriptionObjectState = ExtendedContentDescriptionObjectState;
268
267
  ExtendedContentDescriptionObjectState.guid = GUID_1.default.ExtendedContentDescriptionObject;
268
+ exports.ExtendedContentDescriptionObjectState = ExtendedContentDescriptionObjectState;
269
269
  /**
270
270
  * 4.1 Extended Stream Properties Object (optional, 1 per media stream)
271
271
  * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/04_objects_in_the_asf_header_extension_object.html#4_1
@@ -301,8 +301,8 @@ class ExtendedStreamPropertiesObjectState extends State {
301
301
  };
302
302
  }
303
303
  }
304
- exports.ExtendedStreamPropertiesObjectState = ExtendedStreamPropertiesObjectState;
305
304
  ExtendedStreamPropertiesObjectState.guid = GUID_1.default.ExtendedStreamPropertiesObject;
305
+ exports.ExtendedStreamPropertiesObjectState = ExtendedStreamPropertiesObjectState;
306
306
  /**
307
307
  * 4.7 Metadata Object (optional, 0 or 1)
308
308
  * Ref: http://drang.s4.xrea.com/program/tips/id3tag/wmp/04_objects_in_the_asf_header_extension_object.html#4_7
@@ -333,16 +333,16 @@ class MetadataObjectState extends State {
333
333
  return tags;
334
334
  }
335
335
  }
336
- exports.MetadataObjectState = MetadataObjectState;
337
336
  MetadataObjectState.guid = GUID_1.default.MetadataObject;
337
+ exports.MetadataObjectState = MetadataObjectState;
338
338
  // 4.8 Metadata Library Object (optional, 0 or 1)
339
339
  class MetadataLibraryObjectState extends MetadataObjectState {
340
340
  constructor(header) {
341
341
  super(header);
342
342
  }
343
343
  }
344
- exports.MetadataLibraryObjectState = MetadataLibraryObjectState;
345
344
  MetadataLibraryObjectState.guid = GUID_1.default.MetadataLibraryObject;
345
+ exports.MetadataLibraryObjectState = MetadataLibraryObjectState;
346
346
  /**
347
347
  * Ref: https://msdn.microsoft.com/en-us/library/windows/desktop/dd757977(v=vs.85).aspx
348
348
  */
@@ -26,7 +26,6 @@ class AsfUtil {
26
26
  return buf.readUInt16LE(offset);
27
27
  }
28
28
  }
29
- exports.AsfUtil = AsfUtil;
30
29
  AsfUtil.attributeParsers = [
31
30
  AsfUtil.parseUnicodeAttr,
32
31
  AsfUtil.parseByteArrayAttr,
@@ -36,3 +35,4 @@ AsfUtil.attributeParsers = [
36
35
  AsfUtil.parseWordAttr,
37
36
  AsfUtil.parseByteArrayAttr
38
37
  ];
38
+ exports.AsfUtil = AsfUtil;
package/lib/asf/GUID.js CHANGED
@@ -71,7 +71,6 @@ class GUID {
71
71
  return GUID.encode(this.str);
72
72
  }
73
73
  }
74
- exports.default = GUID;
75
74
  // 10.1 Top-level ASF object GUIDs
76
75
  GUID.HeaderObject = new GUID("75B22630-668E-11CF-A6D9-00AA0062CE6C");
77
76
  GUID.DataObject = new GUID("75B22636-668E-11CF-A6D9-00AA0062CE6C");
@@ -119,3 +118,4 @@ GUID.Degradable_JPEG_Media = new GUID("35907DE0-E415-11CF-A917-00805F5C442B");
119
118
  GUID.FileTransferMedia = new GUID("91BD222C-F21C-497A-8B6D-5AA86BFC0185");
120
119
  GUID.BinaryMedia = new GUID("3AFB65E2-47EF-40F2-AC2C-70A90D71D343");
121
120
  GUID.ASF_Index_Placeholder_Object = new GUID("D9AADE20-7C17-4F9C-BC28-8555DD98E2A2");
121
+ exports.default = GUID;
@@ -51,6 +51,6 @@ class CommonTagMapper {
51
51
  return;
52
52
  }
53
53
  }
54
- exports.CommonTagMapper = CommonTagMapper;
55
54
  CommonTagMapper.maxRatingScore = 1;
55
+ exports.CommonTagMapper = CommonTagMapper;
56
56
  //# sourceMappingURL=GenericTagMapper.js.map
@@ -178,7 +178,7 @@ class MP4Parser extends BasicParser_1.BasicParser {
178
178
  this.getTrackDescription().sampleToChunkTable = stsc.entries;
179
179
  },
180
180
  /**
181
- * time to sample
181
+ * time-to-sample table
182
182
  */
183
183
  stts: async (len) => {
184
184
  const stts = await this.tokenizer.readToken(new AtomToken.SttsAtom(len));
@@ -275,13 +275,22 @@ class MP4Parser extends BasicParser_1.BasicParser {
275
275
  });
276
276
  if (audioTracks.length >= 1) {
277
277
  const audioTrack = audioTracks[0];
278
- const duration = audioTrack.duration / audioTrack.timeScale;
279
- this.metadata.setFormat('duration', duration); // calculate duration in seconds
278
+ if (audioTrack.timeScale > 0) {
279
+ const duration = audioTrack.duration / audioTrack.timeScale; // calculate duration in seconds
280
+ this.metadata.setFormat('duration', duration);
281
+ }
280
282
  const ssd = audioTrack.soundSampleDescription[0];
281
283
  if (ssd.description) {
282
284
  this.metadata.setFormat('sampleRate', ssd.description.sampleRate);
283
285
  this.metadata.setFormat('bitsPerSample', ssd.description.sampleSize);
284
286
  this.metadata.setFormat('numberOfChannels', ssd.description.numAudioChannels);
287
+ if (audioTrack.timeScale === 0 && audioTrack.timeToSampleTable.length > 0) {
288
+ const totalSampleSize = audioTrack.timeToSampleTable
289
+ .map(ttstEntry => ttstEntry.count * ttstEntry.duration)
290
+ .reduce((total, sampleSize) => total + sampleSize);
291
+ const duration = totalSampleSize / ssd.description.sampleRate;
292
+ this.metadata.setFormat('duration', duration);
293
+ }
285
294
  }
286
295
  const encoderInfo = encoderDict[ssd.dataFormat];
287
296
  if (encoderInfo) {
@@ -103,7 +103,6 @@ class OggParser extends BasicParser_1.BasicParser {
103
103
  }
104
104
  }
105
105
  }
106
- exports.OggParser = OggParser;
107
106
  OggParser.Header = {
108
107
  len: 27,
109
108
  get: (buf, off) => {
@@ -124,3 +123,4 @@ OggParser.Header = {
124
123
  };
125
124
  }
126
125
  };
126
+ exports.OggParser = OggParser;
@@ -13,6 +13,7 @@ exports.riffInfoTagMap = {
13
13
  TITL: 'title',
14
14
  IPRD: 'album',
15
15
  ITRK: 'track',
16
+ IPRT: 'track',
16
17
  COMM: 'comment',
17
18
  ICMT: 'comment',
18
19
  ICNT: 'releasecountry',
@@ -13,7 +13,6 @@ class WavPack {
13
13
  return (flags >>> bitOffset) & (0xffffffff >>> (32 - len));
14
14
  }
15
15
  }
16
- exports.WavPack = WavPack;
17
16
  /**
18
17
  * WavPack Block Header
19
18
  *
@@ -74,3 +73,4 @@ WavPack.MetadataIdToken = {
74
73
  };
75
74
  }
76
75
  };
76
+ exports.WavPack = WavPack;
package/package.json CHANGED
@@ -1,150 +1,149 @@
1
- {
2
- "name": "music-metadata",
3
- "description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
4
- "version": "7.13.3",
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
- "keywords": [
14
- "music",
15
- "metadata",
16
- "meta",
17
- "audio",
18
- "tag",
19
- "tags",
20
- "duration",
21
- "MusicBrainz",
22
- "Discogs",
23
- "Picard",
24
- "ID3",
25
- "ID3v1",
26
- "ID3v2",
27
- "m4a",
28
- "m4b",
29
- "mp3",
30
- "mp4",
31
- "Vorbis",
32
- "ogg",
33
- "flac",
34
- "Matroska",
35
- "WebM",
36
- "EBML",
37
- "asf",
38
- "wma",
39
- "wmv",
40
- "ape",
41
- "MonkeyAudio",
42
- "aiff",
43
- "wav",
44
- "WavPack",
45
- "Opus",
46
- "speex",
47
- "musepack",
48
- "mpc",
49
- "dsd",
50
- "dsf",
51
- "mpc",
52
- "dff",
53
- "dsdiff",
54
- "aac",
55
- "adts",
56
- "length",
57
- "chapter",
58
- "info",
59
- "parse",
60
- "parser",
61
- "bwf"
62
- ],
63
- "main": "lib/index.js",
64
- "types": "lib/index.d.ts",
65
- "files": [
66
- "lib/**/*.js",
67
- "lib/**/*.d.ts"
68
- ],
69
- "scripts": {
70
- "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",
71
- "compile-src": "tsc -p lib",
72
- "compile-test": "tsc -p test",
73
- "compile-doc": "tsc -p doc-gen",
74
- "compile": "npm run compile-src && npm run compile-test && npm run compile-doc",
75
- "eslint": "eslint lib/**/*.ts --ignore-pattern lib/**/*.d.ts example/typescript/**/*.ts test/**/*.ts doc-gen/**/*.ts",
76
- "lint-md": "remark -u preset-lint-recommended .",
77
- "lint": "npm run lint-md && npm run eslint",
78
- "test": "mocha --require ts-node/register --require source-map-support/register --full-trace test/test-*.ts",
79
- "build": "npm run clean && npm run compile && npm run doc-gen",
80
- "start": "npm-run-all compile lint cover-test",
81
- "test-coverage": "nyc npm run test",
82
- "send-codacy": "nyc report --reporter=text-lcov | codacy-coverage",
83
- "doc-gen": "node doc-gen/gen.js"
84
- },
85
- "dependencies": {
86
- "@tokenizer/token": "^0.3.0",
87
- "content-type": "^1.0.4",
88
- "debug": "^4.3.4",
89
- "file-type": "^16.5.4",
90
- "media-typer": "^1.1.0",
91
- "strtok3": "^6.3.0",
92
- "token-types": "^4.2.1"
93
- },
94
- "devDependencies": {
95
- "@types/chai": "^4.3.4",
96
- "@types/chai-as-promised": "^7.1.5",
97
- "@types/debug": "^4.1.7",
98
- "@types/file-type": "^10.9.1",
99
- "@types/mocha": "^9.1.0",
100
- "@types/node": "^18.11.9",
101
- "@typescript-eslint/eslint-plugin": "^5.48.0",
102
- "@typescript-eslint/parser": "^5.48.0",
103
- "chai": "^4.3.7",
104
- "chai-as-promised": "^7.1.1",
105
- "del-cli": "5.0.0",
106
- "eslint": "^8.31.0",
107
- "eslint-config-prettier": "^8.6.0",
108
- "eslint-import-resolver-typescript": "^3.5.2",
109
- "eslint-plugin-import": "^2.26.0",
110
- "eslint-plugin-jsdoc": "^39.6.4",
111
- "eslint-plugin-node": "^11.1.0",
112
- "eslint-plugin-unicorn": "^45.0.2",
113
- "mime": "^3.0.0",
114
- "mocha": "^9.2.2",
115
- "npm-run-all": "^4.1.5",
116
- "nyc": "^15.1.0",
117
- "remark-cli": "^11.0.0",
118
- "remark-preset-lint-recommended": "^6.1.2",
119
- "source-map-support": "^0.5.21",
120
- "ts-node": "^10.9.1",
121
- "typescript": "^4.9.4"
122
- },
123
- "engines": {
124
- "node": ">=10"
125
- },
126
- "repository": {
127
- "type": "git",
128
- "url": "git+https://github.com/borewit/music-metadata.git"
129
- },
130
- "license": "MIT",
131
- "bugs": {
132
- "url": "https://github.com/Borewit/music-metadata/issues"
133
- },
134
- "nyc": {
135
- "exclude": [
136
- "test/**/*.ts",
137
- "src/**/*.js"
138
- ],
139
- "extension": [
140
- ".ts"
141
- ],
142
- "sourceMap": true,
143
- "instrument": true,
144
- "reporter": [
145
- "lcov",
146
- "text"
147
- ],
148
- "report-dir": "coverage"
149
- }
150
- }
1
+ {
2
+ "name": "music-metadata",
3
+ "description": "Music metadata parser for Node.js, supporting virtual any audio and tag format.",
4
+ "version": "7.13.5",
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
+ "keywords": [
14
+ "music",
15
+ "metadata",
16
+ "meta",
17
+ "audio",
18
+ "tag",
19
+ "tags",
20
+ "duration",
21
+ "MusicBrainz",
22
+ "Discogs",
23
+ "Picard",
24
+ "ID3",
25
+ "ID3v1",
26
+ "ID3v2",
27
+ "m4a",
28
+ "m4b",
29
+ "mp3",
30
+ "mp4",
31
+ "Vorbis",
32
+ "ogg",
33
+ "flac",
34
+ "Matroska",
35
+ "WebM",
36
+ "EBML",
37
+ "asf",
38
+ "wma",
39
+ "wmv",
40
+ "ape",
41
+ "MonkeyAudio",
42
+ "aiff",
43
+ "wav",
44
+ "WavPack",
45
+ "Opus",
46
+ "speex",
47
+ "musepack",
48
+ "mpc",
49
+ "dsd",
50
+ "dsf",
51
+ "mpc",
52
+ "dff",
53
+ "dsdiff",
54
+ "aac",
55
+ "adts",
56
+ "length",
57
+ "chapter",
58
+ "info",
59
+ "parse",
60
+ "parser",
61
+ "bwf"
62
+ ],
63
+ "main": "lib/index.js",
64
+ "types": "lib/index.d.ts",
65
+ "files": [
66
+ "lib/**/*.js",
67
+ "lib/**/*.d.ts"
68
+ ],
69
+ "scripts": {
70
+ "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",
71
+ "compile-src": "tsc -p lib",
72
+ "compile-test": "tsc -p test",
73
+ "compile-doc": "tsc -p doc-gen",
74
+ "compile": "npm run compile-src && npm run compile-test && npm run compile-doc",
75
+ "eslint": "eslint lib/**/*.ts --ignore-pattern lib/**/*.d.ts example/typescript/**/*.ts test/**/*.ts doc-gen/**/*.ts",
76
+ "lint-md": "remark -u preset-lint-recommended .",
77
+ "lint": "npm run lint-md && npm run eslint",
78
+ "test": "mocha --require ts-node/register --require source-map-support/register --full-trace test/test-*.ts",
79
+ "build": "npm run clean && npm run compile && npm run doc-gen",
80
+ "start": "npm-run-all compile lint cover-test",
81
+ "test-coverage": "nyc npm run test",
82
+ "send-codacy": "nyc report --reporter=text-lcov | codacy-coverage",
83
+ "doc-gen": "node doc-gen/gen.js"
84
+ },
85
+ "dependencies": {
86
+ "@tokenizer/token": "^0.3.0",
87
+ "content-type": "^1.0.5",
88
+ "debug": "^4.3.4",
89
+ "file-type": "^16.5.4",
90
+ "media-typer": "^1.1.0",
91
+ "strtok3": "^6.3.0",
92
+ "token-types": "^4.2.1"
93
+ },
94
+ "devDependencies": {
95
+ "@types/chai": "^4.3.9",
96
+ "@types/chai-as-promised": "^7.1.7",
97
+ "@types/debug": "^4.1.10",
98
+ "@types/file-type": "^10.9.1",
99
+ "@types/mocha": "^9.1.1",
100
+ "@types/node": "^20.8.9",
101
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
102
+ "@typescript-eslint/parser": "^5.62.0",
103
+ "chai": "^4.3.10",
104
+ "chai-as-promised": "^7.1.1",
105
+ "del-cli": "5.1.0",
106
+ "eslint": "^8.52.0",
107
+ "eslint-config-prettier": "^9.0.0",
108
+ "eslint-import-resolver-typescript": "^3.6.1",
109
+ "eslint-plugin-import": "^2.29.0",
110
+ "eslint-plugin-jsdoc": "^46.8.2",
111
+ "eslint-plugin-node": "^11.1.0",
112
+ "eslint-plugin-unicorn": "^46.0.1",
113
+ "mime": "^3.0.0",
114
+ "mocha": "^9.2.2",
115
+ "npm-run-all": "^4.1.5",
116
+ "nyc": "^15.1.0",
117
+ "remark-cli": "^12.0.0",
118
+ "remark-preset-lint-recommended": "^6.1.3",
119
+ "source-map-support": "^0.5.21",
120
+ "ts-node": "^10.9.1",
121
+ "typescript": "^5.0.2"
122
+ },
123
+ "engines": {
124
+ "node": ">=10"
125
+ },
126
+ "repository": {
127
+ "type": "git",
128
+ "url": "git+https://github.com/borewit/music-metadata.git"
129
+ },
130
+ "license": "MIT",
131
+ "bugs": {
132
+ "url": "https://github.com/Borewit/music-metadata/issues"
133
+ },
134
+ "nyc": {
135
+ "exclude": [
136
+ "test/**/*.ts"
137
+ ],
138
+ "extension": [
139
+ ".ts"
140
+ ],
141
+ "sourceMap": true,
142
+ "instrument": true,
143
+ "reporter": [
144
+ "lcov",
145
+ "text"
146
+ ],
147
+ "report-dir": "coverage"
148
+ }
149
+ }