all repos — fixyoutube-go @ 566d29167b4dcd64442c4b91805551c4e4e23dfa

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

handle empty url
Marco Andronaco andronacomarco@gmail.com
Sat, 13 Jan 2024 15:16:31 +0100
commit

566d29167b4dcd64442c4b91805551c4e4e23dfa

parent

0c53037d82b827f00b3bdce97e197c45af008673

4 files changed, 10 insertions(+), 4 deletions(-)

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

@@ -52,9 +52,10 @@ _, l, i := c.findCompatibleFormat(res)

if l == 0 { logger.Warn("No compatible formats found for video.") res.Url = "" + } else { + res.Url = res.Formats[i].Url } - res.Url = res.Formats[i].Url return res, http.StatusOK }
M invidious/invidious.goinvidious/invidious.go

@@ -111,7 +111,6 @@ InitDB()

client := &Client{ http: httpClient, timeouts: []Timeout{}, - Instance: "", } err := client.NewInstance() if err != nil {
M invidious/proxy.goinvidious/proxy.go

@@ -7,6 +7,10 @@ "net/http"

) func (c *Client) urlToBuffer(url string) (*bytes.Buffer, int64, int) { + if url == "" { + return nil, 0, http.StatusBadRequest + } + req, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { logger.Error(err) // bad request
M templates/video.htmltemplates/video.html

@@ -9,13 +9,14 @@ ██ A better way to embed YouTube videos on Telegram (inspired by FixTweet).

██ <html lang="en"><head> <link rel="canonical" href="https://www.youtube.com/watch?v={{ .VideoId }}" /> + <meta http-equiv="refresh" content="0;url=https://www.youtube.com/watch?v={{ .VideoId }}" /> + <meta property="og:url" content="https://www.youtube.com/watch?v={{ .VideoId }}" /> + {{ if .Url }} <meta property="theme-color" content="0000FF" /> <meta property="twitter:card" content="player" /> <meta property="twitter:site" content="{{ .Uploader }}" /> <meta property="twitter:creator" content="{{ .Uploader }}" /> <meta property="twitter:title" content="{{ .Title }}" /> - <meta http-equiv="refresh" content="0;url=https://www.youtube.com/watch?v={{ .VideoId }}" /> - <meta property="og:url" content="https://www.youtube.com/watch?v={{ .VideoId }}" /> <meta property="og:title" content="{{ .Title }}" /> <meta property="og:description" content="{{ .Description }}" /> <meta property="og:site_name" content="FixYouTube ({{ .Uploader }})" />

@@ -25,4 +26,5 @@ <meta property="og:video" content="/proxy/{{ .VideoId }}" />

<meta property="og:video:secure_url" content="/proxy/{{ .VideoId }}" /> <meta property="og:video:duration" content="{{ .Duration }}"> <meta property="og:video:type" content="video/mp4" /> + {{ end }} </head><body></body></html>