How use ytpl with proxy ?
Murena7 opened this issue · 4 comments
Murena7 commented
Hi all - is possible use ytpl with proxy ? Please show example how i can do this ? Thanks
TimeForANinja commented
it should work the same way it works for ytdl-core
extract from the official ytdl-core example:
const ytdl = require('..');
const HttpsProxyAgent = require('https-proxy-agent');
// Remove 'user:pass@' if you don't need to authenticate to your proxy.
const proxy = 'http://user:pass@111.111.111.111:8080';
const agent = HttpsProxyAgent(proxy);
const stream = ytdl('https://www.youtube.com/watch?v=aqz-KE-bpKQ', {
requestOptions: { agent },
});
and for ytpl:
const ytpl = require('ytpl');
const HttpsProxyAgent = require('https-proxy-agent');
// Remove 'user:pass@' if you don't need to authenticate to your proxy.
const proxy = 'http://user:pass@111.111.111.111:8080';
const agent = HttpsProxyAgent(proxy);
const playlist = await ytpl('<some id in here>', {
requestOptions: { agent },
});
Murena7 commented
I try pass agent - same as in example but this didn't work - i receive error
TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "options.agent" property must be one of Agent-like Object
But when i do same in ytdl-core - all work fine, may be in ytdl-core library some different ?
TimeForANinja commented
should be fixed with 30763ff and the new v2.0.4 release