From: Harmon Date: Fri, 19 Feb 2021 16:26:16 +0000 (-0600) Subject: Only include media_category when specified in API.chunked_upload_init X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fc4acb89d6ca81193a874820cceff1b838038136;p=tweepy.git Only include media_category when specified in API.chunked_upload_init Also improve quotation mark type consistency --- diff --git a/tweepy/api.py b/tweepy/api.py index a4dcf5d..1ec8b42 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -418,14 +418,17 @@ class API: """ :reference https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/api-reference/post-media-upload-init """ headers = {'Content-Type': 'application/x-www-form-urlencoded'} + post_data = { 'command': 'INIT', 'total_bytes': total_bytes, 'media_type': media_type, - 'media_category': media_category } + if media_category is not None: + post_data['media_category'] = media_category if additional_owners is not None: - post_data["additional_owners"] = list_to_csv(additional_owners) + post_data['additional_owners'] = list_to_csv(additional_owners) + return self.request( 'POST', 'media/upload', *args, headers=headers, post_data=post_data, upload_api=True, **kwargs