distubejs/ytdl-core

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

Closed this issue · 175 comments

Describe the bug

Debug File

Environment

  • @distube/ytdl-core version:
  • Node.js version:
  • Operating system:

Same here :X

use cookies bro

use cookies, cara

Não sei como adicionar, você pode me enviar sua case sem o token?

use cookies, cara

Não sei como adicionar, você pode me enviar sua case sem o token?

I just followed the instructions in the README, and it worked for me.

Use cookies, cara

Não sei como adicionar, você pode me enviar sua case sem o token?

Eu apenas segui as instruções no README e funcionou para mim.

Envie aqui sua função completa pra eu testar na minha máquina

Apenas a função, os cookies eu consigo encontrar

const cookies = [....]

const agent = distube.createAgent(cookies);

exports.audioOnly = async (req, res) => {
const { videoId } = req.query;
let info = await distube.getInfo(videoId, { agent });
let audioFormats = distube.filterFormats(info.formats, "audioonly");
res.json(audioFormats);
};

const cookies = [....]

const agente = distube.createAgent(cookies);

exports.audioOnly = async (req, res) => { const { videoId } = req.query; let info = await distube.getInfo(videoId, { agent }); let audioFormats = distube.filterFormats(info.formats, "audioonly"); res.json(audioFormats); };

Envia a função completa por favor, da case ao break, ficarei grato!

Where can I get a cookie? to use in the example

Where can I get a cookie? to use in the example

Read This

Where can I get a cookie? to use in the example

Read This

Thank you bro, I will try this.

I just tested, cookies works, but any idea how long does the cookies work?

Acabei de testar, os cookies funcionam, mas alguma ideia de quanto tempo os cookies funcionam?

Me envia aí mano sua função adaptada com os cookies pra eu ver como fica, não consegui adaptar no meu! Não precisa enviar seus cookies

Well I did about the cookies, it works in my local, but in the server isn't work I have the same error, i did the same steps that in the documentation
image

Acabei de testar, os cookies funcionam, mas alguma ideia de quanto tempo os cookies funcionam?

Me envia aí mano sua função adaptada com os cookies pra eu ver como fica, não consegui adaptar no meu! Não precisa enviar seus cookies

Aquí encontré un código que usa las cookies y si me funcionó.
Ejemplo

Well I did about the cookies, it works in my local, but in the server isn't work I have the same error, i did the same steps that in the documentation image

In my case, I used a proxy like 152.26.229.66:9443 to address this issue. (#70)
However, it does slow down the processing speed a bit.

Well I did about the cookies, it works in my local, but in the server isn't work I have the same error, i did the same steps that in the documentation image

Same here

@EAxelGM Adding the referer works for me.

const agentOptions = {
    headers: {
      referer: 'https://www.youtube.com/',
    },
  };
  const agent = ytdl.createAgent(cookies, agentOptions);

@EAxelGM Adding the referer works for me.

const agentOptions = {
    headers: {
      referer: 'https://www.youtube.com/',
    },
  };
  const agent = ytdl.createAgent(cookies, agentOptions);

I did the following, but it does not work on my Glitch server.

const agentOptions = {
    headers: {
        referer: "https://www.youtube.com/",
    },
},
    agent = ytdl.createAgent(cookies, agentOptions);

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

server js – marsh-numerous-oak - Google Chrome 2024_08_08 12_35_58

@ybd-project Male sure to get the cookies while in incognito and then close the browser, do not log out

Went through the steps to get the cookies through incognito mode, used known good working proxies and still having the issue:

image

image

As mentioned above by another user, It works on my local machine but not on my server. Now I can assume it's something to do with whom I'm hosting with. But shouldn't the proxies fix that?

@ybd-project Male sure to get the cookies while in incognito and then close the browser, do not log out

Cookies still do not work as expected and only work locally. For non-local use, using a proxy is the most promising solution at this time.

Update: I am looking for proxies that can be used successfully. But there are very few of these, only about 10 at this time. (Proxies like 152.26.xxx.xx:9443 are competent because they are fast and work correctly.)

I have try, and it working fine
Step 1, Go to :https://chrome.google.com/webstore/detail/fngmhnnpilhplaeedifhccceomclgfbg and install it;
Step 2, Go to Youtube, then login,next in icon EditCookie, choose export data ;
Step 3 Paste cookie to file: cookies.json in root project
NestJS Code:

import * as ytdl from '@distube/ytdl-core';
import axios from 'axios';
import * as fs from 'fs';
import * as path from 'path';

export class YouTubeService  implements OnModuleInit {
  constructor() {
    super();
  }
 }
  private agent: ytdl.Agent;

  onModuleInit() {
    this.initializeAgent();
  }
    private initializeAgent() {
    const cookiesPath = path.join(__dirname, '..', 'cookies.json');
    const cookiesContent = fs.readFileSync(cookiesPath, 'utf8');
    this.agent = ytdl.createAgent(JSON.parse(cookiesContent));
  }
  getAgent(): ytdl.Agent {
    return this.agent;
  }
  
   protected async downloadYoutube(youtubeLink: any, ipAddress: string) {
    try {
      if (!ytdl.validateURL(youtubeLink)) {
        throw new Error('Youtube url not invalid');
      }
      const agent = await this.getAgent();
      const info = await ytdl.getInfo(youtubeLink, { agent });
      const videoFormat = ytdl.chooseFormat(info.formats, {
        quality: 'highestvideo',
        filter: 'videoandaudio',
      });

      if (videoFormat && videoFormat.container === 'mp4') {
        return {
          title: info.videoDetails.title,
          channelId: info.videoDetails.channelId,
          artist: info.videoDetails.author.name,
          verified: info.videoDetails.author.verified,
          category: info.videoDetails.category,
          description: info.videoDetails.description,
          keywords: info.videoDetails.keywords,
          thumbnails: info.videoDetails.thumbnails
     
        };
      } else {
        throw new Error('Error');
      }
    } catch (err) {
      return {
        message: 'Server error',
        error: err.message,
      };
    }
  }

I have try, and it working fine Step 1, Go to :https://chrome.google.com/webstore/detail/fngmhnnpilhplaeedifhccceomclgfbg and install it; Step 2, Go to Youtube, then login,next in icon EditCookie, choose export data ; Step 3 Paste cookie to file: cookies.json in root project NestJS Code:

Thank you very much, I will try it. But using the cookie does not work in my environment (Glitch server).
I got the cookie from EditThisCookie and pasted it as is without editing, but no luck.

use cookies bro

doing this and not working, is there a specific way to do this?

use cookies bro

doing this and not working, is there a specific way to do this?

Cookies do not work well, so we use proxies instead.

Glitch server)

I you no have mysql or sql server database, I think you should try use server vercel ^^

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

use cookies bro

doing this and not working, is there a specific way to do this?

Cookies do not work well, so we use proxies instead.

how do i use proxies?

Like how do i get a proxy url to use

Glitch server)

I you no have mysql or sql server database, I think you should try use server vercel ^^

i was using vercel server all this while it was working, it stopped today

how do i use proxies?

Implement as follows
Specify 152.26.229.66:9443 for the proxy IP.

const ytdl = require('@distube/ytdl-core');
const url = 'https://www.youtube.com/watch?v=' + videoId;

const agent = ytdl.createProxyAgent({
    uri: "http://" + proxyIp,
});
const info = await ytdl.getInfo(url, {
    agent,
});

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^
This is API temp, I will delete it after 2 hour

how do i use proxies?

Implement as follows Specify 152.26.229.66:9443 for the proxy IP.

const ytdl = require('@distube/ytdl-core');
const url = 'https://www.youtube.com/watch?v=' + videoId;

const agent = ytdl.createProxyAgent({
    uri: "http://" + proxyIp,
});
const info = await ytdl.getInfo(url, {
    agent,
});

thanks dude let me try it

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^

Very nice. I am curious how you implement it.

how do i use proxies?

Implement as follows Specify 152.26.229.66:9443 for the proxy IP.

const ytdl = require('@distube/ytdl-core');
const url = 'https://www.youtube.com/watch?v=' + videoId;

const agent = ytdl.createProxyAgent({
    uri: "http://" + proxyIp,
});
const info = await ytdl.getInfo(url, {
    agent,
});

this proxy doesn't work locally i get connect timeout error

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^ This is API temp, I will delete it after 2 hour

But, still can't bypass 403 the url video/audio

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^

Very nice. I am curious how you implement it.

As I have said above, I do steps bellow :
Step 1, Go to :https://chrome.google.com/webstore/detail/fngmhnnpilhplaeedifhccceomclgfbg and install it;
Step 2, Go to Youtube, then login,next in icon EditCookie, choose export data ;
Step 3 Paste cookie to file: cookies.json in root project
NestJS Code:

import * as ytdl from '@distube/ytdl-core';
import axios from 'axios';
import * as fs from 'fs';
import * as path from 'path';

export class YouTubeService  implements OnModuleInit {
  constructor() {
    super();
  }
 }
  private agent: ytdl.Agent;

  onModuleInit() {
    this.initializeAgent();
  }
    private initializeAgent() {
    const cookiesPath = path.join(__dirname, '..', 'cookies.json');
    const cookiesContent = fs.readFileSync(cookiesPath, 'utf8');
    this.agent = ytdl.createAgent(JSON.parse(cookiesContent));
  }
  getAgent(): ytdl.Agent {
    return this.agent;
  }
  
   protected async downloadYoutube(youtubeLink: any, ipAddress: string) {
    try {
      if (!ytdl.validateURL(youtubeLink)) {
        throw new Error('Youtube url not invalid');
      }
      const agent = await this.getAgent();
      const info = await ytdl.getInfo(youtubeLink, { agent });
      const videoFormat = ytdl.chooseFormat(info.formats, {
        quality: 'highestvideo',
        filter: 'videoandaudio',
      });

      if (videoFormat && videoFormat.container === 'mp4') {
        return {
          title: info.videoDetails.title,
          channelId: info.videoDetails.channelId,
          artist: info.videoDetails.author.name,
          verified: info.videoDetails.author.verified,
          category: info.videoDetails.category,
          description: info.videoDetails.description,
          keywords: info.videoDetails.keywords,
          thumbnails: info.videoDetails.thumbnails
     
        };
      } else {
        throw new Error('Error');
      }
    } catch (err) {
      return {
        message: 'Server error',
        error: err.message,
      };
    }
  }

My Server : VPS or Vercel

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^ This is API temp, I will delete it after 2 hour

But, still can't bypass 403 the url video/audio

Can you have give me id youtube ?

this proxy doesn't work locally i get connect timeout error

Indeed, locally the proxy does not work...
However, I don't know why, but it works when deployed to Glitch, etc.

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^ This is API temp, I will delete it after 2 hour

But, still can't bypass 403 the url video/audio

oh let me check

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^ This is API temp, I will delete it after 2 hour

But, still can't bypass 403 the url video/audio

oh let me check

Try this one 11JI_2dQZqU

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^ This is API temp, I will delete it after 2 hour

But, still can't bypass 403 the url video/audio

oh let me check

Try this one 11JI_2dQZqU

image

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^ This is API temp, I will delete it after 2 hour

But, still can't bypass 403 the url video/audio

oh let me check

Try this one 11JI_2dQZqU

image

Local or server? I try before, 403

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^ This is API temp, I will delete it after 2 hour

But, still can't bypass 403 the url video/audio

oh let me check

Try this one 11JI_2dQZqU

Oh some video HD, FULL HD url get error 403

I you no have mysql or sql server database, I think you should try use server vercel ^^

I had deployed an app with ytdl-core to a serverless function in Vercel, but this error prevented it from working. I tried changing cookies, creating a new account, etc., but it did not work and now using a proxy is working.

You can have check my API at here : https://api.phuongmychi.vn/v3/video-stream?id=cSofAIqJ7mE ^^ This is API temp, I will delete it after 2 hour

But, still can't bypass 403 the url video/audio

oh let me check

Try this one 11JI_2dQZqU

Oh some video HD, FULL HD url get error 403

Try the audio also

this proxy doesn't work locally i get connect timeout error

Indeed, locally the proxy does not work... However, I don't know why, but it works when deployed to Glitch, etc.

ok, i wanna deploy to vercel and render i hope it works there if not i don't know what else to do

ok, i wanna deploy to vercel and render i hope it works there if not i don't know what else to do

So far my app (Vercel Serverless Function) is working well with proxies. (It is unstable compared to before...)
If the proxies listed before don't work, try the following IP addresses.

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

I just got the URL for the video from my API, so please test if you can view it.

Worked for me. Although made me want to throw up a little.

I just got the URL for the video from my API, so please test if you can view it.

Worked for me. Although made me want to throw up a little.

By using a proxy, I can avoid 403 errors, etc. But instead, the proxy is unstable, so my API is getting errors for about 20% of all requests... (processing is too slow and times out (15 seconds))

ok, i wanna deploy to vercel and render i hope it works there if not i don't know what else to do

So far my app (Vercel Serverless Function) is working well with proxies. (It is unstable compared to before...) If the proxies listed before don't work, try the following IP addresses.

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

the proxy works in vercel, but one of my routes get timed out, i'm checking out whether it will timeout on render now

ok, i wanna deploy to vercel and render i hope it works there if not i don't know what else to do

So far my app (Vercel Serverless Function) is working well with proxies. (It is unstable compared to before...) If the proxies listed before don't work, try the following IP addresses.

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

the proxy works in vercel, but one of my routes get timed out, i'm checking out whether it will timeout on render now

You should upgrade to vercel $20/month for setup timeout 30s, or optimize timeout 10s , because vercel free is 10s timeout

ok, i wanna deploy to vercel and render i hope it works there if not i don't know what else to do

So far my app (Vercel Serverless Function) is working well with proxies. (It is unstable compared to before...) If the proxies listed before don't work, try the following IP addresses.

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

the proxy works in vercel, but one of my routes get timed out, i'm checking out whether it will timeout on render now

You should upgrade to vercel $20/month for setup timeout 30s, or optimize timeout 10s , because vercel free is 10s timeout

as of the time i sent that message till now, even with the render url, the route is still loading, it hasn't error'ed but it is still loading so upgrading vercel won't work idk if i should just abandon it

ok, i wanna deploy to vercel and render i hope it works there if not i don't know what else to do

So far my app (Vercel Serverless Function) is working well with proxies. (It is unstable compared to before...) If the proxies listed before don't work, try the following IP addresses.

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

the proxy works in vercel, but one of my routes get timed out, i'm checking out whether it will timeout on render now

You should upgrade to vercel $20/month for setup timeout 30s, or optimize timeout 10s , because vercel free is 10s timeout

as of the time i sent that message till now, even with the render url, the route is still loading, it hasn't error'ed but it is still loading so upgrading vercel won't work idk if i should just abandon it

oh i think i know what is going on, the stream doesn't show even with proxy, only details

oh i think i know what is going on, the stream doesn't show even with proxy, only details

Can you show me the code you implemented?

oh i think i know what is going on, the stream doesn't show even with proxy, only details

Can you show me the code you implemented?

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

In the specific route:

    const filter = req.query.filter === 'mp3' ? 'audioonly':'audioandvideo' ;
        const stream = yt(req.query.link, { filter: filter, agent: agent})
        let bytes = 0
        stream.on("data", (chunk)=>{
            bytes += chunk.length;
        })
        stream.on("end", ()=>{
            console.log(bytes)
            res.send(`${formatBytes(bytes)}`)
        })

not working with cookie and proxy?

not working with cookie and proxy?

in proxy only info works

This probably depends on the internal internet speed of the server; the following implementation on a Glitch server works fine.
Actual example: http://marsh-numerous-oak.glitch.me/chunk?ytid=dQw4w9WgXcQ
(It will not be loaded immediately.)

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

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

const stream = ytdl(url, {
    filter: "videoandaudio",
    agent,
    requestOptions: {
        headersTimeout: 1000 * 10, // 10 Seconds
        bodyTimeout: 1000 * 10, // 10 Seconds
        headers: {
            referer: "https://www.youtube.com/",
        },
    },
});

res.setHeader("Content-Type", "video/mp4");

stream.on("data", (chunk) => {
    // bytes += chunk.length;
    res.write(chunk);
});

stream.on("end", () => {
    // res.send(`${formatBytes(bytes)}`);
    res.end();
});

Adding cookies did not work initially but then creating cookies with a youtube premium account worked.

Adding cookies did not work initially but then creating cookies with a youtube premium account worked.

Is the cookie running locally? Or is it running on a VPS (server)?

A função funciona sem cookies e sem proxies no termux, mas quando Upo para o servidor, já não funciona, alguém conhece algum outra função? Se conhecerem, por favor compartilhe conosco!

A função funciona sem cookies e sem proxies no termux, mas quando Upo para o servidor, já não funciona, alguém conhece algum outra função? Se conhecerem, por favor compartilhe conosco!

Is termux running locally?
In most cases, it works properly locally.

A função funciona sem cookies e sem proxies no termux, mas quando Upo para o servidor, já não funciona, alguém conhece algum outra função? Se conhecerem, por favor compartilhe conosco!

O termux está sendo executado localmente? Na maioria dos casos, funciona corretamente localmente.

Sim, você conhece algum outro módulo?

Sim, você conhece algum outro módulo?

Please let me know what you would like to implement using ytdl-core. The example I provided is to stream video, so it may not work in some environments.

Hello, i was doing everything but my download from nuxt in the server

`//import ytdl from 'ytdl-core';
import ytdl from '@distube/ytdl-core';
import { sanitizeHeaderContent } from '/utils';
import { cookiesUtil } from '
/utils/cookies';

export default defineEventHandler(async (event) => {
const body = await readBody(event);
const videoURL = body.url; // El parámetro 'url' se espera en la consulta
if (!videoURL || !ytdl.validateURL(videoURL)) {
throw { message: 'URL de video de YouTube no válida' };
}

const agent = ytdl.createAgent(cookiesUtil);
const info = await ytdl.getInfo(videoURL, { agent });
const title = sanitizeHeaderContent(info.videoDetails.title);
const format = ytdl.chooseFormat(info.formats, { quality: 'highest' });

event.res.setHeader('Content-Disposition', attachment; filename="${title}.mp4");
event.res.setHeader('filename', ${title}.mp4);
const stream = ytdl(videoURL, {
format: format,
requestOptions: {
//maxReconnects: 5,
//maxRetries: 3,
highWaterMark: 1 << 25,
},
})
console.log("Download?")
return stream.pipe(event.res);
});
`
there is the my example, all is okay, show the console.log() but never end :c so never get the download

Hello, i was doing everything but my download from nuxt in the server
there is the my example, all is okay, show the console.log() but never end :c so never get the download

I have looked at the code and it does not seem to use a proxy. So far the cookie only works locally in most cases.
Please change ytdl.createAgent to ytdl.createProxyAgent({uri: 'http://152.26.229.66:9443'}) and try it.
In my case, it works by implementing it as shown in the image. (Server)
code

BROOOUUU Thank you so much! is some strange, because in my local does not working with proxies jajaja, but in the server yes, so thank you bro, this is in Nuxt Server, really works

For download Mp4
image

For download Mp3
image

Really thank you so much

Really thank you so much

You're welcome. There is one thing I am wondering about though. You commented out the format in the stream variable, which I don't think needs to be commented out.

const stream = ytdl(videoURL, {
    //format: foramt, <- this
    filter: ....
    ....
})

i try it with format, but never download the video/music, so i comment the variable format and works fine, idk what happens, but your code really works for me, and i hope work for other developers

i try it with format, but never download the video/music, so i comment the variable format and works fine, idk what happens, but your code really works for me, and i hope work for other developers

I see :)
Keep up the good work!

Hi, I am currently using the following methods in our application: ytdl.getBasicInfo, ytdl.getInfo, ytdl.getURLVideoID, ytdl.downloadFromInfo, ytdl.filterFormats, and ytdl.chooseFormat. After implementing the suggested changes, we've encountered the following errors:

  1. Without a proxy server: We receive an UnrecoverableError: Sign in to confirm you’re not a bot.
  2. With public proxies added: We encounter an UnrecoverableError: This video is unavailable.
  3. Intermittently: We are also seeing request timeout errors.
    Any assistance with resolving these issues would be greatly appreciated.

Thanks!

Hi, I am currently using the following methods in our application: ytdl.getBasicInfo, ytdl.getInfo, ytdl.getURLVideoID, ytdl.downloadFromInfo, ytdl.filterFormats, and ytdl.chooseFormat. After implementing the suggested changes, we've encountered the following errors:

  1. Without a proxy server: We receive an UnrecoverableError: Sign in to confirm you’re not a bot.
  2. With public proxies added: We encounter an UnrecoverableError: This video is unavailable.
  3. Intermittently: We are also seeing request timeout errors.
    Any assistance with resolving these issues would be greatly appreciated.

Thanks!

Can you tell me what code you are implementing or the IP address of the proxy you are using?
Also, the timeout depends on the proxy, so I think the only way is to use a better proxy.

Hi, I am currently using the following methods in our application: ytdl.getBasicInfo, ytdl.getInfo, ytdl.getURLVideoID, ytdl.downloadFromInfo, ytdl.filterFormats, and ytdl.chooseFormat. After implementing the suggested changes, we've encountered the following errors:

  1. Without a proxy server: We receive an UnrecoverableError: Sign in to confirm you’re not a bot.
  2. With public proxies added: We encounter an UnrecoverableError: This video is unavailable.
  3. Intermittently: We are also seeing request timeout errors.
    Any assistance with resolving these issues would be greatly appreciated.

Thanks!

Can you tell me what code you are implementing or the IP address of the proxy you are using? Also, the timeout depends on the proxy, so I think the only way is to use a better proxy.

curl --location 'https://api.phuongmychi.vn/v3/video-stream?id=11JI_2dQZqU' \
--header 'accept: application/json, text/plain, */*' \
--header 'accept-language: vi,en;q=0.9,vi-VN;q=0.8,fr-FR;q=0.7,fr;q=0.6,en-US;q=0.5' \
--header 'author: phuongmychimusic' \
--header 'origin: https://phuongmychi.vn'

You can try it, but some video/audio type webm is 403, else anything working fine

curl --location 'https://api.phuongmychi.vn/v3/video-stream?id=11JI_2dQZqU' \
--header 'accept: application/json, text/plain, */*' \
--header 'accept-language: vi,en;q=0.9,vi-VN;q=0.8,fr-FR;q=0.7,fr;q=0.6,en-US;q=0.5' \
--header 'author: phuongmychimusic' \
--header 'origin: https://phuongmychi.vn'

You can try it, but some video/audio type webm is 403, else anything working fine

Thank you very much. Also, I noticed one important thing.
The query parameter for URLs that return 403 has c=ANDROID set, and the URLs that can be viewed have c=IOS set! The ones with c=ANDROID set are almost all WebM codecs, and most, but not all, return 403.
Currently it is a good idea to exclude these.

Por favor, alguém pode corrigir essa função:

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

    const stream = ytdl("https://youtube.com/watch?v=" + firstResult.videoId, {
        filter: "audioonly", // 
        
        agent,
        requestOptions: {
            headersTimeout: 1000 * 10, 
            bodyTimeout: 1000 * 10,  
            headers: {},
            referer: "https://www.youtube.com/",
        },
    });

    const VidName = await getRandom('.mp3');
    const path = `Del/${VidName}`;
    const writer = fs.createWriteStream(path);

    stream.pipe(writer);

    writer.on("finish", async () => {
        writer.close();
        console.log("Download Completed!");

        await conn.sendMessage(from, { audio: { url: path }, mimetype: "audio/mpeg" }, { quoted: info });

        await fs.unlinkSync(path);
    });
} catch (error) {
    console.error(error);
    reply("Ocorreu um erro ao processar seu pedido.");
}
break;

}

Por favor, alguém pode corrigir essa função:

What error is occurring? Please provide details.

You can try it, but some video/audio type webm is 403, else anything working fine

Thank you very much. Also, I noticed one important thing. The query parameter for URLs that return 403 has c=ANDROID set, and the URLs that can be viewed have c=IOS set! The ones with c=ANDROID set are almost all WebM codecs, and most, but not all, return 403. Currently it is a good idea to exclude these.

URLs with the query parameter of c=ANDROID are initially viewable, but after opening a URL with c=IOS, the URL with c=ANDROID stops working with a 403 and only the URL with c=IOS works.
I don't think this is a coincidence.

Por favor, alguém pode corrigir essa função:

Que erro está ocorrendo? Por favor, forneça detalhes.

No servidor não aparece erro, porém não faz download do áudio. No local aparece esse erro:

Connect Timeout Error
ConnectTimeoutError: Connect Timeout Error

Por favor, alguém pode corrigir essa função:

Que erro está ocorrendo? Por favor, forneça detalhes.

No servidor não aparece erro, porém não faz download do áudio. No local aparece esse erro:

Connect Timeout Error ConnectTimeoutError: Connect Timeout Error

I don't know why, but proxies do not work locally. Local is recommended to use cookies or some other method.

Por favor, alguém pode corrigir essa função:

Que erro está ocorrendo? Por favor, forneça detalhes.

No servidor não aparece erro, porém não faz download do áudio. No local aparece esse erro:
Erro de tempo limite de conexão ConnectTimeoutError: Erro de tempo limite de conexão

Não sei por que, mas os proxies não funcionam localmente. Recomenda-se o uso de cookies ou algum outro método.

Mas no servidor também não está funcionando, não está dando resposta alguma

Mas no servidor também não está funcionando, não está dando resposta alguma

Then try another proxy.

  1. 152.26.229.42:9443
  2. 152.26.229.66:9443
  3. 152.26.229.86:9443
  4. 152.26.229.88:9443
  5. 152.26.231.42:9443
  6. 152.26.231.77:9443
  7. 152.26.231.86:9443

Thank you very much. Also, I noticed one important thing. The query parameter for URLs that return 403 has c=ANDROID set, and the URLs that can be viewed have c=IOS set! The ones with c=ANDROID set are almost all WebM codecs, and most, but not all, return 403. Currently it is a good idea to exclude these.

URLs with the query parameter of c=ANDROID are initially viewable, but after opening a URL with c=IOS, the URL with c=ANDROID stops working with a 403 and only the URL with c=IOS works. I don't think this is a coincidence.

Update: Once opened, almost all URLs containing c=ANDROID will return 403.

Mas no servidor também não está funcionando, não está dando resposta alguma

Em seguida, tente outro proxy.

  1. 152.26.229.42:9443
  2. 152.26.229.66:9443
  3. 152.26.229.86:9443
  4. 152.26.229.88:9443
  5. 152.26.231.42:9443
  6. 152.26.231.77:9443
  7. 152.26.231.86:9443

Nenhum fez o download do áudio, apenas criou áudios vazios dentro da pasta:

case 'p': {
const Results = await yts(args.join(" "));
const firstResult = Results.all[0];
try {
const proxies = [
"152.26.229.42:9443",
"152.26.229.66:9443",
"152.26.229.86:9443",
"152.26.229.88:9443",
"152.26.231.42:9443",
"152.26.231.77:9443",
"152.26.231.86:9443"
];
function getRandomProxy() {
const randomIndex = Math.floor(Math.random() * proxies.length);
return proxies[randomIndex];
}
const proxyUri = getRandomProxy();
console.log("Usando proxy:", proxyUri);
const agent = ytdl.createProxyAgent({
uri: http://${proxyUri},
});
const stream = ytdl("https://youtube.com/watch?v=" + firstResult.videoId, {
filter: "audioonly",
agent,
requestOptions: {
headersTimeout: 1000 * 10,
bodyTimeout: 1000 * 10,
headers: {},
referer: "https://www.youtube.com/",
},
});
const VidName = await getRandom('.mp3');
const path = Del/${VidName};
const writer = fs.createWriteStream(path);
stream.pipe(writer);
writer.on("finish", async () => {
writer.close();
console.log("Download Completed!");
await conn.sendMessage(from, { audio: { url: path }, mimetype: "audio/mpeg" }, { quoted: info });
await fs.unlinkSync(path);
});
} catch (error) {
console.error(error);
reply("Ocorreu um erro ao processar seu pedido.");
}
break;
}

Nenhum fez o download do áudio, apenas criou áudios vazios dentro da pasta:

What is the value of the VidName? Also, are you running that app on a server?
It is a Glitch server and works properly in the example I implemented. (Express)
https://marsh-numerous-oak.glitch.me/chunk?ytid=dQw4w9WgXcQ

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

const stream = ytdl(url, {
    filter: "audioonly",
    agent,
    requestOptions: {
        headersTimeout: 1000 * 10, // 10 Seconds
        bodyTimeout: 1000 * 10, // 10 Seconds
        headers: {
            referer: "https://www.youtube.com/",
        },
    },
});

res.setHeader("Content-Type", "video/mp4");
stream.pipe(res);

Nenhum fez o download do áudio, apenas criou áudios vazios dentro da pasta:

Qual é o valor do ? Além disso, você está executando esse aplicativo em um servidor? É um servidor Glitch e funciona corretamente no exemplo que implementei. (Expresso) https://marsh-numerous-oak.glitch.me/chunk?ytid=dQw4w9WgXcQ`VidName`

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

const stream = ytdl(url, {
    filter: "audioonly",
    agent,
    requestOptions: {
        headersTimeout: 1000 * 10, // 10 Seconds
        bodyTimeout: 1000 * 10, // 10 Seconds
        headers: {
            referer: "https://www.youtube.com/",
        },
    },
});

res.setHeader("Content-Type", "video/mp4");
stream.pipe(res);

Uso na aws

Understood. Once you do, try to run the ytdl.getInfo function instead of the ytdl function. That should get you the URL of the audio.
If you can open it successfully, then there is a problem with the file writing (fs).

ybd-project

Hello bro can you help to create yt-dl core api i am previously using node ytdl core api this one is not working last 1 month. I have my old api code and please upgrade it with new one. please help me and share your email address i send you my api code

Hello bro can you help to create yt-dl core api i am previously using node ytdl core api this one is not working last 1 month. I have my old api code and please upgrade it with new one. please help me and share your email address i send you my api code

I understand. I can help as I am also using ytdl-core to create an API.
My email address is =========. Please contact me.

Hello bro can you help to create yt-dl core api i am previously using node ytdl core api this one is not working last 1 month. I have my old api code and please upgrade it with new one. please help me and share your email address i send you my api code

I understand. I can help as I am also using ytdl-core to create an API. My email address is ybd.project@gmail.com. Please contact me.

Please sir i send you my api code in your email please check it. and helo me to update the lastest distube ytdlcore code.

I checked the code.
I can't work on it right now due to a few things, so it will be about 6 hours before I can send you the completed code.

I checked the code. I can't work on it right now due to a few things, so it will be about 6 hours before I can send you the completed code.

ok bro done i am waiting :)
Thank you so much for cooperate with me

You're welcome.
I'll do my best!

Many thanks to @ybd-project for the support and patience :'3

Many thanks to @ybd-project for the support and patience :'3

You you right bro very thankfull to this man

Many thanks to @ybd-project for the support and patience :'3

You you right bro very thankfull to this man

I have sent you the implemented code. Please check it.

Hello bro please see the email i have an error