fent / node-ytdl-core

YouTube video downloader in javascript.
MIT License
4.51k stars 798 forks source link

ReferenceError: MC is not defined #1167

Open LostAndDead opened 1 year ago

LostAndDead commented 1 year ago
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.

xenorio commented 1 year ago

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

matteopolak commented 1 year ago

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"
  }
}
xenorio commented 1 year ago

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

kaddyadriano commented 1 year ago

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

nextpier commented 1 year ago

Thank you @matteopolak ! It's working

kilianpfr commented 1 year ago

@matteopolak ty so much

richardabear commented 1 year ago

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

Pnlvfx commented 1 year ago

Same

stale[bot] commented 1 year ago

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.