Search code examples
javascripttypescriptnpmtwitter

Twitter Media entities always return images (Thumbnail image) not the video or the gif


For this tweet I only get the following as media entity:

{
  id: 1291683183411437600,
  id_str: '1291683183411437568',
  indices: [ 149, 172 ],
  media_url: 'http://pbs.twimg.com/tweet_video_thumb/Eez7Av2VoAAK58T.jpg',
  media_url_https: 'https://pbs.twimg.com/tweet_video_thumb/Eez7Av2VoAAK58T.jpg',
  url: 'STACKOVERFLOW TOLD ME TO REMOVE THIS URL',
  display_url: 'pic.twitter.com/I3Clni8MeD',
  expanded_url: 'https://twitter.com/_Weeekly/status/1291683199240695809/photo/1',
  type: 'photo',
  sizes: {
    thumb: { w: 150, h: 150, resize: 'crop' },
    medium: { w: 846, h: 1200, resize: 'fit' },
    large: { w: 1024, h: 1452, resize: 'fit' },
    small: { w: 480, h: 680, resize: 'fit' }
  }
}

This is the function I use:

let params = {
    screen_name: tweeter.tweeter,
    since_id: parseInt(tweeter.latestTweetId),
    include_rts: true,
    tweet_mode: "extended",
    count: 1000
};
twitterClient.get("statuses/user_timeline", params, async function (
    error,
    tweets
) { 
       //code
}

How can I get the gifs/video links from the user_timeline?


Solution

  • Check the media object that is inside the extended_entities part of the Tweet.