Only include media_category when specified in API.chunked_upload_init
authorHarmon <Harmon758@gmail.com>
Fri, 19 Feb 2021 16:26:16 +0000 (10:26 -0600)
committerHarmon <Harmon758@gmail.com>
Fri, 19 Feb 2021 16:26:16 +0000 (10:26 -0600)
Also improve quotation mark type consistency

tweepy/api.py

index a4dcf5d8105c588c51f80dd2d74cc3ae8bad2d5f..1ec8b429c05b090349e6eda745369e4812a02e25 100644 (file)
@@ -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