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
|
|
@ -128,7 +128,8 @@ type fxTwitterResponse struct {
|
|||
Height int `json:"height"`
|
||||
} `json:"photos"`
|
||||
Videos []struct {
|
||||
URL string `json:"url"`
|
||||
URL string `json:"url"`
|
||||
ThumbnailURL string `json:"thumbnail_url"`
|
||||
} `json:"videos"`
|
||||
} `json:"media"`
|
||||
IsNoteTweet bool `json:"is_note_tweet"`
|
||||
|
|
@ -204,11 +205,8 @@ func parseFxTwitterResponse(fxResp *fxTwitterResponse, tweetID string, originalU
|
|||
|
||||
if len(tweet.Media.Videos) > 0 {
|
||||
videoURL = tweet.Media.Videos[0].URL
|
||||
thumbnailURL = tweet.Media.Videos[0].ThumbnailURL
|
||||
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 {
|
||||
thumbnailURL = tweet.Media.Photos[0].URL
|
||||
for _, photo := range tweet.Media.Photos {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue