talmobi / yt-search

100 stars 33 forks source link

TypeError: Cannot read property 'split' of undefined #43

Closed FidelGB closed 3 years ago

FidelGB commented 3 years ago

I have the same error that the issue #27, but this happens when I try to search this list Id: RDGMEM_v2KDBP3d4f8uT-ilrs8fQ&

Code:

let result = await yts({ listId: "RDGMEM_v2KDBP3d4f8uT-ilrs8fQ&" });

Error:

[nodemon] restarting due to changes...
[nodemon] starting `node index.js`
Bot encendido
TypeError: Cannot read property 'split' of undefined
    at _parsePlaylistInitialData (/Users/fidel/discord-bot-php/js/node_modules/yt-search/dist/yt-search.js:812:63)
    at /Users/fidel/discord-bot-php/js/node_modules/yt-search/dist/yt-search.js:792:9
    at i (/Users/fidel/discord-bot-php/js/node_modules/dasu/dist/dasu.min.js:1:4168)
    at Gunzip.<anonymous> (/Users/fidel/discord-bot-php/js/node_modules/dasu/dist/dasu.min.js:1:2627)
    at Gunzip.emit (events.js:315:20)
    at endReadableNT (internal/streams/readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
talmobi commented 3 years ago

Hello there,

i'm about to upload a patch that will correctly handle this case and throw a "This playlist type is unviewable" error.

The issue here is that the playlist is unviewable for some reason. Playlists usually have an ID that bigs with PL ex: ´PLxxxxxxxxxxxxxxx´ so I'm not sure what your ID is supposed to mean.

talmobi commented 3 years ago

It is actually a playlist, you can view it using /watch ex: https://www.youtube.com/watch?list=RDGMEM_v2KDBP3d4f8uT-ilrs8fQ

but you can't view it as a playlist ex: https://www.youtube.com/playlist?list=RDGMEM_v2KDBP3d4f8uT-ilrs8fQ

I'm not sure why...

talmobi commented 3 years ago

Maybe it has something to do with the first video in the playlist which is seems to be some kind of weird device restricted thing? Not sure what that is...

FidelGB commented 3 years ago

I was checking my application logs and the youtube url they entered was this one:

https://www.youtube.com/watch?v=wZkwvOJjzyk&list=RDGMEM_v2KDBP3d4f8uT-ilrs8fQ&start_radio=1

I don't know if that error is due to the list being a Youtube Mix 🤔

FidelGB commented 3 years ago

I'm watching this url, that is also a youtube mix, and is the same error

https://www.youtube.com/watch?v=QmyuUuzgGlA&list=RDQMc8ZcCnbMfmY&start_radio=1&ab_channel=VideoFilmacionesContrerasBailesSoniderosTV2

talmobi commented 3 years ago

What's the difference between a youtube mix and a playlist?

talmobi commented 3 years ago

found a link to some info about it, must do some research on it soon: https://support.google.com/youtube/answer/9011078?hl=en

talmobi commented 3 years ago

It seems mix id's all begin with RD ex: RDxxxxxx... -- and the default "My Mix" id is RDMM

For example, going to the url https://youtube.com/watch?list=RDMM will always have different results depending on who is opening it. Even when you open in incognito. It seems youtube is guessing what kind of music you would like based on the history of the user-agent, ip, search history etc etc.

And mixes (RDxxxxx...) are always infinite, they never stop playing. Music is added to it by youtube based on what it guesses you would like indefinitely.

For this reason it is very much unlike a normal playlist. I'm not sure how it should be supported. My current initial idea is to not suppor them at all, and instead throw an error explaining that this is a mix based on the RD value in the supplied listId.

What do you think? @FidelGB

FidelGB commented 3 years ago

As start sounds good that this library doesn't support this mixes because, as you say, this mixes are infinite.

I'm develop a Discord bot with music support from youtube and I use your library to do the search, this function is almost same that Groovy Bot, and when I play any youtube mix, Groovy plays the first 25 songs (I don't know how Groovy work internally), so I think that, in the future, you can add support from Youtube mixes but getting a determinate number of results. This is my idea 🤔

(Pd. sorry if my english contains errors, I can't speak it fluently)

talmobi commented 3 years ago

As the most pressing bug causing a crash is fixed I'm closing this in favour of: https://github.com/talmobi/yt-search/issues/46 to track/discuss how mixes should be handled.