Code Monkey home page Code Monkey logo

large-video-upload-python's Introduction

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.

  1. INIT media upload.
  2. APPEND chunked data.
  3. FINALIZE media uploaded.
  4. Check STATUS of media processing.
  5. Tweet with attached media.

Large video files are longer than 30 seconds / up to 140 seconds, and/or a file size larger than 15 megabytes up to 512 megabytes.

Learn more about the Twitter Media APIs. Pay attention to the other requirements such as encoding, frame size and video formats supported, as these may be reasons for uploads failing at the processing stage.

Running the sample

  1. Install requirements:

    $ pipenv shell
    $ pipenv install
    
  2. Fill in your consumer keys and access tokens in async-upload.py:

    CONSUMER_KEY = 'your-consumer-key'
    CONSUMER_SECRET = 'your-consumer-secret'
    ACCESS_TOKEN = 'your-access-token'
    ACCESS_TOKEN_SECRET = 'your-access-secret'
    
  3. Edit path to your media file in async-upload.py:

VIDEO_FILENAME = 'path/to/video/file'
  1. Run script:

    $ python async-upload.py
    

Questions? Check our developer discussion forums.

large-video-upload-python's People

Contributors

andypiper avatar jcipriano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

large-video-upload-python's Issues

Video upload always fails

I get the error:
INIT
Media ID: 1263253181288546307
APPEND
986718 of 986718 bytes uploaded
Upload chunks complete.
FINALIZE
{'media_id': 1263253181288546307, 'media_id_string': '1263253181288546307', 'media_key': '7_1263253181288546307', 'size': 986718, 'expires_after_secs': 86400, 'processing_info': {'state': 'pending', 'check_after_secs': 1}}
Media processing status is pending
Checking after 1 seconds
STATUS
Media processing status is failed

I tried other videos and it does the same thing

Would love to see plain text of HTTP requests for reference

Hey Twitter peeps! I've been struggling with this API for an entire day. I'm re-implementing some of this functionality in Deno and I can't seem to get it to work. I keep getting error 32 on the APPEND step, even though the authentication works fine on every other step except this one.

I've been clued in that this error is because of some mistake with encoding my multipart/form-data, but I'm using modern web standard with no clear reason to distrust that part of the code.

I would love to see plain text versions of the HTTP requests that are the result of the code in this repository so I can actually reference a real HTTP request rather than having to find out how thousands of different libraries build a different request that might work.

If you peeps would help out with that, that'd be great. Thanks! ๐Ÿ™๐Ÿป

large-video-upload-python async upload code does not working correctly.

{u'media_id_string': u'881896187762233346', u'media_id': 881896187762233346, u'processing_info': {u'check_after_secs': 5, u'state': u'pending'}, u'expires_after_secs': 86400, u'size': 10492221}
Media processing status is pending 
Checking after 5 seconds
STATUS
Media processing status is failed 

I got this error when trying upload 10MB video file to my twitter account.

any idea?

it doesn't run in crontab as a root.

describing the issue

I use crontab [ to schedule tasks on ubuntu 16.04 ] to run a script that does the work automatically for me, but when it runs the line ( pipenv run python async-python.py ) it doesn't work with crontab.

Expected behaviour

description of how to run this script in crontab on ubuntu 16.04.

is the media category 'tweetvideo'?

I found the twitter document says media category should be tweet_video.
But i looked into your code, it wrote as 'media_category': 'tweetvideo'
Does it work as well?
Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.