Youtube-upload is a command line Python script that uploads videos to Youtube (it should work on any platform -GNU/Linux, BSD, OS X, Windows, ...- that runs Python) using theYoutube APIv3.
- Python 2.6 or 2.7. Python 3.0 is NOT supported.
- Python Google API
Check if your operating system provides a package for the google API library. If not, this should work:
$ pip install --upgrade google-api-python-client
$ 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 bin/youtube_upload ...
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.
The package includes a default client_secrets.json
file. If you plan to make a heavy use of the script, please create and use your own OAuth 2.0 file, it's a free service. Steps:
- Go to the Google console.
- Create project.
- Side menu: APIs & auth -> APIs
- Top menu: Enabled API(s): Enable all Youtube APIs.
- Side menu: APIs & auth -> Credentials.
- Create new Client ID: Application type: Installed application + Other
- Download JSON: save the file to your local system.
- Use the saved JSON as your credentials file:
--client-secrets=CLIENT_SECRETS
- Upload a video:
$ youtube-upload --title="A.S. Mutter" anne_sophie_mutter.flv
pxzZ-fYjeYs
- Upload a video with more metadata and your own client secrets 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
- Upload a video using a browser window to authenticate (if required):
$ youtube-upload --title="A.S. Mutter" --auth-browser anne_sophie_mutter.flv
- 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_proxy
$ youtube-upload ....
- Main logic of the upload: main.py (function
upload_video
). - Check the Youtube Data API.
- Some Youtube API examples provided by Google.
- License: GNU/GPLv3.
- Donations.
- If you find a bug, open an issue.
- If you want a new feature to be added, you'll have to send a pull request (or find a programmer to do it for you), currently I am not adding new features.