From 4d75f2db34a8d22c876453ba45c7f6f6d771dc46 Mon Sep 17 00:00:00 2001 From: Jose Manuel Delicado Date: Sat, 7 Oct 2017 14:53:53 +0200 Subject: [PATCH] Renamed set_description to create_metadata in Twython endpoints. Added a bit more documentation and use the documented channel --- src/controller/buffersController.py | 2 +- src/twython/endpoints.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/controller/buffersController.py b/src/controller/buffersController.py index 112fb8b2..8262eda1 100644 --- a/src/controller/buffersController.py +++ b/src/controller/buffersController.py @@ -157,7 +157,7 @@ class bufferController(object): for i in attachments: photo = open(i["file"], "rb") img = self.session.twitter.twitter.upload_media(media=photo) - self.session.twitter.twitter.set_description(media_id=img["media_id"], alt_text=dict(text=i["description"])) + self.session.twitter.twitter.create_metadata(media_id=img["media_id"], alt_text=dict(text=i["description"])) media_ids.append(img["media_id"]) self.session.twitter.twitter.update_status(status=text, media_ids=media_ids) diff --git a/src/twython/endpoints.py b/src/twython/endpoints.py index 7691bfd5..b439165c 100644 --- a/src/twython/endpoints.py +++ b/src/twython/endpoints.py @@ -145,11 +145,12 @@ class EndpointsMixin(object): """ return self.post('https://upload.twitter.com/1.1/media/upload.json', params=params) - def set_description(self, **params): - """ Adds a description to an image.""" - # This method only accepts strings, no dictionaries. + def create_metadata(self, **params): + """ Adds metadata to a media element, such as image descriptions for visually impaired. + Docs: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create + """ params = json.dumps(params) - return self.post("media/metadata/create", params=params) + return self.post("https://upload.twitter.com/1.1/media/metadata/create.json", params=params) def upload_video(self, media, media_type, size=None): """Uploads video file to Twitter servers in chunks. The file will be available to be attached