From 0eb16f9975fb5d17838565b5f122739a9afc223a Mon Sep 17 00:00:00 2001 From: Carl Kittelberger Date: Tue, 5 Jul 2016 15:07:50 +0200 Subject: [PATCH] Remove getYouTubeId from util.go. This bit of code has long been moved to the YouTube parser package. --- util.go | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/util.go b/util.go index 9b50a96..933e89f 100644 --- a/util.go +++ b/util.go @@ -1,7 +1,6 @@ package main import ( - "net/url" "regexp" "strings" ) @@ -28,34 +27,3 @@ func stripIrcFormatting(text string) string { text = rxIrcColor.ReplaceAllLiteralString(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 "" -}