fent / node-ytdl-core

YouTube video downloader in javascript.
MIT License
4.48k stars 791 forks source link

403 error it stopped working #1295

Open Dmytro-Tihunov opened 2 months ago

Dmytro-Tihunov commented 2 months ago

Hey guys! it stopped working we need an update :)

red1ul commented 1 month ago

as I understand we all faced with new problem that is "Sign in to confirm you’re not a bot" and that means youtube asks for captcha, is there anybody who find solution?

I'm also encountering a similar issue where access to https://rr4---sn-qxaeenlz.googlevideo.com is being denied with a status code 403. Does anyone have a solution for this?

Dmytro-Tihunov commented 1 month ago

@corwin-of-amber in production youtube will ban your ip and ask for captcha, in local it works also

corwin-of-amber commented 1 month ago

Sorry @Dmytro-Tihunov, I have no idea what is this "production". I think your scenario is different from what most users are facing and reporting.

Dmytro-Tihunov commented 1 month ago

@corwin-of-amber in production it means deploy it and try to use, NOT LOCALLY )

corwin-of-amber commented 1 month ago

I assume by "deploy" you mean some cloud service...? It's just that I cannot see how this library fits into such a scenario, but it is entirely possible that Google have more strict limitations on requests originating from such IPs.

isaacs commented 1 month ago

I got around this by coping in the user-agent header from my browser. It seems to be blocking anything that doesn't smell browsery.

AliAryanTech commented 1 month ago

Guys it went down again

corwin-of-amber commented 1 month ago

https://github.com/fent/node-ytdl-core/issues/1301#issuecomment-2262484536

Someone should probably merge the issues.

gatecrasher777 commented 1 month ago

Just an observation, exploring this issue. On the YouTube website, videoplayback requests are now using POST method. And that GET method is forbidden on video files that are not shorts (<1 minute). The only GET requests that seem to work on longer videos files are 360p with audio and video combined.

Update: Regular downloading works up until 1 minute of video, thereafter, the servers require that requests have a post body that is an encoded uint8array comprising various metadata, config and cookie data, created by umpteen interlinked functions in base.js. Only the non-adaptive format streams and video streams less than one minute appear to work in HTML video tags.

It may be different on mobile devices.

hextor1 commented 1 month ago

no body share better patch code

gatecrasher777 commented 1 month ago

Innertube info (/youtubei/v1/player) requests post a copy of the session's context client. Solved my problems (at least for now) by modifying the client from web to non-web for videos with duration greater than 1 minute. No more 403s on adaptive streams and resulting video streams will also play in HTML video tags.

The problem with this library is that it does not use the innertube API so I am not sure how you can modify the client type on a watch page. But the watch page does provide everything you need to make a subsequent innertube API request with modified client for streams that will work.

hextor1 commented 1 month ago

Innertube info (/youtubei/v1/player) requests post a copy of the session's context client. Solved my problems (at least for now) by modifying the client from web to non-web for videos with duration greater than 1 minute. No more 403s on adaptive streams and resulting video streams will also play in HTML video tags.

The problem with this library is that it does not use the innertube API so I am not sure how you can modify the client type on a watch page. But the watch page does provide everything you need to make a subsequent innertube API request with modified client for streams that will work.

My friend is using innnertube js API. Its working fine no more 403 error last few months. so you mean we move to innertube API @gatecrasher777

gatecrasher777 commented 1 month ago

My friend is using innnertube js API. Its working fine no more 403 error last few months. so you mean we move to innertube API @gatecrasher777

Was thinking of doing a PR here, but I see that @distube/ytdl-core, a fork of this library already appears to do an ios innertube player request.

hextor1 commented 1 month ago

My friend is using innnertube js API. Its working fine no more 403 error last few months. so you mean we move to innertube API @gatecrasher777

Was thinking of doing a PR here, but I see that @distube/ytdl-core, a fork of this library already appears to do an ios innertube player request.

So what should we do now? Whats the next steps?

gatecrasher777 commented 1 month ago

So what should we do now? Whats the next steps?

I don't know what your use case is, but while this issue persists I would suggest using https://github.com/distubejs/ytdl-core . It is also on NPM so it should be relatively easy to replace this library in your js/node projects.

There is a non-zero probability that YouTube will also put similar restrictions on non-web clients in the near future. If that happens I will try and crack the POST body encoding which happens with regular web client streaming on the YouTube website. But for now this non-web workaround is good enough for my projects.

hextor1 commented 1 month ago

do you have you email address i wanna sending you my API code and you can check it and let me know what we need to change?

gatecrasher777 commented 1 month ago

do you have you email address i wanna sending you my API code and you can check it and let me know what we need to change?

AFAIK email is on my profile.

TechBroCode commented 1 month ago

@navetacandra Ok thanks, btw will my youtube data api key will work here

It should work but DON'T restrict your API key so that it'll work for all platforms...

hextor1 commented 1 month ago

do you have you email address i wanna sending you my API code and you can check it and let me know what we need to change?

AFAIK email is on my profile.

Hello I send API code to your email address please check it and let me know

TechBroCode commented 1 month ago

Guys it went down again

I'm facing same issue, @distube isn't working properly... I'm still receiving 403 page instead

TechBroCode commented 1 month ago

So what should we do now? Whats the next steps?

I don't know what your use case is, but while this issue persists I would suggest using https://github.com/distubejs/ytdl-core . It is also on NPM so it should be relatively easy to replace this library in your js/node projects.

There is a non-zero probability that YouTube will also put similar restrictions on non-web clients in the near future. If that happens I will try and crack the POST body encoding which happens with regular web client streaming on the YouTube website. But for now this non-web workaround is good enough for my projects.

Please, check it. It didn't work few hours ago

gatecrasher777 commented 1 month ago

Please, check it. It didn't work few hours ago

Downloaded latest version of @Distube/ytdl-core

Ran

const fs = require('fs');
const ytdl = require('./lib/index.js');
ytdl('http://www.youtube.com/watch?v=4jnaYhnmYlo')
  .pipe(fs.createWriteStream('video.mp4'));

No errors. Got

2024/08/07  14:10       191 108 392 video.mp4

Ran a similar test in #1301 with this original project (after replacing the extractNCode function) and it downloaded at 360p with sound.

@Distube downloaded a much higher quality video (1080p), but without sound, so clearly the adaptive streams are working because of it using a non-web client call to the innertube API.

Lampropoulosss commented 1 month ago

Please, check it. It didn't work few hours ago

Downloaded latest version of @Distube/ytdl-core

Ran

const fs = require('fs');
const ytdl = require('./lib/index.js');
ytdl('http://www.youtube.com/watch?v=4jnaYhnmYlo')
  .pipe(fs.createWriteStream('video.mp4'));

No errors. Got

2024/08/07  14:10       191 108 392 video.mp4

Ran a similar test in #1301 with this original project (after replacing the extractNCode function) and it downloaded at 360p with sound.

@Distube downloaded a much higher quality video (1080p), but without sound, so clearly the adaptive streams are working because of it using a non-web client call to the innertube API.

I can verify, @distube/ytdl-core works without any issues.

hextor1 commented 1 month ago

@distube is not working and no code is working

gatecrasher777 commented 1 month ago

@Distube is not working and no code is working

See https://github.com/distubejs/ytdl-core/issues/76

hextor1 commented 1 month ago

@Distube is not working and no code is working

See distubejs#76

Hello please share your email I wanna send you my API code and you add the cookie code then I will add the cookie can you help me?

corwin-of-amber commented 1 month ago

This is a different problem. It is not related to the nTransform anymore. I am getting 403 for all but one of the formats. The getInfo does go through, and I am not getting the "sign in to prove you are not a bot" error, though.

gatecrasher777 commented 1 month ago

This is a different problem. It is not related to the nTransform anymore. I am getting 403 for all but one of the formats. The getInfo does go through, and I am not getting the "sign in to prove you are not a bot" error, though.

For me, Innertube player requests with a non-web client are still working fine for downloading adaptive streams. But not for some (https://github.com/distubejs/ytdl-core/issues/76).