distubejs / ytdl-core

YouTube video downloader in javascript.
MIT License
261 stars 48 forks source link

Request Error With Status 403 #92

Closed Talhary closed 3 days ago

Talhary commented 2 months ago

Describe the bug

I got the Urls of Videos But the urls doesn't work they return 403. I checked in browser , with axios and fetch. All return same error.

Debug File

export const downloadVideo = async (url, quality) => {
const res = await ytdl.getInfo(url,{agent});
const title = res['player_response']['videoDetails']['title']
const formate = res['player_response']['streamingData']['formats']
// console.log(formate)
const adaptiveFormate = res['player_response']['streamingData']['adaptiveFormats'].map(format=>{
  return {itag: format.itag,mimeType:format.mimeType, url: format.url, quality: format.qualityLabel, width: format.width, height: format.height}
})
const data = adaptiveFormate.filter(f=>{
  if(!quality ) return f;
  return f.height >= quality 
})
if(!data.length)
return {title: title, urls: formate[0] };

return {title: title,urls:data[data.length-1] };
}

Environment

miketuannguyen commented 2 months ago

Try using cookie https://github.com/distubejs/ytdl-core?tab=readme-ov-file#cookies-support. In my case, it works.

Talhary commented 2 months ago

Try using cookie https://github.com/distubejs/ytdl-core?tab=readme-ov-file#cookies-support. In my case, it works.

Already using cookies. But I removed the localhost part from userAgent options. because with it I am getting Error. Failed to Connect or something like that

luthfipun commented 2 months ago

try update decipher https://github.com/distubejs/ytdl-core/issues/91#issuecomment-2290360827

Talhary commented 2 months ago

try update decipher #91 (comment)

Already Tried Doesn't work

xaksis commented 2 months ago

Try using cookie https://github.com/distubejs/ytdl-core?tab=readme-ov-file#cookies-support. In my case, it works.

@miketuannguyen Could you tell me, what version of ytdl-core are you using?

Talhary commented 2 months ago

Try using cookie https://github.com/distubejs/ytdl-core?tab=readme-ov-file#cookies-support. In my case, it works.

@miketuannguyen Could you tell me, what version of ytdl-core are you using?

Latest I installed it yesterday

xaksis commented 2 months ago

I'm experiencing the same issue as you, @Talhary. My question was for @miketuannguyen to see if he's on a different version that is working.

Talhary commented 2 months ago

I'm experiencing the same issue as you, @Talhary. My question was for @miketuannguyen to see if he's on a different version that is working.

oh. I didn't see that name.

miketuannguyen commented 2 months ago

I'm experiencing the same issue as you, @Talhary. My question was for @miketuannguyen to see if he's on a different version that is working.

I'm using the latest version of @distubejs/ytdl-core. Please read carefully the instruction and follow it. The first time I tried using cookie, it doesn't work. But, in the second time, I follow the instruction more carefully and it works like a charm. I also didn't remove localhost part or any part from the cookie i got.

xaksis commented 2 months ago

@Talhary where is your code hosted? I have my stuff on gcp and I think youtube is now blocking data warehouse IPs which is why this doesn't seem to work anymore. Not sure what the fix could be other than using a proxy that works.

EmilianoTalamo commented 2 months ago

I'm using both proxy and cookies. It works fine locally but once deployed to AWS it gets blocked.