add catching for already deleted videos

This commit is contained in:
localhost 2026-02-22 20:17:04 +01:00
parent e91a5b957a
commit 6e820581f1
1 changed files with 5 additions and 0 deletions

View File

@ -126,6 +126,11 @@ app.ws('/download/:id', async (ws, req) => {
let quality = '480p'
const info = await getInfo(req.params.id);
if (info.playabilityStatus?.errorScreen?.playerErrorMessageRenderer?.subreason?.simpleText) {
ws.send(`This video is not available for download (${info.playabilityStatus.errorScreen.playerErrorMessageRenderer.subreason.simpleText}).`);
return ws.close()
}
if (!info || info.videoDetails.lengthSeconds == undefined) {
ws.send('Unable to retrieve video info from YouTube. Please try again later.');
return ws.close()