node-ytdl-core: SyntaxError: Invalid regular expression: missing /
node:events:498
throw er; // Unhandled 'error' event
^
evalmachine.<anonymous>:13
-1929233002,b,/,][};Xka(ncode);
^
SyntaxError: Invalid regular expression: missing /
at new Script (node:vm:100:7)
at Object.exports.decipherFormats (C:\Users\user\Documents\bot rewrite\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\user\Documents\bot rewrite\node_modules\ytdl-core\lib\info.js:401:17)
Emitted 'error' event on B instance at:
at OggDemuxer.t (C:\Users\user\Documents\bot rewrite\node_modules\@discordjs\voice\dist\index.js:8:288)
at Object.onceWrapper (node:events:640:26)
at OggDemuxer.emit (node:events:532:35)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
resource: <ref *3> T {
playStream: OggDemuxer {
_readableState: ReadableState {
objectMode: true,
highWaterMark: 16,
buffer: BufferList { head: null, tail: null, length: 0 },
length: 0,
pipes: [],
flowing: false,
ended: false,
endEmitted: false,
reading: true,
constructed: true,
sync: false,
needReadable: true,
emittedReadable: false,
readableListening: true,
resumeScheduled: false,
errorEmitted: true,
emitClose: true,
autoDestroy: true,
destroyed: true,
errored: evalmachine.<anonymous>:13
-1929233002,b,/,][};Xka(ncode);
^
SyntaxError: Invalid regular expression: missing /
at new Script (node:vm:100:7)
at Object.exports.decipherFormats (C:\Users\user\Documents\bot rewrite\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\user\Documents\bot rewrite\node_modules\ytdl-core\lib\info.js:401:17),
closed: true,
closeEmitted: false,
defaultEncoding: 'utf8',
awaitDrainWriters: null,
multiAwaitDrain: false,
readingMore: false,
dataEmitted: false,
decoder: null,
encoding: null,
[Symbol(kPaused)]: null
},
_events: [Object: null prototype] {
prefinish: [Function: prefinish],
close: [
[Function (anonymous)],
[Function: onclose],
[Function: bound onceWrapper] { listener: [Function: s] }
],
end: [
[Function: onend],
[Function: bound onceWrapper] { listener: [Function: s] }
],
finish: [
[Function: onfinish],
[Function: bound onceWrapper] { listener: [Function: s] }
],
error: [Function: onerror],
readable: [
[Function: bound onceWrapper] {
listener: [Function (anonymous)]
},
[Function: bound onceWrapper] { listener: [Function: o] }
]
},
_eventsCount: 6,
_maxListeners: undefined,
_writableState: WritableState {
objectMode: false,
highWaterMark: 16384,
finalCalled: false,
needDrain: false,
ending: false,
ended: false,
finished: false,
destroyed: true,
decodeStrings: true,
defaultEncoding: 'utf8',
length: 0,
writing: false,
corked: 0,
sync: true,
bufferProcessing: false,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
allBuffers: true,
allNoop: true,
pendingcb: 0,
constructed: true,
prefinished: false,
errorEmitted: true,
emitClose: true,
autoDestroy: true,
errored: evalmachine.<anonymous>:13
-1929233002,b,/,][};Xka(ncode);
^
SyntaxError: Invalid regular expression: missing /
at new Script (node:vm:100:7)
at Object.exports.decipherFormats (C:\Users\user\Documents\bot rewrite\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\user\Documents\bot rewrite\node_modules\ytdl-core\lib\info.js:401:17),
closed: true,
closeEmitted: false,
[Symbol(kOnFinished)]: []
},
allowHalfOpen: true,
_remainder: null,
_head: null,
_bitstream: null,
[Symbol(kCapture)]: false,
[Symbol(kCallback)]: null
},
edges: [
<ref *1> {
type: 'ffmpeg ogg',
to: _e {
edges: [ [Object], [Object], [Object] ],
type: 'ogg/opus'
},
cost: 2,
transformer: [Function: transformer],
from: _e { edges: [ [Object], [Circular *1] ], type: 'arbitrary' }
},
<ref *2> {
type: 'ogg/opus demuxer',
to: _e { edges: [ [Object] ], type: 'opus' },
cost: 1,
transformer: [Function: transformer],
from: _e {
edges: [ [Circular *2], [Object], [Object] ],
type: 'ogg/opus'
}
}
],
metadata: null,
volume: undefined,
encoder: undefined,
audioPlayer: <ref *4> B {
_events: [Object: null prototype] { stateChange: [Function (anonymous)] },
_eventsCount: 1,
_maxListeners: undefined,
_state: {
status: 'buffering',
resource: [Circular *3],
onReadableCallback: [Function: o],
onFailureCallback: [Function: s],
onStreamError: [Function: t]
},
subscribers: [
O {
connection: G {
_events: [Object: null prototype],
_eventsCount: 1,
_maxListeners: undefined,
rejoinAttempts: 0,
_state: [Object],
joinConfig: [Object],
packets: [Object],
receiver: [j],
debug: null,
onNetworkingClose: [Function: bound onNetworkingClose],
onNetworkingStateChange: [Function: bound onNetworkingStateChange],
onNetworkingError: [Function: bound onNetworkingError],
onNetworkingDebug: [Function: bound onNetworkingDebug],
[Symbol(kCapture)]: false
},
player: [Circular *4]
}
],
behaviors: { noSubscriber: 'pause', maxMissedFrames: 5 },
debug: [Function (anonymous)],
[Symbol(kCapture)]: false
},
playbackDuration: 0,
started: false,
silencePaddingFrames: 5,
silenceRemaining: -1
}
}
Not really sure the reason behind this, started happening after switching to version 4.11.1 from 4.10.0. Switching back to version 4.10.0 fixed the issue. Not sure about other versions.
Any youtube link supplied will output the error above. This is the only ytdl method I have in my code (except for a few ytdl.validateURL methods):
stream = createAudioResource(ytdl(videoURL, {
filter: "audioonly",
fmt: "mp3",
highWaterMark: 1 << 62,
liveBuffer: 1 << 62,
dlChunkSize: 0,
bitrate: 128 }));
return stream;
The variable videoURL
is supplied with this: https://www.youtube.com/watch?v=${res.data.items[0].id}
where ${res.data.items[0].id}
is gotten from using the youtube api. I checked if the output of ytdl.validateURL(videoURL)
is true, which it was every time.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 20 (4 by maintainers)
Commits related to this issue
- revert ytdl-core update due to bug https://github.com/fent/node-ytdl-core/issues/1131 — committed to AlexanderWyss/discord-bot-node by AlexanderWyss 2 years ago
What needs to happen for G**gle developers to stop fucking around with the streams?
Same here. It was working a few hours ago with the same files and version.
Found a fix: https://github.com/fent/node-ytdl-core/pull/1111
Same solution as the previous regex errors.
As mentioned above the fix in PR #1126
cutAfterJS()
is not identifying this Regex pattern:Probably just a small tweak is needed. Do not close this issue.
Ping @TimeForANinja
with
ok… there’s is nothing wrong with my approach… i just screwed up the regex and used
/(^|[[{:;,])\s+$/
instead of/(^|[[{:;,])\s?$/
will push the fix in a secondDoesn’t look likely, that was a separate issue 6 days ago, this is another one. Please reopen.
Working, thanks Changed the extractNCode function in sig.js to this as per the pr: