distubejs / ytdl-core

YouTube video downloader in javascript.
MIT License
206 stars 43 forks source link

Sign in to confirm you’re not a bot #70

Closed yourshaxzod closed 1 month ago

yourshaxzod commented 1 month ago

I'm using it on aws vps and I'm getting an error message

UnrecoverableError: Sign in to confirm you’re not a bot

jemeetala commented 1 month ago

i am facing same issue...

rickcompanydev commented 1 month ago

When I use the VPS, I face the same issue, but there is no problem on my local PC.

yourshaxzod commented 1 month ago

When I use the VPS, I face the same issue, but there is no problem on my local PC.

are you using free vps?

rickcompanydev commented 1 month ago

When I use the VPS, I face the same issue, but there is no problem on my local PC.

are you using free vps?

i'm using aws and free vps, the issue occurs on both

yourshaxzod commented 1 month ago

When I use the VPS, I face the same issue, but there is no problem on my local PC.

are you using free vps?

i'm using aws and free vps, the issue occurs on both

I think youtube blocked the free vps ip address in aws

dylaniscool54 commented 1 month ago

maybe we could run the download thru tor socks5 proxy

yourshaxzod commented 1 month ago

Ok bro, Let me know if you find a solution

dylaniscool54 commented 1 month ago

app.get('/stream', async (req, res) => { const youtubeid = req.query.ytid;

if (!youtubeid) { return res.status(400).send('YouTube ID is required'); }

try { const proxyUrl = 'http://122.200.19.103:80'; const agent = new HttpsProxyAgent(proxyUrl);

const url = `http://www.youtube.com/watch?v=${youtubeid}`;

console.log(agent)

const info = await ytdl.getInfo(url, { requestOptions: { agent } });
const format = ytdl.chooseFormat(info.formats, { filter: 'audioonly' });
const contentLength = format.contentLength;

res.setHeader('Content-Type', 'audio/mp3');
res.setHeader('Content-Length', contentLength);

ytdl(url, { format: format, requestOptions: { agent } })
  .pipe(res)
  .on('error', (error) => {
    console.error('Error piping the stream:', error);
    res.status(500).send('An error occurred while processing the request');
  });

} catch (error) { console.error('Error:', error); res.status(500).send('An error occurred while processing the request'); } });

im trying this but it gives

Error: InvalidArgumentError: unsupported opts.agent. Did you mean opts.client? at /rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/node_modules/undici/index.js:86:13 at Object.exports.request (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/utils.js:178:21) at /rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:84:59 at Map.getOrSet (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/cache.js:29:19) at getWatchHTMLPageBody (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:84:33) at getWatchHTMLPage (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:165:20) at retryFunc (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:121:22) at runNextTicks (internal/process/task_queues.js:60:5) at processTimers (internal/timers.js:497:9) at async exports.getBasicInfo (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:44:16) { code: 'UND_ERR_INVALID_ARG' }

yourshaxzod commented 1 month ago

app.get('/stream', async (req, res) => { const youtubeid = req.query.ytid;

if (!youtubeid) { return res.status(400).send('YouTube ID is required'); }

try { const proxyUrl = 'http://122.200.19.103:80'; const agent = new HttpsProxyAgent(proxyUrl);

const url = `http://www.youtube.com/watch?v=${youtubeid}`;

console.log(agent)

const info = await ytdl.getInfo(url, { requestOptions: { agent } });
const format = ytdl.chooseFormat(info.formats, { filter: 'audioonly' });
const contentLength = format.contentLength;

res.setHeader('Content-Type', 'audio/mp3');
res.setHeader('Content-Length', contentLength);

ytdl(url, { format: format, requestOptions: { agent } })
  .pipe(res)
  .on('error', (error) => {
    console.error('Error piping the stream:', error);
    res.status(500).send('An error occurred while processing the request');
  });

} catch (error) { console.error('Error:', error); res.status(500).send('An error occurred while processing the request'); } });

im trying this but it gives

Error: InvalidArgumentError: unsupported opts.agent. Did you mean opts.client? at /rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/node_modules/undici/index.js:86:13 at Object.exports.request (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/utils.js:178:21) at /rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:84:59 at Map.getOrSet (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/cache.js:29:19) at getWatchHTMLPageBody (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:84:33) at getWatchHTMLPage (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:165:20) at retryFunc (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:121:22) at runNextTicks (internal/process/task_queues.js:60:5) at processTimers (internal/timers.js:497:9) at async exports.getBasicInfo (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:44:16) { code: 'UND_ERR_INVALID_ARG' }

https://github.com/distubejs/ytdl-core?tab=readme-ov-file#cookies-support

try this

dylaniscool54 commented 1 month ago

image cookies dont even work im gonna use proxy, also i found the correct way to use proxies for this

ybd-project commented 1 month ago

The method of using OAuth tokens solves this problem, albeit in the short term. (I don't know if ytdl-core can do OAuth...) I tried to implement the following as a test, referring to @dylaniscool54's implementation, but it times out. (The text was translated using a translator. Please understand.)

import ytdl from '@distube/ytdl-core';

const PROXY_URI = 'http://122.200.19.103',
    AGENT = ytdl.createProxyAgent({ uri: PROXY_URI });

// Video: Never Gonna Give You Up
ytdl.getInfo('https://youtu.be/dQw4w9WgXcQ', {
    agent: AGENT,
}).then(data => {
    console.log(data);
}).catch(err => {
    console.error('Error:', err);
});
dylaniscool54 commented 1 month ago

app.get('/stream', async (req, res) => { const youtubeid = req.query.ytid;

if (!youtubeid) { return res.status(400).send('YouTube ID is required'); }

try { const agent = ytdl.createProxyAgent({ uri: "http://152.26.229.66:9443" });

const url = `http://www.youtube.com/watch?v=${youtubeid}`;

const info = await ytdl.getInfo(url, { agent });

const format = ytdl.chooseFormat(info.formats, { filter: 'audioonly' });
const contentLength = format.contentLength;

res.redirect(format.url)

} catch (error) { console.error('Error:', error); res.status(500).send('An error occurred while processing the request'); } });

i did this and it worked. i will make it change proxies now

ybd-project commented 1 month ago

Certainly this works! At the moment this appears to be the best method over the others. But can you tell me about the IP addresses of the other proxies, as I think the IPs will be banned by YouTube at some point.

dylaniscool54 commented 1 month ago

youtube are really annoying for doing this

yourshaxzod commented 1 month ago

PROXY_URI

Where can I get the PROXY_URI?

Riders004 commented 1 month ago

Same issue on koyeb

Riders004 commented 1 month ago

app.get('/stream', async (req, res) => { const youtubeid = req.query.ytid; if (!youtubeid) { return res.status(400).send('YouTube ID is required'); } try { const proxyUrl = 'http://122.200.19.103:80'; const agent = new HttpsProxyAgent(proxyUrl);

const url = `http://www.youtube.com/watch?v=${youtubeid}`;

console.log(agent)

const info = await ytdl.getInfo(url, { requestOptions: { agent } });
const format = ytdl.chooseFormat(info.formats, { filter: 'audioonly' });
const contentLength = format.contentLength;

res.setHeader('Content-Type', 'audio/mp3');
res.setHeader('Content-Length', contentLength);

ytdl(url, { format: format, requestOptions: { agent } })
  .pipe(res)
  .on('error', (error) => {
    console.error('Error piping the stream:', error);
    res.status(500).send('An error occurred while processing the request');
  });

} catch (error) { console.error('Error:', error); res.status(500).send('An error occurred while processing the request'); } }); im trying this but it gives Error: InvalidArgumentError: unsupported opts.agent. Did you mean opts.client? at /rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/node_modules/undici/index.js:86:13 at Object.exports.request (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/utils.js:178:21) at /rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:84:59 at Map.getOrSet (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/cache.js:29:19) at getWatchHTMLPageBody (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:84:33) at getWatchHTMLPage (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:165:20) at retryFunc (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:121:22) at runNextTicks (internal/process/task_queues.js:60:5) at processTimers (internal/timers.js:497:9) at async exports.getBasicInfo (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:44:16) { code: 'UND_ERR_INVALID_ARG' }

https://github.com/distubejs/ytdl-core?tab=readme-ov-file#cookies-support

try this

How can i get ip

yourshaxzod commented 1 month ago

app.get('/stream', async (req, res) => { const youtubeid = req.query.ytid; if (!youtubeid) { return res.status(400).send('YouTube ID is required'); } try { const proxyUrl = 'http://122.200.19.103:80'; const agent = new HttpsProxyAgent(proxyUrl);

const url = `http://www.youtube.com/watch?v=${youtubeid}`;

console.log(agent)

const info = await ytdl.getInfo(url, { requestOptions: { agent } });
const format = ytdl.chooseFormat(info.formats, { filter: 'audioonly' });
const contentLength = format.contentLength;

res.setHeader('Content-Type', 'audio/mp3');
res.setHeader('Content-Length', contentLength);

ytdl(url, { format: format, requestOptions: { agent } })
  .pipe(res)
  .on('error', (error) => {
    console.error('Error piping the stream:', error);
    res.status(500).send('An error occurred while processing the request');
  });

} catch (error) { console.error('Error:', error); res.status(500).send('An error occurred while processing the request'); } }); im trying this but it gives Error: InvalidArgumentError: unsupported opts.agent. Did you mean opts.client? at /rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/node_modules/undici/index.js:86:13 at Object.exports.request (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/utils.js:178:21) at /rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:84:59 at Map.getOrSet (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/cache.js:29:19) at getWatchHTMLPageBody (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:84:33) at getWatchHTMLPage (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:165:20) at retryFunc (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:121:22) at runNextTicks (internal/process/task_queues.js:60:5) at processTimers (internal/timers.js:497:9) at async exports.getBasicInfo (/rbd/pnpm-volume/dcc9b815-043a-452e-9859-e1e705677ea0/node_modules/@distube/ytdl-core/lib/info.js:44:16) { code: 'UND_ERR_INVALID_ARG' }

https://github.com/distubejs/ytdl-core?tab=readme-ov-file#cookies-support try this

I tried to change vps ip address in aws it didn't work

ybd-project commented 1 month ago

How can i get ip

I am currently selecting valid proxy IPs from https://github.com/Mini0001/proxylist/blob/main/http.txt, and at this time there are two valid IPs

  1. 152.26.229.66:9443
  2. 152.26.229.42:9443
jemeetala commented 1 month ago

0|app | Error: UnrecoverableError: Sign in to confirm you’re not a bot 0|app | at exports.playError (/home/ubuntu/ytube2d/node_modules/@distube/ytdl-core/lib/utils.js:164:12) 0|app | at exports.getBasicInfo (/home/ubuntu/ytube2d/node_modules/@distube/ytdl-core/lib/info.js:46:25) 0|app | at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

i got this error my code is exports.getData = async (req, res) => { try { const { url } = req.body;

const proxyAgent = ytdl.createProxyAgent({ uri: 'http://localhost:5000' });

const info = await ytdl.getInfo(url, { proxyAgent });

if (!info) {
  throw new Error("No such info found");
}

res.status(200).json({ success: true, info });

} catch (error) { console.error("Error:", error); res.status(500).json({ success: false, message: "Server error" }); } };


for proxy I do set up on AWS server { server_name api.ytube2d.com;

location / {
    proxy_pass http://localhost:5000; # Assuming your Node.js app is running on port 3000
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

}

in my local it's working fine but in AWS server it is not working

ybd-project commented 1 month ago

Maybe the AWS IP is blocked from YouTube. Changing the ytdl.createProxyAgent part as follows should work.

ytdl.createProxyAgent({ uri: '152.26.229.66:9443' });
yourshaxzod commented 1 month ago

Ehtimol, AWS IP YouTube-dan bloklangan. Qismni quyidagi tarzda o'zgartirish ishlashi kerak.ytdl.createProxyAgent

ytdl.createProxyAgent({ uri: '152.26.229.66:9443' });

thanks it worked but http://152.26.229.66:9443 where can i get this

ybd-project commented 1 month ago

thanks it worked but http://152.26.229.66:9443 where can i get this

You can find valid IP addresses at https://github.com/Mini0001/proxylist/blob/main/http.txt and other lists of proxy IP addresses. However, there are very few valid IP addresses, only two at this time. As a way to find a valid IP address, I have set up a test server in Glitch and have been testing IP addresses at random.

yourshaxzod commented 1 month ago

thanks it worked but http://152.26.229.66:9443 where can i get this

You can find valid IP addresses at https://github.com/Mini0001/proxylist/blob/main/http.txt and other lists of proxy IP addresses. However, there are very few valid IP addresses, only two at this time. As a way to find a valid IP address, I have set up a test server in Glitch and have been testing IP addresses at random.

If a good thread has a lot of addresses and uses them randomly, won't this problem occur later?

ybd-project commented 1 month ago

Yes, I think it will continue to work fine if nothing else. However, if YouTube bans your IP or something, the error may happen again.

yourshaxzod commented 1 month ago

Yes, I think it will continue to work fine if nothing else. However, if YouTube bans your IP or something, the error may happen again.

How to avoid youtube ban?, whether to set limits for sending requests?

ybd-project commented 1 month ago

Yes, I think the best solution is to keep the request volume to an appropriate amount that is not too large. You can also provide many proxy IPs to distribute the requests. Well, ultimately it depends on YouTube's mood...

ybd-project commented 1 month ago

The following is a list of valid proxy IP addresses as of 08/07/2024 at 22:00 for resolving this issue.

  1. 152.26.229.42:9443
  2. 152.26.229.66:9443
  3. 152.26.229.88:9443
  4. 152.26.231.42:9443
  5. 152.26.231.77:9443
  6. 152.26.231.86:9443
  7. 177.234.241.25:999
  8. 177.234.241.26:999
  9. 177.234.241.27:999
  10. 177.234.241.30:999

Array: ['152.26.229.66:9443', '152.26.229.42:9443', '152.26.229.88:9443', '152.26.231.42:9443', '152.26.231.86:9443', '152.26.231.77:9443', '152.26.229.88:9443', '177.234.241.27:999', '177.234.241.30:999', '177.234.241.26:999', '177.234.241.25:999']

skick1234 commented 1 month ago

This problem should be due to invalid cookies. I added some warnings to the docs. Duplicated #21

yourshaxzod commented 1 month ago

Quyida ushbu muammoni hal qilish uchun 08.07.2024 yil soat 22:00 holatiga koʻra amaldagi proksi IP manzillar roʻyxati keltirilgan.

  1. 152.26.229.42:9443
  2. 152.26.229.66:9443
  3. 152.26.229.88:9443
  4. 152.26.231.42:9443
  5. 152.26.231.77:9443
  6. 152.26.231.86:9443
  7. 177.234.241.25:999
  8. 177.234.241.26:999
  9. 177.234.241.27:999
  10. 177.234.241.30:999

Massiv: ['152.26.229.66:9443', '152.26.229.42:9443', '152.26.229.88:9443', '152.26.231.42:9443', '1521.2.2.' 31,77:9443' , '152.26.229.88:9443', '177.234.241.27:999', '177.234.241.30:999', '177.234.241.26:999', '1729923.'

Thank you for your great help bro

Riders004 commented 1 week ago

app.get('/stream', async (req, res) => { const youtubeid = req.query.ytid;

if (!youtubeid) { return res.status(400).send('YouTube ID is required'); }

try { const agent = ytdl.createProxyAgent({ uri: "http://152.26.229.66:9443" });

const url = `http://www.youtube.com/watch?v=${youtubeid}`;

const info = await ytdl.getInfo(url, { agent });

const format = ytdl.chooseFormat(info.formats, { filter: 'audioonly' });
const contentLength = format.contentLength;

res.redirect(format.url)

} catch (error) { console.error('Error:', error); res.status(500).send('An error occurred while processing the request'); } });

i did this and it worked. i will make it change proxies now

How to get valid proxy

Riders004 commented 1 week ago

The following is a list of valid proxy IP addresses as of 08/07/2024 at 22:00 for resolving this issue.

  1. 152.26.229.42:9443
  2. 152.26.229.66:9443
  3. 152.26.229.88:9443
  4. 152.26.231.42:9443
  5. 152.26.231.77:9443
  6. 152.26.231.86:9443
  7. 177.234.241.25:999
  8. 177.234.241.26:999
  9. 177.234.241.27:999
  10. 177.234.241.30:999

Array: ['152.26.229.66:9443', '152.26.229.42:9443', '152.26.229.88:9443', '152.26.231.42:9443', '152.26.231.86:9443', '152.26.231.77:9443', '152.26.229.88:9443', '177.234.241.27:999', '177.234.241.30:999', '177.234.241.26:999', '177.234.241.25:999']

How di you get this validproxy

Riders004 commented 1 week ago

thanks it worked but http://152.26.229.66:9443 where can i get this

You can find valid IP addresses at https://github.com/Mini0001/proxylist/blob/main/http.txt and other lists of proxy IP addresses. However, there are very few valid IP addresses, only two at this time. As a way to find a valid IP address, I have set up a test server in Glitch and have been testing IP addresses at random.

How to get valid proxy

ybd-project commented 1 week ago

thanks it worked but http://152.26.229.66:9443 where can i get this

You can find valid IP addresses at https://github.com/Mini0001/proxylist/blob/main/http.txt and other lists of proxy IP addresses. However, there are very few valid IP addresses, only two at this time. As a way to find a valid IP address, I have set up a test server in Glitch and have been testing IP addresses at random.

How to get valid proxy

Test everything.

Riders004 commented 1 week ago

thanks it worked but http://152.26.229.66:9443 where can i get this

You can find valid IP addresses at https://github.com/Mini0001/proxylist/blob/main/http.txt and other lists of proxy IP addresses. However, there are very few valid IP addresses, only two at this time. As a way to find a valid IP address, I have set up a test server in Glitch and have been testing IP addresses at random.

How to get valid proxy

Test everything.

I test but I get some valid ip but that's isn't making connection to @distube/ytdl-core to get YouTube audio video