music-metadata 11.16.0 → 11.16.1
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/id3v2/FrameParser.js
CHANGED
|
@@ -150,7 +150,7 @@ export class FrameParser {
|
|
|
150
150
|
const idAndData = FrameParser.readIdentifierAndData(uint8Array.subarray(1), encoding);
|
|
151
151
|
output = {
|
|
152
152
|
description: idAndData.id,
|
|
153
|
-
text: this.splitValue(type, util.decodeString(idAndData.data, encoding)
|
|
153
|
+
text: this.splitValue(type, FrameParser.trimNullPadding(util.decodeString(idAndData.data, encoding)))
|
|
154
154
|
};
|
|
155
155
|
break;
|
|
156
156
|
}
|
package/lib/ogg/OggParser.js
CHANGED
|
@@ -86,6 +86,7 @@ export class OggParser extends BasicParser {
|
|
|
86
86
|
async parse() {
|
|
87
87
|
this.streams = new Map();
|
|
88
88
|
let enfOfStream = false;
|
|
89
|
+
let stoppedEarly = false;
|
|
89
90
|
let header;
|
|
90
91
|
try {
|
|
91
92
|
do {
|
|
@@ -100,7 +101,10 @@ export class OggParser extends BasicParser {
|
|
|
100
101
|
}
|
|
101
102
|
await stream.parsePage(this.tokenizer, header);
|
|
102
103
|
if (stream.pageNumber > 12 &&
|
|
104
|
+
// A comment (including its cover art) may span more than 13 pages.
|
|
105
|
+
[...this.streams.values()].every(stream => stream.pageConsumer?.isMetadataComplete !== false) &&
|
|
103
106
|
!(this.options.duration && [...this.streams.values()].find(stream => stream.pageConsumer?.durationOnLastPage))) {
|
|
107
|
+
stoppedEarly = true;
|
|
104
108
|
debug('Stop processing Ogg stream');
|
|
105
109
|
break;
|
|
106
110
|
}
|
|
@@ -120,7 +124,9 @@ export class OggParser extends BasicParser {
|
|
|
120
124
|
}
|
|
121
125
|
for (const stream of this.streams.values()) {
|
|
122
126
|
if (!stream.closed) {
|
|
123
|
-
|
|
127
|
+
if (!stoppedEarly) {
|
|
128
|
+
this.metadata.addWarning(`End-of-stream reached before reaching last page in Ogg stream serial=${stream.streamSerial}`);
|
|
129
|
+
}
|
|
124
130
|
await stream.pageConsumer?.flush();
|
|
125
131
|
}
|
|
126
132
|
stream.pageConsumer?.calculateDuration(enfOfStream);
|
package/lib/ogg/OggToken.d.ts
CHANGED
|
@@ -62,6 +62,8 @@ export declare class SegmentTable implements IGetToken<ISegmentTable> {
|
|
|
62
62
|
get(buf: Uint8Array, off: number): ISegmentTable;
|
|
63
63
|
}
|
|
64
64
|
export interface IPageConsumer {
|
|
65
|
+
/** False while required metadata is still being read; undefined if not tracked. */
|
|
66
|
+
isMetadataComplete?: boolean;
|
|
65
67
|
/**
|
|
66
68
|
* Need to parse to end to be able to calculate the duration
|
|
67
69
|
*/
|
|
@@ -26,6 +26,7 @@ export declare class VorbisStream implements IPageConsumer {
|
|
|
26
26
|
protected options: IOptions;
|
|
27
27
|
protected lastPageHeader?: IPageHeader;
|
|
28
28
|
durationOnLastPage: boolean;
|
|
29
|
+
isMetadataComplete: boolean;
|
|
29
30
|
constructor(metadata: INativeMetadataCollector, options: IOptions);
|
|
30
31
|
/**
|
|
31
32
|
* Vorbis 1 parser
|
|
@@ -14,6 +14,7 @@ export class VorbisStream {
|
|
|
14
14
|
constructor(metadata, options) {
|
|
15
15
|
this.pageSegments = [];
|
|
16
16
|
this.durationOnLastPage = true;
|
|
17
|
+
this.isMetadataComplete = false;
|
|
17
18
|
this.metadata = metadata;
|
|
18
19
|
this.options = options;
|
|
19
20
|
}
|
|
@@ -137,5 +138,6 @@ export class VorbisStream {
|
|
|
137
138
|
while (userCommentListLength-- > 0) {
|
|
138
139
|
offset += await this.parseUserComment(pageData, offset);
|
|
139
140
|
}
|
|
141
|
+
this.isMetadataComplete = true;
|
|
140
142
|
}
|
|
141
143
|
}
|
package/package.json
CHANGED