twitter-api-client
twitter-api-client copied to clipboard
Cannot upload .webp media
.webp
is supported by the API via Twitter Media Best Practices
If you try to upload a .webp image the library throws an error, for example...
Code:
account.tweet(text, media=[{"media": "image.webp", "alt": "some nice words about img"}])
Will produce this error:
Traceback (most recent call last):
File "main.py", line 150, in <module>
send_tweet = alerts.twt(tweet["text"], tweet["media"])
File "alerts.py", line 48, in twt
tweet_sent = account.tweet(alert, media=media)
File "venv\lib\site-packages\twitter\account.py", line 160, in tweet
media_id = self._upload_media(m['media'])
File "venv\lib\site-packages\twitter\account.py", line 512, in _upload_media
media_category = f'{upload_type}_gif' if 'gif' in media_type else f'{upload_type}_{media_type.split("/")[0]}'
TypeError: argument of type 'NoneType' is not iterable
But if you go to venv\lib\site-packages\twitter\account.py
Line 510
and add:
# Add .webp MIME type
mimetypes.add_type('image/webp', '.webp')
Now you can upload .webp
media
Issues aside, thank you for maintaining this Trevor <3