node-ytdl-core: getInfo giving me 'Invalid or unexpected token' error
Trying to get the video information from ytdl.getInfo()
but I get SyntaxError: Invalid or unexpected token
instead.
Yes, I am using the latest version of ytdl-core.
Getting data via this code:
const videoData = await ytdl.getInfo(url); // url is: https://www.youtube.com/watch?v=SPzumRExEqw
Error that I am getting:
rma=function(a,b,c,d){var e=null;switch(b){case "JSON":try{var f=c.responseText}catch(h){throw d=Error("Error reading responseText"),d.params=a,bu(d),h;}a=c.getResponseHeader("Content-Type")||"";f&&0<=a.indexOf("json")&&(")]};Yka(ncode);
^^^^^^^^^^^^^^^^
SyntaxError: Invalid or unexpected token
at new Script (node:vm:100:7)
at Object.exports.decipherFormats (C:\Users\null\Desktop\yt-clips\node_modules\ytdl-core\lib\sig.js:116:51)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 0)
at async exports.getInfo (C:\Users\null\Desktop\yt-clips\node_modules\ytdl-core\lib\info.js:401:17)
It happened after getting data of the url approx 20 times, am I getting ratelimited? Thank you.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 37 (2 by maintainers)
https://github.com/fent/node-ytdl-core/blob/11103be3ab373551bddd0938bc0bbaea033acb8e/lib/sig.js#L63-L67
A temporary fix until someone finds a better solution.
downgrading to
4.9.1
fixes for meVersion 4.11.0 is working for me again
i’m having trouble with this problem
`Ama=function(a,b,c,d){var e=null;switch(b){case “JSON”:try{var f=c.responseText}catch(h){throw d=Error(“Error reading responseText”),d.params=a,oC(d),h;}a=c.getResponseHeader(“Content-Type”)||“”;f&&0<=a.indexOf(“json”)&&(")]};Ila(ncode); ^^^^^^^^^^^^^^^^
SyntaxError: Invalid or unexpected token at new Script (node:vm💯7) at Object.exports.decipherFormats (F:\www\revutool\node_modules\ytdl-core\lib\sig.js:116:51) at runMicrotasks (<anonymous>) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Promise.all (index 0) at exports.getInfo (F:\www\example\node_modules\ytdl-core\lib\info.js:401:17)`
Here’s a proper patch from @WaqasIbrahim’s changes:
This worked for me, applied inside the
node_modules/ytdl-core
folder.Go to
node_modules/@distube
deleteytdl-core
folder then open cmd and type this commandnpm i ytdl-core@4.9.1
. Go tonode_modules
and copyytdl-core
file and paste it intonode_modules/@distube
It works 100%.
Throttled to about 10mb a minute but its a good temporary fix. Much appreciated!
I am also just getting this issue out of the blue. I did not even update my ytdl-core. This seems like a major issue.
I had the error, then it went away… today it’s same stack trace but different error
4.11.0 btw
downgrading to v 4.10.0 worked for me
Thank you!
Same issue on v.4.11.5. Downgrading didn’t help Patches above didn’t help. Did youtube change smth or what happened?
(update)
this fixed it for me for now https://github.com/fent/node-ytdl-core/issues/1252#issuecomment-1711107133
@WaqasIbrahim Thanks for looking into this, FYI you’ve got a typo on line 3 of your fix,
index
should bendx
.