all repos — gopipe @ main

Embed YouTube videos on Telegram, Discord and more!

templates/video.tmpl (view raw)

 1{{ extends "base.tmpl" }}
 2
 3{{define "meta" -}}
 4    <title>{{ .Title }} - GoPipe</title>
 5    <link rel="canonical" href="https://www.youtube.com/watch?v={{ .VideoID }}" />
 6    <meta property="og:url" content="https://www.youtube.com/watch?v={{ .VideoID }}" />
 7    <meta property="theme-color" content="0000FF" />
 8    <meta property="twitter:card" content="player" />
 9    <meta property="twitter:site" content="{{ .Author }}" />
10    <meta property="twitter:creator" content="{{ .Author }}" />
11    <meta property="twitter:title" content="{{ .Title }}" />
12    <meta property="og:title" content="{{ .Title }}" />
13    <meta property="og:description" content="{{ .Description }}" />
14    <meta property="og:site_name" content="GoPipe ({{ .Author }})" />
15    <meta property="twitter:image" content="{{ .Thumbnail }}" />
16    <meta property="twitter:player:stream:content_type" content="video/mp4" />
17    {{ if .VideoURL }}
18    <meta property="og:video" content="{{ .VideoURL }}" />
19    <meta property="og:video:secure_url" content="{{ .VideoURL }}" />
20    <meta property="og:video:duration" content="{{ .Duration }}">
21    <meta property="og:video:type" content="video/mp4" />
22    {{ end }}
23{{end}}
24
25
26{{define "content" -}}
27    <video style="width: 100%" autoplay controls>
28        <source src="{{ .VideoURL }}" type="video/mp4" />
29        {{ range .Captions }}
30        <track kind="subtitles" label="{{ .Language }}" src="/sub/{{ .VideoID }}/{{ .Language }}.vtt" srclang="{{ .Language }}" />
31        {{ end }}
32    </video>
33    <h2>{{ .Title }}</h2>
34    <h3>&gt; {{ .Author }}</h3>
35    <pre style="white-space: pre-wrap">{{ .Description }}</pre>
36    <form action="/download" method="post" rel="noopener" target="_blank" style="display: grid; grid-template-columns: auto auto; justify-content: space-between;">
37        <input type="hidden" name="video" value="{{ .VideoID }}">
38        <select name="itagno">
39            <optgroup label="Audio & Video">
40            {{ range .AudioVideoFormats }}
41                <option value="{{ .ItagNo }}">
42                    {{ parseFormat . }}
43                </option>
44                {{ end }}
45            </optgroup>
46            <optgroup label="Video only">
47            {{ range .VideoFormats }}
48                <option value="{{ .ItagNo }}">
49                    {{ parseFormat . }}
50                </option>
51                {{ end }}
52            </optgroup>
53            <optgroup label="Audio only">
54                {{ range .AudioFormats }}
55                <option value="{{ .ItagNo }}">
56                    {{ parseFormat . }}
57                </option>
58                {{ end }}
59            </optgroup>
60        </select>
61        <button type="submit">Download</button>
62    </form>
63    <a href="https://www.youtube.com/watch?v={{ .VideoID }}">Watch on YouTube</a>
64    <br />
65    <a href="/">What is this?</a>
66{{end}}