Upload videos to Youtube from the command line https://github.com/tokland/youtube-upload

Arnau Sanchez c0f473c324 Update README.md 10 years ago
bin e70474dc55 general refactor using APIv3 and Oauth2 10 years ago
examples 2d43706950 fix title template 10 years ago
youtube_upload 3d24e46896 fix lib.py 10 years ago
README.md c0f473c324 Update README.md 10 years ago
client_secrets.json e70474dc55 general refactor using APIv3 and Oauth2 10 years ago
setup.py d0d6974f4c fix version 10 years ago

README.md

Introduction

Youtube-upload is a command-line script that uploads videos to Youtube (it should work on any platform -GNU/Linux, BSD, OS X, Windows, ...- that runs Python) using the APIv3.

Dependencies

Install

$ wget https://github.com/tokland/youtube-upload/archive/master.zip
$ unzip master.zip
$ cd youtube-upload-master
$ sudo python setup.py install
  • Or run directly from sources:

    $ cd youtube-upload-master
    $ PYTHONPATH=. python youtube_upload/youtube_upload.py ...
    

Authentication

You'll see that there is no email/password options. Instead, the Youtube API uses OAuth 2.0 to authenticate the upload. The first time you try to upload a video, you will be asked to follow a URL in your browser to get an authentication token. If you have multiple channels for the logged in user, you will also be asked to pick which one you want to upload the videos to. You can use multiple credentials, just use the option --credentials-file. Also, check the token expiration policies.

Examples

  • Upload a video

    $ youtube-upload --title="A.S. Mutter" --description="A.S. Mutter plays Beethoven" \
                 --category=Music --tags="mutter, beethoven" anne_sophie_mutter.flv
    pxzZ-fYjeYs
    
  • Upload a video with your own client_secrets.json and credentials file:

    $ youtube-upload --title="A.S. Mutter" --description="A.S. Mutter plays Beethoven" \
                 --category=Music --tags="mutter, beethoven" 
                 --client-secrets=my_client_secrets.json
                 --credentials-file=my_credentials.json anne_sophie_mutter.flv
    tx2Zb-145Yz
    
  • Split a video with ffmpeg

Youtube currently limits videos to <2Gb and <15' for almost all users. You can use the example script to split it before uploading:

$ bash examples/split_video_for_youtube.sh video.avi
video.part1.avi
video.part2.avi
video.part3.avi
  • Use a HTTP proxy

Set environment variables http_proxy and https_proxy:

$ export http_proxy=http://user:password@host:port
$ export https_proxy=http://user:password@host:port
$ youtube-upload ....

Caveats

Notes for developers

More