node-ytdl-core icon indicating copy to clipboard operation
node-ytdl-core copied to clipboard

ReferenceError: MC is not defined

Open LostAndDead opened this issue 2 years ago • 9 comments

ReferenceError: MC is not defined
    at Xua (evalmachine.<anonymous>:1:36)
    at evalmachine.<anonymous>:1:165
    at Script.runInContext (node:vm:141:12)
    at Script.runInNewContext (node:vm:146:17)
    at url (c:\Users\jakem\Desktop\Code\MusicBot\Calliope\node_modules\ytdl-core\lib\sig.js:88:22)
    at Object.exports.setDownloadURL (c:\Users\jakem\Desktop\Code\MusicBot\Calliope\node_modules\ytdl-core\lib\sig.js:100:31)
    at <anonymous> (c:\Users\jakem\Desktop\Code\MusicBot\Calliope\node_modules\ytdl-core\lib\sig.js:118:13)
    at Array.forEach (<anonymous>)
    at Object.exports.decipherFormats (c:\Users\jakem\Desktop\Code\MusicBot\Calliope\node_modules\ytdl-core\lib\sig.js:117:11)
    at runMicrotasks (<anonymous>)

The latest version 4.11.2, happens with any song/video requested, I'm unable to trace it to anywhere specific in my code as the error is only within the node modules. Happens every time, and no video is downloaded/streamed. Has been working fine until yesterday with no problems, since yesterday it hasn't worked at all.

LostAndDead avatar Nov 30 '22 16:11 LostAndDead

Same here. Just out of the blue, without any changes or even restarts, this shows up.

I would assume something changed on YouTube's side

xenorio avatar Nov 30 '22 17:11 xenorio

For anyone needing a temporary workaround, you can define MC manually.

At ytdl-core/lib/sig.js:115, replace the decipherScript with the following:

const decipherScript = functions.length ? new vm.Script(`var MC={QO:function(a,b){var c=a[0];a[0]=a[b%a.length];a[b%a.length]=c},"if":function(a){a.reverse()},pn:function(a,b){a.splice(0,b)}};${functions[0]}`) : null;

I've created a fork with this fix, you can replace the dependency temporarily with:

{
  "dependencies": {
    "ytdl-core": "https://github.com/matteopolak/node-ytdl-core.git#d6b56cd67aaa38c22966b98f7b36ad3db4c90192"
  }
}

matteopolak avatar Nov 30 '22 17:11 matteopolak

@matteopolak Thank you very much, fork works great :)

xenorio avatar Nov 30 '22 18:11 xenorio

@matteopolak @LostAndDead Thank you! I was just starting to have the same issue.

kaddyadriano avatar Nov 30 '22 18:11 kaddyadriano

Thank you @matteopolak ! It's working

nextpier avatar Nov 30 '22 20:11 nextpier

@matteopolak ty so much

kilianpfr avatar Nov 30 '22 20:11 kilianpfr

Anyone know whats causing this issue? is it an update with youtube? Im not getting the same error but would like to be aware of why that could be happening

richardabear avatar Dec 01 '22 12:12 richardabear

Same

Pnlvfx avatar Dec 04 '22 21:12 Pnlvfx

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 18 '23 13:06 stale[bot]