node-ytdl-core: error 500 when trying to download a specific video

Hello there,

I am trying to move away from youtube-dl for a specific issue I found and also due to the author not actively maintaining the lib anymore.

I see your project is getting updated so i wanted to test it out.

Unfortunately I found out the same issue on your project which I invite you to try.

Try downloading http://www.youtube.com/watch?v=fxlbIS8CoW8 using best quality (by default)

const fs = require('fs');
const ytdl = require('ytdl-core');

ytdl('http://www.youtube.com/watch?v=fxlbIS8CoW8')
  .pipe(fs.createWriteStream('video.flv'));

This should suffice to break the library. for some unknown reasons this specific video and several others will not work.

I am downloading thousand of vidoes for a project and while this might happen rarely, it happens quite a lot for me.

Let me know if you need further details to reproduce the bug.

Hopefully you’ll find the reason, i wasn’t able to.

Best regards, Nikooo777

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve been testing this, itag 22 is the only format returning a 500 error. All others work, at least for this video. https://github.com/fent/node-ytdl-core/issues/212 is similar, that itag 22 errors, but the error is different.

a possible workaround could be having a format fallback option that would try other formats if the first choice failed. it wouldn’t fix the issue that itag 22 is having, but would circumvent it.

I’m thinking making the syntax like

formatFallback: false | 'all' | filtered

  • false - turned off, would not try other formats
  • 'filtered' - would try other formats that have been filtered. that is, if the user used filter: 'audioonly' for example, it would try the 2nd choice of audioonly formats if the 1st choice fails.
  • 'all' - would try the next best choice regardless of filter

it might also be worth it to have a formatFallbackMax: 3 for maximum formats to fallback on

Found the issue and patched it. Some of the highest quality video URLs are sometimes not accessible for whatever reason on Youtube. It even happened with my own parser that I tested. Made a PR that checks the request and downloads the baseline video if the highest quality fails to download.

https://github.com/fent/node-ytdl-core/pull/164

I believe there is something wrong with the audio channel, i’m not 100% sure of that tho.

I managed to catch the error thus avoiding a crash by doing this:

const fs = require('fs');
const ytdl = require('ytdl-core');

var video = ytdl('http://www.youtube.com/watch?v=fxlbIS8CoW8');
video.pipe(fs.createWriteStream('video.flv'));

video.on('error', (e) => {
    console.error("error " + e);
});
video.on('end', () => {
    console.log('[YoutubeDownload] : Download finished for video ');
});