fix: spotify regex pattern

Fix regex pattern to use non-capturing group for optional intl prefix in Spotify track URLs
This commit is contained in:
KaNaDaAT 2025-05-15 20:48:11 +02:00
parent 8f1ab855a2
commit 1daf682062

View file

@ -183,9 +183,9 @@ func isValidPattern(url, pattern string) bool {
}
func TrackInfo(url string) (*Track, error) {
re := regexp.MustCompile(`open\.spotify\.com\/track\/([a-zA-Z0-9]{22})`)
re := regexp.MustCompile(`open\.spotify\.com\/(?:intl-.+\/)?track\/([a-zA-Z0-9]{22})(\?si=[a-zA-Z0-9]{16})?`)
matches := re.FindStringSubmatch(url)
if len(matches) != 2 {
if len(matches) <= 2 {
return nil, errors.New("invalid track URL")
}
id := matches[1]