This project was created based on code samples from YouTube's Python API documentation with adjustments made to enable mass uploads using a CSV metadata file.
This page in the YouTube API documentation was very helpful for creating this project.
Create OAuth tokens
First, you need to enable the YouTube API and setup a client_id and client_secret. To do this, follow the steps below.
- Go to the Google Cloud Console
- Create a new project by clicking Select a project in the header and then click NEW PROJECT. Note: If you already have a project, the Select a project button will be the name of the current project you are viewing.
- Add a name for the project (i.e. Python YouTube uploader)
- After the project is created, click Select a project and select the project you just created
- In the left sidebar click APIs & Services -> Dashboard
- Click ENABLE APIS AND SERVICES
- Enter YouTube in the search box and select YouTube Data API v3
- Click Enable
- Once the API is enabled, click Credentials in the left sidebar
- Click Create credentials and select the option OAuth client ID
- If a message appears about setting a product name for the consent screen follow these instructions.
- click Configure consent screen
- Enter a product name in the field labeled Product name shown to users (i.e. Python YouTube uploader)
- Click Save
- Select Other for the application type and name it what you would like (i.e. Python YouTube uploader)
- Copy the client ID and the client secret to use when running the create tokens command
Now that you have that, run the following command to create OAuth2 tokens.
Running the upload script
To use, add the videos you would like to upload to files.csv. Then you can invoke the script using the code below.
To specify the location of the csv input file.
python youtube.py ~/files-to-upload.csv