From: Harmon Date: Sun, 11 Apr 2021 18:45:07 +0000 (-0500) Subject: Update and improve documentation for API.chunked_upload_finalize X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=67eb50cb3040787aafd7d1ee7206879458eec08a;p=tweepy.git Update and improve documentation for API.chunked_upload_finalize Automatically use docstring for documentation Improve method and documentation order --- diff --git a/docs/api.rst b/docs/api.rst index 257a97f..f1d79e2 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -221,6 +221,8 @@ Upload media .. automethod:: API.chunked_upload_append +.. automethod:: API.chunked_upload_finalize + Account Methods --------------- @@ -451,18 +453,6 @@ Media methods :rtype: :class:`Media` object -.. method:: API.chunked_upload_finalize(media_id) - - Use this endpoint after the entire media file is uploaded via appending. - If (and only if) the response contains a ``processing_info field``, it may - also be necessary to check its status and wait for it to return success - before proceeding to Tweet creation. - - :param media_id: The ``media_id`` returned from the initialization. - - :rtype: :class:`Media` object - - :mod:`tweepy.error` --- Exceptions ================================== diff --git a/tweepy/api.py b/tweepy/api.py index 4f7ba89..44b7f15 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -2514,6 +2514,31 @@ class API: upload_api=True, **kwargs ) + @payload('media') + def chunked_upload_finalize(self, media_id, **kwargs): + """chunked_upload_finalize(media_id) + + Use this endpoint after the entire media file is uploaded via + appending. If (and only if) the response contains a + ``processing_info field``, it may also be necessary to check its status + and wait for it to return success before proceeding to Tweet creation. + + :param media_id: The ``media_id`` returned from the initialization. + + :rtype: :class:`Media` object + + :reference https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload-finalize + """ + headers = {'Content-Type': 'application/x-www-form-urlencoded'} + post_data = { + 'command': 'FINALIZE', + 'media_id': media_id + } + return self.request( + 'POST', 'media/upload', headers=headers, post_data=post_data, + upload_api=True, **kwargs + ) + @payload('media') def chunked_upload_init(self, total_bytes, media_type, *, media_category=None, additional_owners=None, @@ -2537,20 +2562,6 @@ class API: upload_api=True, **kwargs ) - @payload('media') - def chunked_upload_finalize(self, media_id, **kwargs): - """ :reference https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload-finalize - """ - headers = {'Content-Type': 'application/x-www-form-urlencoded'} - post_data = { - 'command': 'FINALIZE', - 'media_id': media_id - } - return self.request( - 'POST', 'media/upload', headers=headers, post_data=post_data, - 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