SuspiciousLookingOwl / youtubei

Get Youtube data such as videos, playlists, channels, video information & comments, related videos, up next video, and more!
https://suspiciouslookingowl.github.io/youtubei
MIT License
226 stars 50 forks source link

Error in makeSummary: invalid json response body at https://www.google.com/sorry/index?continue=https://www.youtube.com/watch%3FprettyPrint%3Dfalse%26v%3D5A8UUovaSb8%26pbj%3D1&q=EgQDgW_cGKyZ9bEGIjDIbez6kcN4Ofhrrbcfy2T6brx1CtlOvEP6CvOF0rtGbElS0CP3ISqeUAkwFsUF2MgyAXJaAUM reason: Unexpected token '<', "<!DOCTYPE "... is not valid JSON #97

Open jenny4711 opened 4 months ago

jenny4711 commented 4 months ago

Describe the bug Error in makeSummary: invalid json response body at https://www.google.com/sorry/index?continue=https://www.youtube.com/watch%3FprettyPrint%3Dfalse%26v%3D5A8UUovaSb8%26pbj%3D1&q=EgQDgW_cGKyZ9bEGIjDIbez6kcN4Ofhrrbcfy2T6brx1CtlOvEP6CvOF0rtGbElS0CP3ISqeUAkwFsUF2MgyAXJaAUM reason: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

Until a few days ago, it was working fine, but since 4-5 days ago, this error has been coming up. If you remove youtubei, that error does not appear. However, because I need a transcript, I have to use youtubei, so I am reporting this issue. my function const youtube = new Client(); async function makeSummary(req,res){ const { videoId, lang, ask, email } = req.body; ..... const transcript = await youtube.getVideoTranscript(videoId); console.log(transcript,'transcript')

} result Error in makeSummary: invalid json response body at https://www.google.com/sorry/index?continue=https://www.youtube.com/watch%3FprettyPrint%3Dfalse%26v%3D5A8UUovaSb8%26pbj%3D1&q=EgQDgW_cGKyZ9bEGIjDIbez6kcN4Ofhrrbcfy2T6brx1CtlOvEP6CvOF0rtGbElS0CP3ISqeUAkwFsUF2MgyAXJaAUM reason: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

SuspiciousLookingOwl commented 4 months ago

This works fine on my end

const client = new Client();
const transcript = await client.getVideoTranscript("5A8UUovaSb8");
console.log(transcript);

It seems like your error is caused by YouTube detecting your IP as malicious (can be caused by sending too many requests with the same IP, using a VPN, or other stuff). Unfortunately, there's nothing I can do (of which I'm aware) to work around this.

jacksonh commented 4 months ago

I'm getting this on all requests now too. I wonder if Google recently deployed something for this.

jacksonh commented 4 months ago

I'm getting this on all requests now too. I wonder if Google recently deployed something for this.

> await client.getVideoTranscript("5A8UUovaSb8"); 
Uncaught:
[FetchError: invalid json response body at https://www.youtube.com/api/timedtext?v=5A8UUovaSb8&ei=sIFDZq6xFOy52roPnd2MkAc&caps=asr&opi=112496729&exp=xbt&xoaf=5&hl=en-GB&ip=0.0.0.0&ipbits=0&expire=1715725344&sparams=ip%2Cipbits%2Cexpire%2Cv%2Cei%2Ccaps%2Copi%2Cexp%2Cxoaf&signature=CA50B3C8AC657AF47C19E376E92F4A3223DFD927.604DB09FF45AD34E2CE5F96AA9BAAEB2385D5828&key=yt8&kind=asr&lang=en&prettyPrint=false&fmt=json3 reason: Unexpected token < in JSON at position 0] {
  type: 'invalid-json'
}