1
0

Implement mixed-media tweet support

Fixes #697 #1101
This commit is contained in:
Zed
2026-03-13 05:47:37 +01:00
parent 4bf3df94f8
commit 35a929c415
15 changed files with 304 additions and 174 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ proc createEmbedRouter*(cfg: Config) =
router embed:
get "/i/videos/tweet/@id":
let tweet = await getGraphTweetResult(@"id")
if tweet == nil or tweet.video.isNone:
if tweet == nil or not tweet.hasVideos:
resp Http404
resp renderVideoEmbed(tweet, cfg, request)
+10 -6
View File
@@ -44,15 +44,19 @@ proc createStatusRouter*(cfg: Config) =
desc = conv.tweet.text
var
images = conv.tweet.photos.mapIt(it.url)
images = conv.tweet.getPhotos.mapIt(it.url)
video = ""
if conv.tweet.video.isSome():
images = @[get(conv.tweet.video).thumb]
let
firstMediaKind = if conv.tweet.media.len > 0: conv.tweet.media[0].kind
else: photoMedia
if firstMediaKind == videoMedia:
images = @[conv.tweet.media[0].getThumb]
video = getVideoEmbed(cfg, conv.tweet.id)
elif conv.tweet.gif.isSome():
images = @[get(conv.tweet.gif).thumb]
video = getPicUrl(get(conv.tweet.gif).url)
elif firstMediaKind == gifMedia:
images = @[conv.tweet.media[0].getThumb]
video = getPicUrl(conv.tweet.media[0].gif.url)
elif conv.tweet.card.isSome():
let card = conv.tweet.card.get()
if card.image.len > 0: