Command-line script to upload videos to Youtube using the Youtube APIv3.
The Youtube API uses OAuth 2.0 to authenticate the upload.
Important
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 now must create and use your own OAuth 2.0 file.
Click here if you need to create one.
- Go to the Google console.
- Create project.
- Getting Started -> Explore and enable APIs -> APIs -> Credentials.
- Create a Client ID: Create Credentials -> OAuth client ID -> Desktop App -> Name: youtube-upload -> Create -> OK
- Download JSON: Under the section "OAuth 2.0 client IDs". Save the file to
~/.client_secrets.json
.
Tip
Use of the Semaphore playbook is preferred, as it automates the following steps.
Click here if you're a rebel.
- Install the python dependencies
sudo pip3 install --upgrade google-api-python-client oauth2client
- Make sure
my_credentials.json
and.client_secrets.json
are both located in your home folder.
- Set
scriptman.service
with the correctCAMPUS
environment variable.
sudo nano /etc/systemd/system/scriptman.service
and set where you see Environment=CAMPUS=""
enter the name of the campus in the quotes.
Example: Environment=CAMPUS="Riverside"
youtube-upload \
--title="$CAMPUS Service $(date +%D)" \
--privacy="unlisted" \
--playlist="$CAMPUS" \
/home/pi/service.mp4
--description="A.S. Mutter plays Beethoven"
--thumbnail (string)
--tags="mutter, beethoven"
--privacy (public | unlisted | private)
--category="Music"
--publish-at (YYYY-MM-DDThh:mm:ss.sZ)
--recording-date="2011-03-10T15:32:17.0Z"
--location (latitude=VAL,longitude=VAL[,altitude=VAL])
--default-language="en"
--default-audio-language="en"
--embeddable=True|False
--credentials-file="my_credentials.json"
--client-secrets="my_client_secrets.json"