Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

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?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

You could give this open source project a try http://code.google.com/p/youtube-upload/

Youtube-upload is a command-line script that uploads videos to Youtube. If a video does not comply with Youtube limitations (<2Gb and <15'), it will be automatically splitted before uploading.

Youtube-upload should work on any platform (GNU/Linux, BSD, OS X, Windows, ...) that runs Python and FFmpeg (see the dependecies section). You won't need FFmpeg if the video does not need splitting.

share|improve this answer
    
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 –  Barry 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

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

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

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:

Youtube_Native_Client_ID

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",
    "client_secret":"ABCDXXxxxxxxxxx-CddddddddD",
    "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

share|improve this 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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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