Use the thumbnail for opengraph if online

This commit is contained in:
Gabe Kangas 2020-07-19 18:36:04 -07:00
parent 2ae227360a
commit 05c511848a
2 changed files with 7 additions and 6 deletions

View file

@ -58,12 +58,13 @@ func handleScraperMetadataPage(w http.ResponseWriter, r *http.Request) {
tmpl := template.Must(template.ParseFiles(path.Join("static", "metadata.html"))) tmpl := template.Must(template.ParseFiles(path.Join("static", "metadata.html")))
fullURL, err := url.Parse(fmt.Sprintf("http://%s%s", r.Host, r.URL.Path)) fullURL, err := url.Parse(fmt.Sprintf("http://%s%s", r.Host, r.URL.Path))
imageURL, err := url.Parse(fmt.Sprintf("http://%s%s", r.Host, config.Config.InstanceDetails.Logo["large"])) imageURL, err := url.Parse(fmt.Sprintf("http://%s%s", r.Host, config.Config.InstanceDetails.Logo["large"]))
// If the thumbnail does not exist then just use the logo image status := core.GetStatus()
// If the thumbnail does not exist or we're offline then just use the logo image
var thumbnailURL string var thumbnailURL string
if utils.DoesFileExists("webroot/thumbnail.jpg") { if status.Online && utils.DoesFileExists("webroot/thumbnail.jpg") {
thumbnail, err := url.Parse(fmt.Sprintf("http://%s%s", r.Host, "/thumbnail.jpg")) thumbnail, err := url.Parse(fmt.Sprintf("http://%s%s", r.Host, "/thumbnail.jpg"))
if err != nil { if err != nil {
log.Errorln(err) log.Errorln(err)

View file

@ -14,9 +14,9 @@
<meta property="og:type" content="video.other"> <meta property="og:type" content="video.other">
<meta property="video:tag" content="{{.TagsString}}"> <meta property="video:tag" content="{{.TagsString}}">
<meta property="og:image" content="{{.Image}}"> <meta property="og:image" content="{{.Thumbnail}}">
<meta property="og:image:url" content="{{.Image}}"> <meta property="og:image:url" content="{{.Thumbnail}}">
<meta property="og:image:alt" content="{{.Thumbnail}}"> <meta property="og:image:alt" content="{{.Image}}">
<meta property="og:video" content='{{.RequestedURL}}hls/stream.m3u8' /> <meta property="og:video" content='{{.RequestedURL}}hls/stream.m3u8' />
<meta property="og:video:height" content="640" /> <meta property="og:video:height" content="640" />