fent / node-ytdl-core

YouTube video downloader in javascript.
MIT License
4.54k stars 803 forks source link

Error: Video unavailable #888

Open brennanwilkes opened 3 years ago

brennanwilkes commented 3 years ago

About 5% of video URL's throw an error.

Error: Video unavailable at Object.exports.playError (/usr/src/app/node_modules/ytdl-core/lib/utils.js:124:12) at downloadFromInfoCallback (/usr/src/app/node_modules/ytdl-core/lib/index.js:72:19) at /usr/src/app/node_modules/ytdl-core/lib/index.js:20:5 at runMicrotasks (<anonymous>) at processTicksAndRejections (internal/process/task_queues.js:97:5)

Version

$ npm ls ytdl-core
└── ytdl-core@4.5.0 

An example URL which reproducibly fails: youtube.com/watch?v=0NChtZCDCsY

Weirdly, it works just fine on my local machine (in Canada), but fails when deployed to Google Cloud Run on US-West. However the video in question should be available in the United States, and the errors still persist when downloading through a Canadian proxy server, so I don't believe country restrictions is the issue.

When checking for formats with:

ytdl.getInfo(url).then(res => {
    console.dir(res.formats);
});

any empty array [] is printed.

A simplified snippet of my code:

ytdl.getInfo(url).then(res => {
        const audioFormats = ytdl.filterFormats(res.formats, "audioonly");

        const download = ytdl(url, {
                quality: audioFormats.length > 0 ? "highestaudio" : "lowestvideo"
        }).on("error", err => {
                console.error(`Failed to download ${url}`);
                console.error(err);
        });
});

Any ideas?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.