ytmusic-api
ytmusic-api copied to clipboard
TypeError in Playlist.js
When I tried to run
const api = new YTMUSIC(
"cookie",
{ userID: "" },
);
const data = await api.getPlaylist("RDCLAK5uy_k1Wu8QbZASiGVqr1wmie9NIYo38aBqscQ");
console.log(data);
Node exited with an error:
/Users/<path>/node_modules/ytmusic/dist/lib/endpoints/Playlist.js:128
album: e.flexColumns[2].musicResponsiveListItemFlexColumnRenderer.text.runs[0],
^
TypeError: Cannot read properties of undefined (reading '0')
at /Users/<path>/node_modules/ytmusic/dist/lib/endpoints/Playlist.js:128:100
at Array.map (<anonymous>)
at /Users/<path>/node_modules/ytmusic/dist/lib/endpoints/Playlist.js:112:31
at step (/Users/<path>/node_modules/ytmusic/dist/lib/endpoints/Playlist.js:52:23)
at Object.next (/Users/<path>/node_modules/ytmusic/dist/lib/endpoints/Playlist.js:33:53)
at fulfilled (/Users/<path>/node_modules/ytmusic/dist/lib/endpoints/Playlist.js:24:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v19.3.0
Any ideas why?
Hello. Please update package to version 0.0.9
"dependencies": {
"ytmusic": "^0.0.9"
},
And then you should create API instance like this (for using without cookie):
const api = new YTMUSIC()
It should work, I've tested on my setup.
I will specify this in docs soon.
PS: I forgot to publish version, when I've fixed all bugs in october :)
Thanks so much for the prompt reply! I'll take a look.
And then you should create API instance like this (for using without cookie):
Does that mean I cannot create an API with cookies now, or does that simply mean I can choose to use or not to use cookies?
Does that mean I cannot create an API with cookies now, or does that simply mean I can choose to use or not to use cookies?
You should be able to use both: anonymous requests and requests, which require a cookie (like creating a playlist).
If anything goes wrong, feel free to open an issue or mention me here!
You should be able to use both: anonymous requests and requests, which require a cookie (like creating a playlist).
Hmm, it feels like something isn't right here though:
https://github.com/vladdenisov/ytmusic-api/blob/613a87353adf3688ab14575e690239c5d55571af/index.ts#L11-L14
Shouldn't cookie
and userID
be optional then? My TS linter keeps calling me out for not specifying userID
in the previous version, don't think this got fixed yet.
Yeah, looks odd to me too. For now you can specify blank cookie const api = new YTMUSIC("")
. I'll take a look into it a bit later
No worries! Please keep up the amazing work - one of the few still-maintained YouTube Music API out there and the only one with full cookies support AFAIC 😁
I have another question related to browser usage but I'll open another issue. Cheers.
You should be able to use both: anonymous requests and requests, which require a cookie (like creating a playlist).
Hmm, it feels like something isn't right here though:
https://github.com/vladdenisov/ytmusic-api/blob/613a87353adf3688ab14575e690239c5d55571af/index.ts#L11-L14
Shouldn't
cookie
anduserID
be optional then? My TS linter keeps calling me out for not specifyinguserID
in the previous version, don't think this got fixed yet.
@vladdenisov I'm having an issue with using api.getPlaylists. I'm getting invalid args error. I've tried passing a blank string for userId along with cookie but still gives the error. I tried to search the docs for how to get a user id and authuser but couldn't find it