distubejs / ytdl-core

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

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

Open Xing-Deal opened 1 month ago

Xing-Deal commented 1 month ago

Describe the bug

Debug File

Environment

ybd-project commented 1 month ago

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)
gatecrasher777 commented 1 month ago

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.

ybd-project commented 1 month ago

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))

MikeyA-yo commented 1 month ago

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

thind9xdev commented 1 month ago

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

MikeyA-yo commented 1 month ago

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

MikeyA-yo commented 1 month ago

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

ybd-project commented 1 month ago

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?

MikeyA-yo commented 1 month ago

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)}`)
        })
hextor1 commented 1 month ago

not working with cookie and proxy?

MikeyA-yo commented 1 month ago

not working with cookie and proxy?

in proxy only info works

ybd-project commented 1 month ago

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();
});
offminded commented 1 month ago

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

ybd-project commented 1 month ago

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)?

tonykx commented 1 month ago

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!

ybd-project commented 1 month ago

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.

tonykx commented 1 month ago

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?

ybd-project commented 1 month ago

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.

EAxelGM commented 1 month ago

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

ybd-project commented 1 month ago

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

EAxelGM commented 1 month ago

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

ybd-project commented 1 month ago

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: ....
    ....
})
EAxelGM commented 1 month ago

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

ybd-project commented 1 month ago

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!

kumarsatish1984 commented 1 month ago

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!

ybd-project commented 1 month ago

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.

thind9xdev commented 1 month ago

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

ybd-project commented 1 month ago
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.

tonykx commented 1 month ago

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;

}

ybd-project commented 1 month ago

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

What error is occurring? Please provide details.

ybd-project commented 1 month ago

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.

tonykx commented 1 month ago

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

ybd-project commented 1 month ago

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.

tonykx commented 1 month ago

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

ybd-project commented 1 month ago

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
ybd-project commented 1 month ago

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.

tonykx commented 1 month ago

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; }

ybd-project commented 1 month ago

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);
tonykx commented 1 month ago

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

ybd-project commented 1 month ago

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).

hextor1 commented 1 month ago

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

ybd-project commented 1 month ago

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.

hextor1 commented 1 month ago

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.

ybd-project commented 1 month ago

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.

hextor1 commented 1 month ago

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

ybd-project commented 1 month ago

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

NeKosmico commented 1 month ago

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

hextor1 commented 1 month ago

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

You you right bro very thankfull to this man

ybd-project commented 1 month ago

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.

hextor1 commented 1 month ago

Hello bro please see the email i have an error