twlite / soundcloud-scraper

☁️ Get basic informations about a song from a SoundCloud URL
https://soundcloud-scraper.js.org
67 stars 16 forks source link

Cant read property 'split' of undefined #15

Closed TheJerryFox closed 2 years ago

TheJerryFox commented 3 years ago

Im using the discord-player module for my bot, which uses the soundcloud-scraper module to get soundcloud tracks but they told me to open the issue here: So whenever I give my bot a soundcloud link it will take around 30 seconds for it to give me the following error:

image image

I have not altered anything in the discord-player or soundcloud-scraper module, I tried updating them both but that didn't work either.

Any ideas?

cjh980402 commented 3 years ago

https://github.com/DevSnowflake/soundcloud-scraper/pull/14 I think applying this PR is expected to cause your error to be normally catched through try-catch.

maskalix commented 2 years ago

Found out solution!

Change in Client.js in section getPlaylist this:

try {
                    section = JSON.parse(`[{"id": ${raw.split(`{}})},[{"id":`)[1].split(");")[0]}`);
                } catch(e) {
                    throw new Error(`Could not parse playlist:\n${e.message}`);
                }

                const data = Util.last(section).data[0];

To this:

try {
                section = JSON.parse(`{"hydratable":"playlist" ${raw.split(`},{"hydratable":"playlist"`)[1].split(`"}}];`)[0] + `"}}`}`);
            } catch(e) {
                throw new Error(`Could not parse playlist:\n${e.message}`);
            }
            const data = section.data;

Then it works normally as before ;)