+Original repo: https://github.com/twitterdev/large-video-upload-python
+Changes here are meant to be rebased.
+
# Large Media Upload
This Python sample demonstrates the following process of uploading large media (video / GIF / image) files asynchronously with the Twitter API, via the "chunked upload" method.
MEDIA_ENDPOINT_URL = 'https://upload.twitter.com/1.1/media/upload.json'
POST_TWEET_URL = 'https://api.twitter.com/1.1/statuses/update.json'
-CONSUMER_KEY = 'your-consumer-key'
-CONSUMER_SECRET = 'your-consumer-secret'
-ACCESS_TOKEN = 'your-access-token'
-ACCESS_TOKEN_SECRET = 'your-access-secret'
-
-VIDEO_FILENAME = 'path/to/video/file'
+CONSUMER_KEY = 'hJHyPhuU7nSVHrKTVsGVDM4Lw'
+CONSUMER_SECRET = '8UCYePqc1y9DY6mg0yQzLoTuq57AIysype2Si63714uACGMCbO'
+with open(os.path.expanduser('~') + '/.rainbow_oauth-fsf') as fp:
+ ACCESS_TOKEN = fp.readline().rstrip('\n')
+ ACCESS_TOKEN_SECRET = fp.readline().rstrip('\n')
oauth = OAuth1(CONSUMER_KEY,
client_secret=CONSUMER_SECRET,
Publishes Tweet with attached video
'''
request_data = {
- 'status': 'I just uploaded a video with the @TwitterAPI.',
+ 'status': tweet_text,
'media_ids': self.media_id
}
if __name__ == '__main__':
+ if (len(sys.argv) < 2):
+ print('error: expected 2+ arguments, path to video (no spaces) and tweet text')
+ sys.exit(1)
+ VIDEO_FILENAME = sys.argv[1]
+ global tweet_text
+ tweet_text = ' '.join(sys.argv[2:])
+
videoTweet = VideoTweet(VIDEO_FILENAME)
videoTweet.upload_init()
videoTweet.upload_append()