tweepy / tweepy

Twitter for Python!
https://www.tweepy.org
MIT License
10.54k stars 4.6k forks source link

Uploading a GIF (From Linux) leads to error: "Media could not be displayed" #2013

Open jetley opened 2 years ago

jetley commented 2 years ago

Hi,

I'm working on a bot where it randomly uploads media (still images or gifs) to Twitter. It works fine whne it's a still image, but when it's a GIF, the GIF can't be shown on Twitter: "Media couldn't be displayed" (Link for reference).

I've tried uploading the GIF manually to another account and there's not a single problem, the GIF can be displayed correctly, so there's no error when exporting the media to a GIF (since it's made with FFMPEG).

This is the code I'm using for uploading:

mediaUpload = api.media_upload(filename="./media_upload/GIF.gif", chunked=True, media_category="tweet_gif")
api.create_media_metadata(mediaUpload.media_id_string, altText)
api.update_status(data[5], media_ids=[mediaUpload.media_id_string])

The real problem: It works fine when the code is executed from Windows 11. The "Media could not be displayed" error ocurrs when the bot it's running under Debian GNU (Where the bot is hosted). In both Windows 11 and Debian, I'm using the latest stable version of Tweepy.

lebraat commented 2 years ago

Hey @jetley

Can you please further explain what you mean when you say 'I've tried uploading the GIF manually to another account':

And can you confirm that my reiteration of your problem is correct: So far, you've identified that this is only an issue when executing the request via Debian.

jetley commented 2 years ago

Hi,

Thanks for replying (and sorry for my late reply).

I will try to explain myself better: When I say "I tried to upload the GIF manually" i mean the following: I uploaded the GIF to my personal account via twitter's desktop web page (drag and drop method) and it works fine. GIF is shown correctly when uploaded. Therefore, the GIF itself is not the problem but the SO from where it is being uploaded (in my case, Debian). The code used to upload in both Win11 and Debian is exactly the same.

For the moment, I'm considering making a few different VMs with different Linux distros in order to determine more closely the problem. If the issue only happens to exist in Debian, I can switch to another OS effortlessly.

jetley commented 1 year ago

Hi, any updates on this bug?...

Harmon758 commented 1 year ago

@boidushya Please don't ghost ping.

Regardless, a reproducible example (MCVE/SSCCE) is necessary here. Although, if this is an OS-specific issue, I don't have an easy way of reproducing it on my end. This seems likely an issue on Twitter's end anyway, but Daniel (lebraat) no longer works at Twitter, so I don't really have any means of following up to see if it is or not anymore.

boidushya commented 1 year ago

my bad Was having this issue but I managed to resolve it by using chunk based upload with chunk=True. Thought that might resolve it but OP was already doing that.

On Sun, May 28, 2023 at 10:36 PM Harmon @.***> wrote:

@boidushya https://github.com/boidushya Please don't ghost ping.

Regardless, a reproducible example (MCVE/SSCCE) is necessary here. Although, if this is an OS-specific issue, I don't have an easy way of reproducing it on my end. This seems likely an issue on Twitter's end anyway, but Daniel (lebraat) no longer works at Twitter, so I don't really have any means of following up to see if it is or not anymore.

— Reply to this email directly, view it on GitHub https://github.com/tweepy/tweepy/issues/2013#issuecomment-1566201435, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGMB6ZKYUDHD6K3QWWT5GPDXIOAY3ANCNFSM6AAAAAAR7AFZYY . You are receiving this because you were mentioned.Message ID: @.***>

jakeonfire commented 6 months ago

if anybody encounters this issue, i was able to solve it per the nice documentation summary here: https://github.com/sferik/x-ruby/issues/22#issuecomment-1922532165