Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

twitter.models.Status.media.AsDict() does not contain the key 'sizes'. #357

Description

@sharmaeklavya2

I'm porting code from python-twitter version 1.1 to 3.1 in Zulip.

In version 1.1, twitter.Status.media used to be a list of dicts. In version 3.1, twitter.models.Status.media it is a list of twitter.models.Media.

We weren't using models in our code. We used to get a dict obtained from AsDict to access all data. I think it will be easy to quickly switch to version 3.1 if we continue to do that.

In version 1.1, twitter.Status.AsDict() didn't include media by default, so we used to add that explicitly like this - res['media'] = tweet.media (res was initialized to tweet.AsDict()). In version 3.1, media is added by default in twitter.Status.AsDict(), so we no longer need that workaround.

I noticed that the format of the dict returned by AsDict() has changed slightly. Most notably, the sizes key is no longer in the media dicts. We were using that to get the largest image smaller than a particular threshold height. Now I can't find a way to do that. Can you suggest something?

The Twitter API still seems to support sizes, as can be seen here: https://dev.twitter.com/overview/api/entities-in-twitter-objects#media.

Was the sizes key intentionally removed? If yes, why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions