handle empty url
Marco Andronaco andronacomarco@gmail.com
Sat, 13 Jan 2024 15:16:31 +0100
4 files changed,
10 insertions(+),
4 deletions(-)
M
invidious/api.go
→
invidious/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.go
→
invidious/invidious.go
@@ -111,7 +111,6 @@ InitDB()
client := &Client{ http: httpClient, timeouts: []Timeout{}, - Instance: "", } err := client.NewInstance() if err != nil {
M
invidious/proxy.go
→
invidious/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.html
→
templates/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>