shichao-an / twitter-photos

Simple, fast command-line tool to get photos from Twitter accounts
https://twitter-photos.shichao.io
BSD 2-Clause "Simplified" License
171 stars 39 forks source link

Statuses with multiple photos #4

Closed 7185 closed 8 years ago

7185 commented 8 years ago

Not sure if it's a bug from the API or from this script, but it seems like when there is a tweet with multiple pictures, only the first one is downloaded. Is there a way to solve this? I think the problem is related to what I just read in this blogpost.

Thanks for this great tool!

7185 commented 8 years ago

I looked into it some more and this is what I found:

https://github.com/shichao-an/twitter-photos/blob/master/twphotos/photos.py#L99-L103

Only the first media object is fetched. This makes sense since the python-twitter I had installed (v1.1) only returned one media object (thanks Debian…).

However, the last version of python-twitter I found (3.0-rc1) supports extended_entities so I installed it and changed the code to:

fetched_photos = []
    for s in statuses:
        for m in s.media:
            if m.type == 'photo':
                fetched_photos.append((m.id, m.media_url))

And voilà.

I guess this is tricky to fix without breaking backward compatibility, so I'm just leaving this here in case someone else runs across the same issue.

shichao-an commented 8 years ago

Hi @7185 , thanks for filing the issue. I'll look into this if I have time. Besides, pull requests are welcome.