Switch back to streaming parsing of id3s

This commit is contained in:
Jordan Eldredge 2025-07-05 16:17:03 -07:00
parent 7b87c2302c
commit d4a841846c
2 changed files with 14 additions and 11 deletions

View file

@ -30,19 +30,22 @@ export async function genMediaTags(
`Failed to fetch URL: ${file}, status: ${response.status}`
);
}
// There's currently an issue where some URLs will fail to parse id3 tags
// when using parseWebStream. So, for now, we'll deopt to using parseBlob.
// This forces us to download the whole file, but is at least correct.
// https://github.com/Borewit/music-metadata/issues/2455
// There's currently an issue where some URLs will fail to parse id3 tags
// when using parseWebStream. This approach can work around it. However,
// My current assumption is that this is an issue mostly specific to that
// individual file and not a wide spread issue, but if we find it happens
// more broadly we can deopt to using parseBlob as below.
// const webStream = response.body;
// if (webStream == null) {
// throw new Error("Response body is null, cannot parse metadata.");
// }
// return musicMetadata.parseWebStream(webStream, undefined, options);
const blob = await response.blob();
return musicMetadata.parseBlob(blob, options);
// const blob = await response.blob();
// return musicMetadata.parseBlob(blob, options);
const webStream = response.body;
if (webStream == null) {
throw new Error("Response body is null, cannot parse metadata.");
}
return musicMetadata.parseWebStream(webStream, undefined, options);
}
if (
"fetchFromUrl" in musicMetadata &&

View file

@ -17,6 +17,6 @@
"jsx": "react-jsx",
"module": "esnext"
},
"include": ["**/*.ts", "**/*.tsx"],
"include": ["**/*.ts", "**/*.tsx", "vite.config.mts", "vite.config.mts"],
"exclude": ["node_modules", "demo/built", "built", "dist"]
}