spotify-url-info
spotify-url-info copied to clipboard
TypeError: Couldn't find scripts to get the data.
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)
}
Can you try to debug it? what is the HTML markup associated with that URL?
What do you mean? I use the package in a discord bot in javascript and node
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 🙂
Done, when this error occurs again I will post it