add player embed

This commit is contained in:
HookedBehemoth 2022-05-16 19:37:39 +02:00
parent 138826fb4f
commit 0daa7c164f
2 changed files with 9 additions and 3 deletions

View File

@ -46,8 +46,10 @@ proc createStatusRouter*(cfg: Config) =
video = ""
if conv.tweet.video.isSome():
images = @[get(conv.tweet.video).thumb]
video = getVideoEmbed(cfg, conv.tweet.id)
let vid = get(conv.tweet.video)
images = @[vid.thumb]
let vids = vid.variants.filterIt(it.contentType == VideoType.mp4)
video = getVidUrl(vids[0].url)
elif conv.tweet.gif.isSome():
images = @[get(conv.tweet.gif).thumb]
video = getPicUrl(get(conv.tweet.gif).url)

View File

@ -109,13 +109,17 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
if rss.len > 0:
meta(property="twitter:card", content="summary")
elif video.len > 0:
meta(property="twitter:card", content="player")
else:
meta(property="twitter:card", content="summary_large_image")
if video.len > 0:
meta(property="og:video:url", content=video)
meta(property="og:video:secure_url", content=video)
meta(property="og:video:type", content="text/html")
meta(property="og:video:type", content="video/mp4")
meta(name="twitter:player:stream", content=video)
meta(name="twitter:player:stream:content_type", content="video/mp4")
# this is last so images are also preloaded
# if this is done earlier, Chrome only preloads one image for some reason