I’ve discovered a bug where media entities are mixed up in certain circumstances with a tweet that contains 1 media item.
Request: https://api.twitter.com/1.1/statuses/user_timeline.json?count=4&max_id=375551948524888064&user_id=14257869
Response: http://pastie.org/private/96are1ocgdcunutwi7ozhg
You can see the bug in the last tweet of the response. Both the entity media and the extended entity media return two items instead of one. Both media arrays contain media info and extended media info.
This should not be the case, the entities.media array should contain 1 media dictionary, and the extended_entities.media array should contain 1 media dictionary (with more detail than the first).
That above response contains 4 items, the last of which is the one containing the error. The first item also contains media, but appears to be okay. Interestingly, if we skip that first tweet by moving the max_id down one tweet, the issue with our tweet in question disappears. So it appears to be an issue where those two tweets are returned in the same response.
Request not expressing the bug: https://api.twitter.com/1.1/statuses/user_timeline.json?count=4&max_id=375548928630226944&user_id=14257869
So I believe this is a bug in the Twitter REST API v1.1.