turn into working cli tool master
authorIan Kelling <iank@fsf.org>
Wed, 5 Aug 2020 19:51:27 +0000 (15:51 -0400)
committerIan Kelling <iank@fsf.org>
Wed, 5 Aug 2020 20:58:24 +0000 (16:58 -0400)
README.md
async-upload.py

index 1a43541..1e3c035 100644 (file)
--- a/README.md
+++ b/README.md
@@ -1,3 +1,6 @@
+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.
index 4c37c02..2028355 100644 (file)
@@ -10,13 +10,12 @@ from requests_oauthlib import OAuth1
 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,
@@ -153,7 +152,7 @@ class VideoTweet(object):
     Publishes Tweet with attached video
     '''
     request_data = {
-      'status': 'I just uploaded a video with the @TwitterAPI.',
+      'status': tweet_text,
       'media_ids': self.media_id
     }
 
@@ -162,6 +161,13 @@ class VideoTweet(object):
 
 
 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()