python-twitter-tools / twitter

Python Twitter API
http://mike.verdone.ca/twitter/
MIT License
3.19k stars 713 forks source link

media type unrecognized error from previously working code #403

Closed WiggyB closed 5 years ago

WiggyB commented 5 years ago

I'm getting an error from code that has been working for months. "details: {'request': '/1.1/media/upload.json', 'error': 'media type unrecognized.'}"

    try:
            img_byte = io.BytesIO()
            image.save(img_byte, format='PNG')
            img_byte = img_byte.getvalue()
            id_img = self.t_upload.media.upload(media=img_byte)["media_id_string"]
            self.t_tweet.statuses.update(status=text, media_ids=id_img)
            # if twitter_uploads is not empty, try uploading them
            if os.stat("twitter_uploads.cfg").st_size != 0:
                self.try_uploads()

it falls over at "self.t_upload.media.upload(media=img_byte)["media_id_string"]" This code has been working for months and I'm very confused as to why this is suddenly not working. I've checked my access tokens, they are working fine.

RouxRC commented 5 years ago

Hi, I guess the error is quite explicit : "media type unrecognized" so I figure Twitter implemented some more restrictive image checks and now refuses such kind of generated images maybe? This seems like a Twitter API issue which you should rather raise on the forum than here: https://developer.twitter.com/en/forum