Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError in Playlist.js #10

Open
rakuzen25 opened this issue Jan 4, 2023 · 8 comments
Open

TypeError in Playlist.js #10

rakuzen25 opened this issue Jan 4, 2023 · 8 comments

Comments

@rakuzen25
Copy link

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?

@vladdenisov
Copy link
Owner

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.

@vladdenisov
Copy link
Owner

PS: I forgot to publish version, when I've fixed all bugs in october :)

@rakuzen25
Copy link
Author

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?

@vladdenisov
Copy link
Owner

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!

@rakuzen25
Copy link
Author

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:

ytmusic-api/index.ts

Lines 11 to 14 in 613a873

constructor(
private cookie: string,
private args?: { userID: string; authUser?: number }
) {

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.

@vladdenisov
Copy link
Owner

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

@rakuzen25
Copy link
Author

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.

@cmclark00
Copy link

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:

ytmusic-api/index.ts

Lines 11 to 14 in 613a873

constructor(
private cookie: string,
private args?: { userID: string; authUser?: number }
) {

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.

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants