spotify-web-api-node
spotify-web-api-node copied to clipboard
how to search for a song with the song link (https://open.spotify.com/track/5kJLPjc6YlvkoEm3aZ0VBV?si=zheh1KQWTfOOeleGlK5CiQ)
how to search for a song with the song link (https://open.spotify.com/track/5kJLPjc6YlvkoEm3aZ0VBV?si=zheh1KQWTfOOeleGlK5CiQ)
i mean the docs says only how to search with artist name etc.. and i want to search with a url
I think you can just split the link so you get the trackID and then use getTrack.
how to search for a song with the song link (https://open.spotify.com/track/5kJLPjc6YlvkoEm3aZ0VBV?si=zheh1KQWTfOOeleGlK5CiQ)
i mean the docs says only how to search with artist name etc.. and i want to search with a url
Parse the Track id from the URL:
For eg: URL : https://open.spotify.com/track/5kJLPjc6YlvkoEm3aZ0VBV?si=zheh1KQWTfOOeleGlK5CiQ Id of the Track : 5kJLPjc6YlvkoEm3aZ0VBV
Then use the Following methods to get info of the Track:
spotifyApi.getTrack(spotifyTrackId).then(
function (data) {
let temp = data.body;
artists = temp.album.artists[0].name;
images = temp.album.images[0].url;
album = temp.album.name;
title = temp.name;
date = temp.album.release_date;
spotifyTrackName = `${title} ${artists}`;
getYtLink(spotifyTrackName);
},
function (err) {
console.error(err);
}
);