From 513b1f4d83d8267f9b8c7299822c40e9d4d77196 Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Thu, 8 Jul 2021 12:54:05 +0200 Subject: Add video download server support --- grimtube.go | 7 +++++++ templates/search.html | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/grimtube.go b/grimtube.go index c635418..bd700fb 100644 --- a/grimtube.go +++ b/grimtube.go @@ -14,6 +14,7 @@ import ( ) var docPath string +var dlsrv string func getLangs() []string { return []string{"en", "fr", "de", "ja", "ru"} @@ -67,6 +68,7 @@ func index(w http.ResponseWriter, r *http.Request) { Items []ytparser.Item Page int Lang string + Dlsrv string }{ getLangs(), getOrders(), @@ -75,6 +77,7 @@ func index(w http.ResponseWriter, r *http.Request) { items, page, lang, + dlsrv, } serve(w, "templates/search.html", data) } @@ -118,6 +121,7 @@ func search(w http.ResponseWriter, r *http.Request) { Langs []string Order string Orders []string + Dlsrv string }{ items, term, @@ -126,6 +130,7 @@ func search(w http.ResponseWriter, r *http.Request) { getLangs(), order, getOrders(), + dlsrv, } serve(w, "templates/search.html", data) } @@ -150,8 +155,10 @@ func favicon(w http.ResponseWriter, r *http.Request) { func main() { port := flag.Int("p", 8080, "The port to bind to.") dir := flag.String("d", "", "Location of the templates and static resources.") + dl := flag.String("dlsrv", "", "Link to a download server.") flag.Parse() docPath = *dir + dlsrv = *dl fs := http.FileServer(http.Dir("static")) http.Handle("/static/", http.StripPrefix(path.Join(docPath, "/static/"), fs)) http.HandleFunc("/favicon.ico", favicon) diff --git a/templates/search.html b/templates/search.html index 8cbf200..e5cff9a 100644 --- a/templates/search.html +++ b/templates/search.html @@ -41,6 +41,11 @@ {{.LengthText}} + {{if ne $.Dlsrv ""}} + + Download + + {{end}} {{end}} -- cgit v1.2.3