From: Harmon Date: Sun, 1 Sep 2019 19:31:54 +0000 (-0500) Subject: Add API.create_media_metadata X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=a63a2efc9dae0e6a59f30159a1f151e54b4efedb;p=tweepy.git Add API.create_media_metadata Resolves #716 Resolves #1247 --- diff --git a/docs/api.rst b/docs/api.rst index c0dec5f..cf8a996 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1083,6 +1083,17 @@ Media methods Up to 100 additional owners may be specified. +.. method:: API.create_media_metadata(media_id, alt_text) + + This endpoint can be used to provide additional information about the + uploaded media_id. This feature is currently only supported for images and + GIFs. Call this endpoint to attach additional metadata such as image alt + text. + + :param media_id: The ID of the media to add alt text to. + :param alt_text: The alt text to add to the image. + + :mod:`tweepy.error` --- Exceptions ================================== diff --git a/tweepy/api.py b/tweepy/api.py index 56d66cf..dfef2d6 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -234,6 +234,26 @@ class API(object): upload_api=True )(*args, **kwargs) + def create_media_metadata(self, media_id, alt_text, *args, **kwargs): + """ :reference: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create + :allowed_param: + """ + kwargs.update({ + 'json_payload': { + 'media_id': media_id, + 'alt_text': {'text': alt_text} + } + }) + + return bind_api( + api=self, + path='/media/metadata/create.json', + method='POST', + allowed_param=[], + require_auth=True, + upload_api=True + )(*args, **kwargs) + def update_with_media(self, filename, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update_with_media :allowed_param: 'status', 'possibly_sensitive',