add thumbnail, video tag
Marco Andronaco andronacomarco@gmail.com
Wed, 16 Oct 2024 00:39:10 +0200
2 files changed,
23 insertions(+),
3 deletions(-)
M
src/app/handlers.go
→
src/app/handlers.go
@@ -71,12 +71,18 @@ http.Error(w, err500, http.StatusInternalServerError)
return } + var thumbnail string + if len(video.Thumbnails) > 0 { + thumbnail = video.Thumbnails[len(video.Thumbnails)-1].URL + } + data := map[string]interface{}{ "VideoID": videoID, "VideoURL": format.URL, "Uploader": video.Author, "Title": video.Title, "Description": video.Description, + "Thumbnail": thumbnail, "Duration": video.Duration, "Debug": g.Debug, }
M
templates/video.html
→
templates/video.html
@@ -8,11 +8,15 @@ ██ ██ ██ ██ ██ ███ ███ ██ ███ ██████ ███████
██ ██ A better way to embed YouTube videos on Telegram (inspired by FixTweet). ██ --> -<html lang="en"><head> +<html lang="en"> + +<head> <link rel="canonical" href="https://www.youtube.com/watch?v={{ .VideoID }}" /> {{ if not .Debug }} <meta http-equiv="refresh" content="0;url=https://www.youtube.com/watch?v={{ .VideoID }}" /> {{ end }} + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> <meta property="og:url" content="https://www.youtube.com/watch?v={{ .VideoID }}" /> <meta property="theme-color" content="0000FF" /> <meta property="twitter:card" content="player" />@@ -22,7 +26,7 @@ <meta property="twitter:title" content="{{ .Title }}" />
<meta property="og:title" content="{{ .Title }}" /> <meta property="og:description" content="{{ .Description }}" /> <meta property="og:site_name" content="GoTube ({{ .Uploader }})" /> - <meta property="twitter:image" content="0" /> + <meta property="twitter:image" content="{{ .Thumbnail }}" /> <meta property="twitter:player:stream:content_type" content="video/mp4" /> {{ if .VideoURL }} <meta property="og:video" content="{{ .VideoURL }}" />@@ -30,4 +34,14 @@ <meta property="og:video:secure_url" content="{{ .VideoURL }}" />
<meta property="og:video:duration" content="{{ .Duration }}"> <meta property="og:video:type" content="video/mp4" /> {{ end }} -</head><body></body></html> +</head> + +<body style="background-color: black;"> + {{ if .VideoURL }} + <video style="display: block; margin: auto; width: 100%; max-width: 960px;" autoplay controls> + <source src="{{ .VideoURL }}" type="video/mp4" /> + </video> + {{ end }} +</body> + +</html>