node-ytdl-core: SyntaxError: Missing catch or finally after try

Code :-

const ytdl = require('ytdl-core');

ytdl.getInfo('http://www.youtube.com/watch?v=aqz-KE-bpKQ')
.then( d => console.log(d))
.catch(e => console.error(e));

Expected Behaviour log the video info

Ouptut on Console

evalmachine.<anonymous>:24
c[72],c[6]),(0,c[85])(c[11]),(0,c[41])(c[39],c[28],(0,c[66])()),(0,c[78])(c[Math.pow(6,2)+122+-119],c[new Date("Wednesday December 31 1969 19:00:14 CDT")/1E3])}catch(d){(0<c[0]||(((0,c[80])(c[60],c[88]),c[80])(c[21],c[88]),0))&&(0,c[17])((0,c[70])(c[6]),c[78],c[88],c[12])}try{2<c[91]&&(1<c[53]?(0,c[17])((0,c[80])(c[82],c[6]),c[78],c[39],c[5]):((0,c[45])(c[49],c[88]),c[78])(c[88],c[86])),(0,c[17])((0,c[85])(c[31]),c[41],c[88],c[75],(0,c[35])())}catch(d){}};Wka(ncode);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ^

SyntaxError: Missing catch or finally after try
    at new Script (node:vm:100:7)
    at exports.decipherFormats (/storage/emulated/0/c/ytdl/node_modules/ytdl-core/lib/sig.js:116:51)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async exports.getInfo (/storage/emulated/0/c/ytdl/node_modules/ytdl-core/lib/info.js:401:17)

Node.js v18.7.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 26
  • Comments: 20 (1 by maintainers)

Commits related to this issue

Most upvoted comments

Rolling back to 4.10.0 fixes problem for me

PR for the Fix but missing “Maintainer approval” Also @greepSheep did a Fork with the Fix…you can see his fork in the PR below

PR: https://github.com/fent/node-ytdl-core/pull/1111

I’ve debugged the issue, it is thrown by this line

https://github.com/fent/node-ytdl-core/blob/11103be3ab373551bddd0938bc0bbaea033acb8e/lib/sig.js#L116

The issue stems from somewhere in this function

https://github.com/fent/node-ytdl-core/blob/11103be3ab373551bddd0938bc0bbaea033acb8e/lib/sig.js#L33-L73

Which appears to be transforming some compiled javascript code from youtube’s html5 player, the transformed code seems to have illegal syntax.

I can confirm 4.10.0 is working for me

@bwees I can confirm that downgrading to version 4.10.0 fixes the issue, but in my case the download speed decrease a lot. (6 minutes to download a 2 minutes video with a good internet connection).

🎉 This issue has been resolved in version 4.11.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

same issue for me. please fix it 😦

@noviardi1986 it seems like switching to the fork of the project https://github.com/GreepTheSheep/node-ytdl-core is the best option as of now until the changes in that fork get pulled in