As a content creator on YouTube, uploading videos and managing channel details can often become a tedious task. One such aspect is crafting descriptions for each video uploaded. For creators that upload frequently, typing out similar repetitive descriptions can be incredibly time-consuming. However, by harnessing the power of Google Apps Script, a solution can be automated to alleviate any manual input!

In this article, we will discuss how to create a YouTube description template and copy-paste it using Google Apps Script. We will cover the following topics:

  1. The Google Apps Script basics
  2. Connecting the YouTube API to your script
  3. Creating a description template
  4. Copying and pasting the template
  5. Deploying the script within YouTube.

The Google Apps Script Basics

Google Apps Script is a JavaScript-based language with access to Google Workspace services such as Google Sheets and Google Drive. Developers can use it to automate tasks and create custom functions, add-ons, and user interfaces, all within Google Workspace. For instance, with Google Apps Script, we can create YouTube descriptions automatically.

The primary methods to access Google services in Google Apps Script are:

// Authenticating to Google services
const auth = GoogleAuth.getApplicationDefault();
// Accessing the Google Sheets API
const sheets = google.sheets({
    version: 'v4',
    auth
});
// Accessing the Google Drive API
const drive = google.drive({
    version: 'v3',
    auth
});
// Accessing the YouTube Data API
const youtube = google.youtube({
    version: 'v3',
    auth
});

For our case, we will access the YouTube Data API using Google Apps Script to get the video descriptions.

Connecting the YouTube API to your Script

A prerequisite to using the YouTube Data API is a Google Cloud console where a new project must be created. Once done, create an API key within it. Next, enable the YouTube Data API under APIs and Services within the project.

After enabling the API, open the Google Apps Script editor, click on navigation bar Services, and search for YouTube Data API. Enable it by switching the toggle on the right-hand side.

Now that we have authorization set up with the YouTube API and Google Apps Script, we can create a description template.

Creating a Description Template

First, create a new Google Spreadsheet, and name it YouTube Description Template In it, add the following columns:

  • Title
  • Description

Next, set up the descriptions template for each video. A sample could be:

In this video, we will discuss [topic]. This is a [duration] long video on [sub-topic] and [sub-topic].
00:00 - Introduction
[time] - [sub-topic 1]
[time] - [sub-topic 2]
[conclusion]

This way, as a creator, you only need to input the topic, duration, and sub-topics in the description of each video. The remaining format description can be automated with the help of Google Apps Script.

Copying and Pasting the Template

To copy the template, we need to access it from the Google Spreadsheet and get the required columns. We will use the following method to get the title and description from the Google spreadsheet:

function getDescriptionTemplate() {
    const spreadsheetId = 'SPREADSHEET_ID';
    const sheetName = 'Sheet1'; // Change it as per your spreadsheet
    const firstRow = 2;
    const lastRow = 2;
    const spreadsheet = SpreadsheetApp.openById(spreadsheetId);
    const sheet = spreadsheet.getSheetByName(sheetName);
    const range = sheet.getRange(firstRow, 1, lastRow, sheet.getLastColumn());
    const values = range.getValues();
    const title = values[0][0];
    const description = values[0][1];
    return {
        title,
        description
    };
}

The above code fetches the rows and columns from the Spreadsheet, and in our case, the second row, first column denotes the title and the second column denotes the description.

Finally, we can take the copied title and description and update the video descriptions via the YouTube Data API. We will use the youtube.videos.update method to complete this task:

function setDescription(videoId, title, description) {
    youtube.videos.update({
        part: 'snippet',
        resource: {
            id: videoId,
            snippet: {
                title,
                description
            }
        }
    });
}

With this code in place, we have everything we need to automate and copy the YouTube descriptions of each video.

Deploying the Script in YouTube

Once the above code is implemented and tested, we need to deploy it within YouTube, so it runs automatically.

  1. Open the Google Apps Script project for the YouTube Description Template
  2. Click on “Run” → “Run function” and choose setDescription from the drop-down box.
  3. Authorize your Google account.
  4. Once authorized, go to “Edit” → “Current Project’s Triggers” within the Google Apps Script project.
  5. Create a new trigger. Choose:
    • Run: setDescription
    • Event: From the dropdown menu, choose “Time-driven”
    • Time Interval: Choose how often the script should be run.

That’s it! After following the above steps, the script will automatically run every x interval that we have set up.

In conclusion, with the help of Google Apps Script and the YouTube API, we can automatically copy-paste the YouTube description template. For the next video you create, your YouTube description can be filled in within a matter of seconds.