From 99028ec2d9c0c8cc8ed51e0f0cc4f8ca764707ae Mon Sep 17 00:00:00 2001 From: Harmon Date: Sun, 11 Apr 2021 13:09:10 -0500 Subject: [PATCH] Update and improve documentation for API.get_media_upload_status Automatically use docstring for documentation Improve method and documentation order Add API documentation headers to match API reference index Improve capitalization Improve formatting --- docs/api.rst | 17 ++++++++--------- tweepy/api.py | 30 ++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 9cc5739..cb5a9cc 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -203,6 +203,14 @@ Sending and receiving events .. automethod:: API.send_direct_message +Media +----- + +Upload media +^^^^^^^^^^^^ + +.. automethod:: API.get_media_upload_status + Account Methods --------------- @@ -526,15 +534,6 @@ Media methods :param alt_text: The alt text to add to the image. -.. method:: API.get_media_upload_status(media_id) - - This endpoints sends a STATUS command that will check on the progress of - a chunked media upload. If the upload has succeeded, it's safe to create - a tweet with this ``media_id``\ . - - :param media_id: The ID of the media to check. - - :mod:`tweepy.error` --- Exceptions ================================== diff --git a/tweepy/api.py b/tweepy/api.py index f9af7d5..18570f3 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -2302,6 +2302,26 @@ class API: json_payload=json_payload, **kwargs ) + # Upload media + + @payload('media') + def get_media_upload_status(self, media_id, **kwargs): + """get_media_upload_status(media_id) + + This endpoints sends a STATUS command that will check on the progress + of a chunked media upload. If the upload has succeeded, it's safe to + create a Tweet with this ``media_id``. + + :param media_id: The ID of the media to check. + + :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/get-media-upload-status + """ + return self.request( + 'GET', 'media/upload', endpoint_parameters=( + 'command', 'media_id' + ), command='STATUS', media_id=media_id, upload_api=True, **kwargs + ) + def media_upload(self, filename, *, file=None, chunked=False, media_category=None, additional_owners=None, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/overview @@ -2459,16 +2479,6 @@ class API: upload_api=True, **kwargs ) - @payload('media') - def get_media_upload_status(self, media_id, **kwargs): - """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/get-media-upload-status - """ - return self.request( - 'GET', 'media/upload', endpoint_parameters=( - 'command', 'media_id' - ), command='STATUS', media_id=media_id, upload_api=True, **kwargs - ) - @payload('json') def rate_limit_status(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status -- 2.25.1