Help

Extract Youtube API and fetch the transcript to Airtable

Topic Labels: Automations Data Integrations
616 1
cancel
Showing results for 
Search instead for 
Did you mean: 
bmax911
4 - Data Explorer
4 - Data Explorer

Hello guys,

I'm trying to build a script to automation fetch the youtube video's transcript to Airtable via API keys or Oauth 2.0 via Make.com. But when i'm trying to retrieve the transcript and fetch the data to Airtable, i cannot do that via API, so I have to create OAuth in Make.com. This is a script i used, but Airtable noticed me an error

console.error

  1. "Error fetching transcript:"
  1. {code: 403, message: "The permissions associated with the request are not sufficient to download the caption track. The request might not be properly authorized, or the video order might not have enabled third-party contributions for this caption.", errors: Array(1)}

Anyone has experience this issue or resolve it before. Pleases, let me know hown

Thank you so much

1 Reply 1
bmax911
4 - Data Explorer
4 - Data Explorer
// Fetch the record that triggered the automation
let inputConfig = input.config();
let recordId = inputConfig.recordId;
let table = base.getTable('Your Table Name');

let record = await table.selectRecordAsync(recordId);
let videoURL = record.getCellValue('Link Sample Video');

if (videoURL) {
    let videoID = videoURL.split('v=')[1].split('&')[0];
    let accessToken = 'YOUR_ACCESS_TOKEN'; // Replace with the actual access token

    // API call to get the caption list
    let response = await fetch(`https://www.googleapis.com/youtube/v3/captions?videoId=${videoID}`, {
        headers: {
            'Authorization': `Bearer ${accessToken}`
        }
    });

    let data = await response.json();

    if (data.error) {
        console.error('Error fetching transcript:', data.error);
        return;
    }

    if (data.items && data.items.length > 0) {
        let captionId = data.items[0].id;

        // Call to get the actual transcript
        let transcriptResponse = await fetch(`https://www.googleapis.com/youtube/v3/captions/${captionId}`, {
            headers: {
                'Authorization': `Bearer ${accessToken}`
            }
        });

        let transcriptData = await transcriptResponse.json();

        if (transcriptData.error) {
            console.error('Error fetching transcript:', transcriptData.error);
            return;
        }

        // Process transcriptData to extract text and update Airtable
        // ...
    } else {
        console.log('No captions available for this video.');
    }
} else {
    console.log('No video URL found in the record.');
}