Remove getYouTubeId from util.go.

This bit of code has long been moved to the YouTube parser package.
develop
Icedream 2016-07-05 15:07:50 +02:00
parent f97c872b2e
commit 0eb16f9975
1 changed files with 0 additions and 32 deletions

32
util.go
View File

@ -1,7 +1,6 @@
package main package main
import ( import (
"net/url"
"regexp" "regexp"
"strings" "strings"
) )
@ -28,34 +27,3 @@ func stripIrcFormatting(text string) string {
text = rxIrcColor.ReplaceAllLiteralString(text, "") text = rxIrcColor.ReplaceAllLiteralString(text, "")
return text return text
} }
func getYouTubeId(uri *url.URL) string {
u := &(*uri)
u.Scheme = strings.ToLower(u.Scheme)
u.Host = strings.ToLower(u.Host)
// Must be an HTTP URL
if u.Scheme != "http" && u.Scheme != "https" {
return ""
}
// Remove www. prefix from hostname
if strings.HasPrefix(u.Host, "www.") {
u.Host = u.Host[4:]
}
switch strings.ToLower(u.Host) {
case "youtu.be":
// http://youtu.be/{id}
if s, err := url.QueryUnescape(strings.TrimLeft(u.Path, "/")); err == nil {
return s
} else {
return ""
}
case "youtube.com":
// http://youtube.com/watch?v={id}
return u.Query().Get("v")
}
return ""
}