You are reading a single comment by @rhb and its replies. Click here to read the full conversation.
  • 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']])
    
About

Avatar for rhb @rhb started