all repos — fixyoutube-go @ 16533651011cc01650e41be1ac540bac44902edc

A better way to embed YouTube videos everywhere (inspired by FixTweet).

better video template
Marco Andronaco andronacomarco@gmail.com
Sun, 24 Nov 2024 15:02:33 +0100
commit

16533651011cc01650e41be1ac540bac44902edc

parent

c0b6900ba8c94a0dba08b736131ca72692a9f8d9

2 files changed, 9 insertions(+), 12 deletions(-)

jump to
M invidious/invidious.goinvidious/invidious.go

@@ -19,22 +19,17 @@ Length int64

} func GetVideoURL(video rabbitpipe.Video) string { - for _, format := range video.FormatStreams { - if format.Itag == "18" { - return format.URL - } + if len(video.FormatStreams) == 0 { + return "" } - return "" + return video.FormatStreams[0].URL } func NewVideoBuffer(b *bytes.Buffer, l int64) *VideoBuffer { d := new(bytes.Buffer) d.Write(b.Bytes()) - return &VideoBuffer{ - Buffer: d, - Length: l, - } + return &VideoBuffer{Buffer: d, Length: l} } func (vb *VideoBuffer) Clone() *VideoBuffer {
M templates/video.htmltemplates/video.html

@@ -39,12 +39,14 @@ </head>

<body> <main class="container" style="max-width: 35rem"> + {{ if gt (len .FormatStreams) 0 }} <video style="width: 100%" autoplay controls> - <source src="/proxy/{{ .VideoID }}" type="video/mp4" /> + <source src="{{ (index .FormatStreams 0).URL }}" type="video/mp4" /> </video> + {{ end }} <h2>{{ .Title }}</h2> - <h3>&gt; {{ .Author }}</h3> - <pre style="white-space: pre-wrap">{{ .Description }}</pre> + <h3>&gt; <a href="https://www.youtube.com/{{ .AuthorURL }}" target="_blank">{{ .Author }}</a></h3> + <pre style="white-space: pre-wrap">{{ .DescriptionHTML }}</pre> <a href="https://www.youtube.com/watch?v={{ .VideoID }}">Watch on YouTube</a> <br /> <a href="/">What is this?</a>