Merge branch 'master' into video-upload
authorHarmon <Harmon758@gmail.com>
Fri, 12 Feb 2021 04:49:37 +0000 (22:49 -0600)
committerGitHub <noreply@github.com>
Fri, 12 Feb 2021 04:49:37 +0000 (22:49 -0600)
1  2 
tests/test_api.py
tweepy/api.py

index 83496783761f10882f0da50ecfce42064a4af9d6,33a5890b806573f9939a613608fc3dca6a7bc39a..0f40f08ae059a3d078e097c5b76e0d519cf420f5
@@@ -113,24 -113,12 +113,24 @@@ class TweepyAPITests(TweepyTestCase)
          update = self.api.update_with_media('examples/banner.png', status=tweet_text)
          self.assertIn(tweet_text + ' https://t.co', update.text)
  
-     @tape.use_cassette('testgetuser.json')
 +    @tape.use_cassette('testmediauploadpng.yaml', serializer='yaml')
 +    def testmediauploadpng(self):
 +        self.api.media_upload('examples/banner.png')
 +
 +    @tape.use_cassette('testmediauploadgif.yaml', serializer='yaml')
 +    def testmediauploadgif(self):
 +        self.api.media_upload('examples/animated.gif')
 +
 +    @tape.use_cassette('testmediauploadmp4.yaml', serializer='yaml')
 +    def testmediauploadmp4(self):
 +        self.api.media_upload('examples/video.mp4')
 +
+     @tape.use_cassette('testgetuser.yaml', serializer='yaml')
      def testgetuser(self):
-         u = self.api.get_user('Twitter')
+         u = self.api.get_user(screen_name='Twitter')
          self.assertEqual(u.screen_name, 'Twitter')
  
-         u = self.api.get_user(783214)
+         u = self.api.get_user(user_id=783214)
          self.assertEqual(u.screen_name, 'Twitter')
  
      @tape.use_cassette('testlookupusers.json')
diff --cc tweepy/api.py
index 503e76f9f3b6198a53f009df07a60bd6a989fe85,dd389a549840f259ba1877f4fcdd3efe154b7d56..a452f825642bc994b28a5bc07de775f9785245bc
@@@ -440,24 -361,10 +440,24 @@@ class API
              upload_api=True, **kwargs
          )
  
-     def create_media_metadata(self, media_id, alt_text, *args, **kwargs):
 +    @payload('media')
 +    def chunked_upload_finalize(self, media_id, *args, **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', *args, headers=headers,
 +            post_data=post_data, upload_api=True, **kwargs
 +        )
 +
+     def create_media_metadata(self, media_id, alt_text, **kwargs):
          """ :reference: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create
          """
-         kwargs['json_payload'] = {
+         json_payload = {
              'media_id': media_id,
              'alt_text': {'text': alt_text}
          }