Can't find the video element in extended_entities

video
api
extended-entities

#1

My API call is https://api.twitter.com/1.1/lists/statuses.json?tweet_mode=extended&slug=Usa&owner_screen_name=giuliohome
Among the list, I’m looking at a tweet containing a video
and I see indeed that
jsonObject.getJSONObject("extended_entities").getJSONArray("media").getJSONObject(0).getString("expanded_url")
is
https://twitter.com/businessinsider/status/914208243068440576/video/1
but the type is “photo” and there is no JSONObject “video_info”…
how can I get the mp4 link?

Notice that there’s the same problem (described above) also for a single tweet show API and with extended mode
"https://api.twitter.com/1.1/statuses/show.json?id=914208243068440576&tweet_mode=extended


Twitter Videos returned api do not contain extended_entities?
#2

It looks like the vide_info is present only if the video is attached to a tweet in my own timeline??

That makes no sense at all: can someone from Twitter please explain?

Tested with my id 914278370606686208
where I’ve actually found
jsonObject.getJSONObject("extended_entities").getJSONArray("media").getJSONObject(0)
equals to
{"id":914278122736029697,"id_str":"914278122736029697","indices":[79,102],"media_url":"http:\/\/pbs.twimg.com\/ext_tw_video_thumb\/914278122736029697\/pu\/img\/OCmlwjmt3AmSgf-g.jpg","media_url_https":"https:\/\/pbs.twimg.com\/ext_tw_video_thumb\/914278122736029697\/pu\/img\/OCmlwjmt3AmSgf-g.jpg","url":"https:\/\/t.co\/DS5F6VG7D0","display_url":"pic.twitter.com\/DS5F6VG7D0","expanded_url":"https:\/\/twitter.com\/giuliohome\/status\/914278370606686208\/video\/1","type":"video","sizes":{"small":{"w":340,"h":340,"resize":"fit"},"thumb":{"w":150,"h":150,"resize":"crop"},"medium":{"w":600,"h":600,"resize":"fit"},"large":{"w":720,"h":720,"resize":"fit"}},"video_info":{"aspect_ratio":[1,1],"duration_millis":45000,"variants":[{"content_type":"application\/x-mpegURL","url":"https:\/\/video.twimg.com\/ext_tw_video\/914278122736029697\/pu\/pl\/Rx2WP4c8fS5iSXjl.m3u8"},{"bitrate":832000,"content_type":"video\/mp4","url":"https:\/\/video.twimg.com\/ext_tw_video\/914278122736029697\/pu\/vid\/480x480\/V7W0dbJzlqGnF1Pd.mp4"},{"bitrate":320000,"content_type":"video\/mp4","url":"https:\/\/video.twimg.com\/ext_tw_video\/914278122736029697\/pu\/vid\/240x240\/lEf-P2xyDdVhdfXl.mp4"},{"bitrate":1280000,"content_type":"video\/mp4","url":"https:\/\/video.twimg.com\/ext_tw_video\/914278122736029697\/pu\/vid\/720x720\/SJQxZ5qf70XSqwHf.mp4"}]},"additional_media_info":{"monetizable":false}}


#3

That’s not a normal video. It has been posted via https://studio.twitter.com/

That means, usually, that it is an advert. Twitter don’t display adverts via the API.


#4

Thank you @edent! I’ve tried with a lot of tweets, that was only an example. I would be glad to test whatever tweet you suggest that is supposed to work. Just tell me which is your example, thanks. So, by the way, you are confirming that you find the video_info in tweets that don’t belong to your timeline, aren’t you?


#5

Yes - I can see the video_info of tweets I haven’t posted.

See https://api.twitter.com/1.1/statuses/show/914038608302153728.json?tweet_mode=extended on https://apigee.com/console/twitter

I get the full video_info data.


#6

This is not an advertisement though

https://api.twitter.com/1.1/statuses/show/914812218654416898.json?tweet_mode=extended

There is no reason why Twitter should block this content from its API


#7

These are the important elements to be aware of in this Tweet:

        "additional_media_info": {
          "title": "America's immigration policy is an advantage says Microsoft CEO",
          "description": "We sat down with Microsoft CEO Satya Nadella to talk about how America's immigration policy is actually a major competitive advantage for companies. Nadella is also the author of Hit Refresh.",
          "call_to_actions": {
            "watch_now": {
              "url": "http://www.businessinsider.com/category/bi-original-video"
            }
          },
          "embeddable": false,
          "monetizable": true
        }
      }
    ]
  },
  "source": "<a href=\"https://studio.twitter.com\" rel=\"nofollow\">Media Studio</a>",

This Tweet was posted using our Twitter Media Studio tool, which is primarily aimed at publishers. In this case, the publisher has marked the content as monetizable, but not embeddable. We recently announced these fields as part of extensions to the Twitter API to enable more control over content rights for publishers.


#8

The only relevant thing appears to be embeddable.

Both Media Studio and monetizable seem unrelated.

Look at 919468660183375872.


#9

Yes, you’re right, that one shows as embeddable: true so that’s why the video data is served as part of the API Tweet object (my Tweet reply to you was incorrect, apologies). If it is marked embeddable: false by the media owner, then only the thumbnail will be served in the Tweet object, and you should not attempt to embed the video content.