-
For a pause, put
import time
near the top, then insert
time.sleep(5.5) # Pause 5.5 seconds
between the upload_video and update_status lines. It'll probably achieve nothing, but it's something I'd try out of curiosity.
For verifying that the upload_video step is successful:
response = api.upload_video(media=video, media_type='video/mp4') api.update_status(status=tweetStr, media_ids=[response['media_id']])
On line one, you're uploading your file to Twitter, and the response (including a unique identifier for the media file you just uploaded) is stashed in the response variable. You need that ID because when you then send your tweet with update_status, you need to attach the file to your tweet, and you do that by passing the ID of the media file along with your tweet: media_ids=[response['media_id']]
To verify the media upload worked, I'd probably start by just printing out response['media_id'] and seeing if it looks sane. E.g.
video = open('5into15.mp4', 'rb') response = api.upload_video(media=video, media_type='video/mp4') print('media_id', response['media_id']) api.update_status(status=tweetStr, media_ids=[response['media_id']])
-
I tried both these ammemds on just the tweet step using yesterday's 5into15.mp4 but it failed without confirming the video was uploaded so presume it is an error in the video.
I did a new timelapse using the old script to create a new and it worked again (although I had to confirm it could overwrite the mp4 as I hadn't removed it) - also it is upside down & half obscured as I wasn't thinking when setting it up. https://twitter.com/5into15/status/1382727672963461121?s=19
I'll ammend that to add in the response confirmation line as it'll be useful to have as well as the time checks at each step.
I guess the encoding of the video to h264 might be the problem point still?
I'll see if I can add a pause... assuming the code is relatively straightforward?
I'm not sure how I'd do this? The fact it tweets is usually the verification all went ok. Does twitter return "answers" to each step i could somehow ask the code to delve into?
E.g. if video upload = success, go tweet, else stop, hammer time?