spotify-url-info icon indicating copy to clipboard operation
spotify-url-info copied to clipboard

TypeError: Couldn't find scripts to get the data.

Open ItsPerona opened this issue 1 year ago • 4 comments

Describe the bug Just like issue #125, im using the getPreview() method with a url of a spotify track, the error sometimes appears and sometimes not.

Adding require('fs').writeFileSync('index.html', JSON.stringify(html, null, 2)) doesn't fix the problem

Spotify URL(s) https://open.spotify.com/intl-es/track/2HZLXBOnaSRhXStMLrq9fD?si=0c23f172ebba42fb

Your Code

// Spotify
const SpotifyFetch = require('isomorphic-unfetch')
const { getData, getPreview, getTracks } = require('spotify-url-info')(SpotifyFetch);

// More code

if (url.includes("spotify.com/") && url.includes("track/")) {
    getPreview(url).then(data => {  ...

Error Message

TypeError: Couldn't find scripts to get the data.
Please report the problem at https://github.com/microlinkhq/spotify-url-info/issues.
    at throwError (/home/iperona/DiscordBot/GatoFeli/node_modules/spotify-url-info/src/index.js:24:9)
    at parseData (/home/iperona/DiscordBot/GatoFeli/node_modules/spotify-url-info/src/index.js:32:37)
    at /home/iperona/DiscordBot/GatoFeli/node_modules/spotify-url-info/src/index.js:76:10
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Promise {
  <rejected> TypeError: Couldn't find scripts to get the data.
  Please report the problem at https://github.com/microlinkhq/spotify-url-info/issues.
      at throwError (/home/iperona/DiscordBot/GatoFeli/node_modules/spotify-url-info/src/index.js:24:9)
      at parseData (/home/iperona/DiscordBot/GatoFeli/node_modules/spotify-url-info/src/index.js:32:37)
      at /home/iperona/DiscordBot/GatoFeli/node_modules/spotify-url-info/src/index.js:76:10
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}

ItsPerona avatar Jan 29 '24 18:01 ItsPerona

Can you try to debug it? what is the HTML markup associated with that URL?

Kikobeats avatar Jan 29 '24 21:01 Kikobeats

What do you mean? I use the package in a discord bot in javascript and node

ItsPerona avatar Jan 30 '24 04:01 ItsPerona

I suspect this is related with the HTML get from from the fetch request.

For debugging this, I released [email protected] which exposes error.html.

Can you do something like this?

try {
    const data = await getPreview(url)
} catch(error) {
    const filepath = `${require('os').tmpdir()}/${url}.html`
    require('fs').writeFileSync(filepath, error.html)
    console.log('debug file at', filepath)
}

Then upload the file to https://gist.github.com/ or whatever so we can determine what's happening 🙂

Kikobeats avatar Jan 31 '24 16:01 Kikobeats

Done, when this error occurs again I will post it

ItsPerona avatar Jan 31 '24 23:01 ItsPerona