distubejs / spotify

A DisTube custom plugin for supporting Spotify.
MIT License
21 stars 6 forks source link

Spotify music link that does not work #24

Closed byorage closed 1 year ago

byorage commented 1 year ago

Please describe your problem in as much detail as possible: when I launch a music and in the music link the link contains "intl-fr" the bot does not find the music and therefore does not play it. example link: https://open.spotify.com/intl-fr/track/0HYaC4uGgpx7EIBekhxWfi?si=3d5289545af74ea2

Further information:

skick1234 commented 1 year ago

All redirect links won't be supported since we cannot handle all of them. Just follow redirects then play the final location instead.

Akif9748 commented 1 year ago

A basic solution for now:

// Input URLs
const inputURL = "https://open.spotify.com/intl-fr/track/0HYaC4uGgpx7EIBekhxWfi?si=3d5289545af74ea2";

// Define a regular expression to match and remove the '/intl-xx/' part from the URLs
const regex = /\/intl-[a-z]{2}\//;

// Replace the matching part with an empty string
const outputURL= inputURL.replace(regex, '/');

// Output converted URL
console.log(outputURL);