fix gifv to have a failover and to use videoExtensions to compare

This commit is contained in:
waveringana 2025-05-14 17:50:12 -04:00
parent 06efb67198
commit e8c05667d0

View file

@ -121,11 +121,9 @@ router.get(
const [filename, fileExtension] = extension(`uploads/${req.params.file}`);
if (
fileExtension == ".mp4" ||
fileExtension == ".mov" ||
fileExtension == ".webm" ||
fileExtension == ".gif"
videoExtensions.includes(fileExtension)
) {
try {
const imageData = ffProbe(
`uploads/${req.params.file}`,
filename,
@ -141,7 +139,17 @@ router.get(
width: width,
height: height,
});
} catch (error) {
console.error("Error processing video:", error);
return res.render("gifv", {
url: url,
host: `${req.protocol}://${req.get("host")}`,
width: 800,
height: 600,
});
}
} else {
try {
const imageData = await imageProbe(
fs.createReadStream(`uploads/${req.params.file}`)
);
@ -151,6 +159,15 @@ router.get(
width: imageData.width,
height: imageData.height,
});
} catch (error) {
console.error("Error processing image:", error);
return res.render("gifv", {
url: url,
host: `${req.protocol}://${req.get("host")}`,
width: 800,
height: 600,
});
}
}
}
);