music: fetch again with get if head fails

This commit is contained in:
Cynthia Foxwell 2023-12-25 18:03:07 -07:00
parent a3e092c78d
commit a7c17c195b
1 changed files with 8 additions and 1 deletions

View File

@ -574,9 +574,16 @@ command.callback = async function (
}
} else {
if (argStr.match(/^https?:\/\//)) {
const contentType = await fetch(argStr, {method: "HEAD"}).then(
let contentType = await fetch(argStr, {method: "HEAD"}).then(
(res) => res.headers.get("Content-Type")
);
if (!contentType) {
contentType = await fetch(argStr, {method: "GET"}).then((res) =>
res.headers.get("Content-Type")
);
}
if (
contentType.startsWith("audio/") ||
contentType.startsWith("video/")