Fixed URL parsing not working for some URLs
This commit is contained in:
parent
ff222e10c1
commit
68a4052809
|
@ -143,19 +143,19 @@ func add(user, url string) (string, error) {
|
|||
`https?:\/\/www.youtube.com\/v\/([\w-]+)`,
|
||||
}
|
||||
matchFound := false
|
||||
shortUrl := ""
|
||||
|
||||
for _, pattern := range youtubePatterns {
|
||||
if re, err := regexp.Compile(pattern); err == nil {
|
||||
if re.MatchString(url) {
|
||||
matchFound = true
|
||||
shortUrl = re.FindStringSubmatch(url)[1]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if matchFound {
|
||||
urlMatch := strings.Split(url, "=")
|
||||
shortUrl := urlMatch[1]
|
||||
newSong := NewSong(user, shortUrl)
|
||||
if err := dj.queue.AddSong(newSong); err == nil {
|
||||
return newSong.title, nil
|
||||
|
|
Reference in a new issue