[=BUG=] TypeError: Cannot read properties of undefined (reading 'find')
MikeDev96 opened this issue ยท 4 comments
Describe the bug
- Node.js version: 16.20.0
- OS & version: Windows 11 Pro 22H2
Simply calling video_info with this URL (https://www.youtube.com/watch?v=wp43OdtAAkM) causes the error although it doesn't happen every time.
Actual behavior
TypeError: Cannot read properties of undefined (reading 'find')
at video_basic_info (D:\Dev\lucille-bot\node_modules\play-dl\dist\index.js:2:2210)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async video_info (D:\Dev\lucille-bot\node_modules\play-dl\dist\index.js:3:1064)
Expected behavior
Returns a InfoData object
Code to reproduce
import { video_info } from "play-dl"
const info = await video_info("https://www.youtube.com/watch?v=wp43OdtAAkM")
ScreenShots
N/A
Checklist
- I have read the documentation.
- I have tried my code with the latest version of Node.js and Play-dl.
I can confirm this is occurring in v1.9.6 of the play-dl module on my end.
Was wondering why the bot refuses to identify songs now, especially from YouTube links.
In my case it was happening pretty much every single time this function is called.
Digging through my bot's code and its debug logs reveals the same error:
(18-09-2023 11:19:27) [error] Something went wrong while parsing the song request!
(18-09-2023 11:19:27) [error] Cannot read properties of undefined (reading 'find')
(18-09-2023 11:19:27) [debug] TypeError: Cannot read properties of undefined (reading 'find')
at video_basic_info (/home/runner/LynxBotRepl/node_modules/play-dl/dist/index.js:2:2210)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Object.video_info (/home/runner/LynxBotRepl/node_modules/play-dl/dist/index.js:3:1064)
at async resolveUrl (/home/runner/LynxBotRepl/lib/commands/fun/music.js:201:20)
at async Object.execute (/home/runner/LynxBotRepl/lib/commands/fun/music.js:510:20)
at async Object.execute (/home/runner/LynxBotRepl/lib/events/interactionCreate.js:53:18)
Guess something with youtube's data changed and
play-dl/play-dl/YouTube/utils/extractor.ts
Line 130 in 76c2373
This is due to an API change to the chapters data. The raw chapters object (markersMap
) needs additional optional chaining. This will be pushed in the next update. If you need a quick fix, follow the trace log and append a ?
after the markersMap property. (e.g. markersMap?.find(...)
)