This script allows to upload multiple captions files to a YouTube video. It uses the YouTube APIs (specifically the Captions Insert API) and requires a Google account that has Owner permissions on the channel.
-
Download the repo and extract it in a folder of your choice.
-
Install Python from https://www.python.com/downloads
-
Obtain Google OAuth Client ID: In order to run the script, you will need to obtain OAuth authorization credentials from the Google developer console. For this, you can follow the steps here. When following the steps at this link, after completing all steps including 3.5, select "Desktop app" as the application type, and name your app anything you want, then download the json file, place it next to the py script file (in the current folder) and rename it client_secret.json
-
If that's the first time you are running the script or if your token has expired, delete the *token.json file.
-
The script expects to have the following vtt files in a single folder (for example C:\Captions):
- caption-en-us.vtt
- caption-fr-fr.vtt
- caption-de-de.vtt
- caption-it-it.vtt
- caption-ja-jp.vtt
- caption-ko-kr.vtt
- caption-pt-pt.vtt
- caption-ru-ru.vtt
- caption-es-es.vtt
- caption-zh-cn.vtt
If you are getting them from the Docs Video Portal, just download every single vtt file in a folder.
-
Get your YouTube video ID from your YouTube video URL, extract the ID (see bold part in examples):
https://www.youtube.com/watch?v=OzTagK628FM https://youtu.be/OzTagK628FM
-
Run the script
From the Terminal, make sure you are in the folder where the script file is, then type the following command (replacing the video ID and path to captions files with yours):
python .\UploadCaptions.py OzTagK628FM "C:\Captions"
-
Get your authorization code
On the first run or after you have deleted the token.json file, you will be prompted to visit a URL and get an authorization code. For this, visit the URL displayed in your terminal:
Select the brand account to get the credentials for:
Click on Continue to discard warning message:
Click on Allow to generate and access your code:
Copy the Code:
Paste the code in your terminal and hit Enter
From here, the script will proceed with the creation of the captions and upload of the files from the local folder