I want to upload to YouTube without having to use the web interface in order to automate some things. Is there a way to upload from the command line in OSX?


You could give this open source project a try: https://github.com/tokland/youtube-upload/

Youtube-upload is a command-line script that uploads videos to Youtube.

Youtube-upload should work on any platform (GNU/Linux, BSD, OS X, Windows, ...) that runs Python 2/3.

  • When I try to run the install script I get an error saying No module named gdata.media. – z-buffer Feb 5 '11 at 10:56
  • @z-buffer - I'm afraid I didn't write this software nor do I have a Mac so I can't test it either. I would suggest that you contact the person who created the software with any issues. Thanks – codingbadger Feb 5 '11 at 11:06
  • @z-buffer You will need to install the Google Data APIs Python Client Library. – Hydra Feb 17 '13 at 6:58


youtube-upload now uses Youtube APIv3 and OAuth2, whereas GoogleCL is broken due to OAuth1 turndown.

https://github.com/vinitkumar/googlecl is a fork of GoogleCL, which claims to have been ported to OAuth2 (it is not available via PyPI though).

Original Answer

Use GoogleCL, the universal Google command line client. It's implemented in Python and therefore cross-platform. Unlike youtube-upload it uses proper OAuth2 authentication, so you're not typing in or sending your Google account password in plain text.

Install via pip:

pip install googlecl

Uploading a video is as simple as:

google youtube post --category Education killer_robots.avi
  • youtube-upload now uses Youtube APIv3 and OAuth2. – tokland Apr 4 '16 at 7:06
  • This answer is outdated. From OP's GoofleCL link: "8 June 2015: GoogleCL is currently broken due to the OAuth1 turndown, and likely to remain so. " – Jason Conrad Mar 6 '18 at 18:34

Use this straightforward tutorial on accessing the standard Youtube Cloud API, takes 10 mins to setup and gets the job done:


Google happens to have its own upload_video.py script, and I could make it work with some, or rather a lot of, efforts mainly because of authentication. There’s probably a better way (comments welcome), but here’s what I had to do in Ubuntu 14.04, although I should work as well for 12.04 / 13.10:

Download the script:

mkdir youtube-upload
cd youtube-upload
wget https://github.com/youtube/api-samples/raw/master/python/upload_video.py

Download and extract Google API Python Client, and move relevant directories to the directory where the script is located:

wget https://google-api-python-client.googlecode.com/files/google-api-python-client-1.2.tar.gz
tar xzvf google-api-python-client-1.2.tar.gz
cd google-api-python-client-1.2/
mv apiclient/ oauth2client/ uritemplate/ ..
cd ..

In a computer with a Desktop interface, create a project called “Youtube Upload Script” with Google Cloud Console (the name and id does not matter) using the YouTube credential, and Enable YouTube Data API v3 in APIs & auth->API. In Credentials, click on CREATE NEW CLIENT ID, select Installed application for Application Type, and Other for Installed application type, and click Create Client ID. You should now have a Client ID for native application that looks like:


Back to the command line, create a file client_secrets.json vi your preferred editor (e.g. nano, vi, …), with the Client ID, Client secret, and redirect URIs above:

  "installed": {
    "client_id": "xxxxxxxxxx-yyyyyyyyyyyyyyy.apps.googleusercontent.com",
    "redirect_uris": ["http://locahost", "urn:ietf:wg:oauth:2.0:oob"],
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://accounts.google.com/o/oauth2/token"

Now you can upload a video to your YouTube account with the script. There are two cases: You have access to a desktop browser such as Chromium or Firefox on the machine where the script is executed:

python upload_video.py --file=video.webm --title="Video Title" \ 
--description="Video Description" --keywords="keyword1, keyword2" \
--category=22 --privacyStatus="unlisted"
Most options are self-descriptive. Category 22 refers to People and Blog. other categories available are: Comedy “23”, Education “27”,  Entertainment “24”,   Film & Animation “1”,  Gaming “20”,  Howto & Style “26”,  Music “10”, News & Politics  “25”,  Nonprofits & Activism “29”, People & Blogs  “22”,  Pets & Animals “15”,  Science & Technology “28”,  Sports “17”, and   Travel & Events “19”.

privacyStatus lets you choose between unlisted, private or public. The machine where the script is executed does not have access to a desktop browser, and you need to use a browser in another machine, run the following command instead:

python upload_video.py --file=video.webm --title="Video Title" \
--description="Video Description" --keywords="keyword1, keyword2" \
--category=22 --privacyStatus="unlisted" --noauth_local_webserver

It will provide a link to access in your browser, to get a verification code that you can enter in the terminal. This is only requires for the first time, after you can just upload the videos without user intervention for authentication. If you run the command without noauth_local_webserver, and if you only have access to a text based web browser this won’t work, as they don’t usually support JavaScript. That’s it, the video should now upload to your YouTube account.

Authentication successful.
Uploading file...
Video id 'sbRf3O3VCEI' was successfully uploaded.

I’ve tested it myself with with one of our videos and it went pretty quickly, from a VPS.

Read more: http://www.cnx-software.com/2014/02/09/how-to-upload-youtube-videos-with-the-command-line-in-linux/#ixzz3NUKWeuqU


The script I posted here previously actually did work for MacOS, but only after I realized the Google account you can use to upload videos to YouTube with on the web interface is not, necessarily, a YouTube account. Using the Gmail account, even after I'd granted my script access in console and even when I could use that same account to log in on the YT web site and upload videos there, had an auth fail. Using an older YT account and adding the YT API there with Oauth worked with just the default scopes. My previous post with script was downvoted, so I deleted it, but the Python script youtube_video_upload worked for me just now in Oct 2020. (https://pypi.org/project/youtube-video-upload/) If you don't need CLI, I might suggest Zapier, which can auto-upload to YouTube on different triggers, such as a new upload to Dropbox. HTH.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.