Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3720

unable to pull youtube video transcriptions from youtube Data API V3 [closed]

$
0
0

I'm unable to pull youtube video transcriptions from youtube Data API V3:

This is my code:

const accessToken = "my access token with all youtube Scopes"// Make the request to retrieve transcriptionsconst transcriptionsUrl = `https://www.googleapis.com/youtube/v3/captionspart=snippet&videoId=${item.id.videoId}&key=${YOUTUBE_API_KEY}`;const headers = {    Authorization: `Bearer ${accessToken}`,};const response = await axios.get(transcriptionsUrl, {    headers});const caption = response.data.items[0]; // Assuming there is only one caption in the responseif (caption) {    const captionId = caption.id;    const captionTrackUrl = `https://www.googleapis.com/youtube/v3/captions/${captionId}?tfmt=srt&key=${YOUTUBE_API_KEY}`;    const captionTrackResponse = await axios.get(captionTrackUrl, {        headers    });    if (captionTrackResponse.status === 200) {        const transcriptionText = captionTrackResponse.data;        console.log('Transcription Text:', transcriptionText);    } else {        console.log('Failed to retrieve caption track');    }} else {    console.log('No caption found for the video');}

Viewing all articles
Browse latest Browse all 3720

Latest Images

Trending Articles



Latest Images