-
Notifications
You must be signed in to change notification settings - Fork 864
Open
Description
I'm using ytdl-core from a browser, using browserify. Cross-domain requests are not allowed, so I'm using CORS Anywhere proxy to bypass CORS Header related errors.
After a few requests, I'm getting error 429s from YouTube, saying that I may be making too many requests (not really, one or two per minute at the most, downloading a webm stream). The method crashes afterward and won't do any additional requests.
Google seems to block the entire origin domain, so it won't work for anyone with the same origin header (I haven't verified yet).
There are multiple things wrong:
- How can I prevent this? I'd like to have some sort of rate throttling so it doesn't incur into 429 errors. It renders ytdl completely unusable for a long time (no exact amount, last time it was more than an hour)
- No error is thrown by ytdl whatsoever. This is not good because there is no way to handle the error. The callback never gets invoked, and error handlers are never called.
Code example:
const ytdl = require('ytdl-core');
const concat = require('concat-stream');
var concatStream = concat((arrayBuffer) =>
{
console.log('file downloaded');
// Processing of video blob goes here...
});
var ytstream = ytdl(YOUTUBE_VIDEOURL,
{
requestOptions: {
transform: (parsed) =>
{
var parsedHeaders = parsed.headers;
return {
host: 'cors-anywhere.herokuapp.com/',
path: "http://youtube.com" + parsed.path,
maxRedirects: 10,
headers: parsedHeaders
}
},
},
});
ytstream.on('error', function(e)
{
// Never gets called
})
.pipe(concatStream);
trinhvanbien, NafiAF, josephrocca, MrZBou, alexmercerind and 8 moreluiseok, abh80, ARJUNOP6969 and dave9123