fix: extract Twitter video thumbnails from correct API field
Twitter video thumbnails are provided by the FxTwitter API directly in the video object's thumbnail_url field, not in a separate photos array. This fixes thumbnail generation for Twitter video links.
This commit is contained in:
parent
4a2cb341fa
commit
4763e69b79
1 changed files with 3 additions and 5 deletions
|
|
@ -129,6 +129,7 @@ type fxTwitterResponse struct {
|
||||||
} `json:"photos"`
|
} `json:"photos"`
|
||||||
Videos []struct {
|
Videos []struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
|
ThumbnailURL string `json:"thumbnail_url"`
|
||||||
} `json:"videos"`
|
} `json:"videos"`
|
||||||
} `json:"media"`
|
} `json:"media"`
|
||||||
IsNoteTweet bool `json:"is_note_tweet"`
|
IsNoteTweet bool `json:"is_note_tweet"`
|
||||||
|
|
@ -204,11 +205,8 @@ func parseFxTwitterResponse(fxResp *fxTwitterResponse, tweetID string, originalU
|
||||||
|
|
||||||
if len(tweet.Media.Videos) > 0 {
|
if len(tweet.Media.Videos) > 0 {
|
||||||
videoURL = tweet.Media.Videos[0].URL
|
videoURL = tweet.Media.Videos[0].URL
|
||||||
|
thumbnailURL = tweet.Media.Videos[0].ThumbnailURL
|
||||||
mediaType = "video"
|
mediaType = "video"
|
||||||
// Videos usually have a poster/thumbnail in photos
|
|
||||||
if len(tweet.Media.Photos) > 0 {
|
|
||||||
thumbnailURL = tweet.Media.Photos[0].URL
|
|
||||||
}
|
|
||||||
} else if len(tweet.Media.Photos) > 0 {
|
} else if len(tweet.Media.Photos) > 0 {
|
||||||
thumbnailURL = tweet.Media.Photos[0].URL
|
thumbnailURL = tweet.Media.Photos[0].URL
|
||||||
for _, photo := range tweet.Media.Photos {
|
for _, photo := range tweet.Media.Photos {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue