fent/node-ytdl-core

Copyrighted Material (Music Videos) throws an Error #510

NeuronButter posted onGitHub

Now firstly, I am aware of the restriction on YouTube's end, but that's not my problem. My problem is that when it throws the error, the process terminates. Here's my code:

app.get('/mp4', (req,res) => {
    var url = req.query.url;
    res.header('Content-Disposition', 'attachment; filename="video.mp4"');
    ytdl(url, {
        format: 'mp4'
    }).pipe(res)
});

Because this is running in an Express server, everything works fine, and will work as normal when the video is successful. The problem is, when it's not, rather than logging an error, it will instead stop the Express server (the instance inside the command prompt). How do I make Express not crash Node, but instead change the response (like instead return a TXT file)?


Have you tried wrapping it in a try catch block?

posted by MarcelloTheArcane about 5 years ago

Turns out I formatted it wrong lol, I was setting Format by string and not a function

posted by NeuronButter about 5 years ago

Fund this Issue

$0.00
Funded

Pull requests