diff options
| author | Julian Hurst <julian.hurst92@gmail.com> | 2021-07-08 12:54:05 +0200 |
|---|---|---|
| committer | Julian Hurst <julian.hurst92@gmail.com> | 2021-07-08 12:54:05 +0200 |
| commit | 513b1f4d83d8267f9b8c7299822c40e9d4d77196 (patch) | |
| tree | a2b6d0f1c74bf2a8741977beb7c27bdf0380b10b | |
| parent | 124be83ec299a4b9502a469cef75b7b9fe971756 (diff) | |
| download | grimtube-513b1f4d83d8267f9b8c7299822c40e9d4d77196.tar.gz | |
Add video download server support
| -rw-r--r-- | grimtube.go | 7 | ||||
| -rw-r--r-- | templates/search.html | 5 |
2 files changed, 12 insertions, 0 deletions
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 @@ <td> {{.LengthText}} </td> + {{if ne $.Dlsrv ""}} + <td> + <a href="{{$.Dlsrv}}{{.Url}}">Download</a> + </td> + {{end}} </tr> {{end}} </table> |
