Added info cards are not visible on Youtube video

1k Views Asked by At

I have updated Youtube video by using Youtube data api.I got successful response from api. I have updated my video title and also added cards with api. I can see title was updated instantly but not able to find added cards on Youtube video.

I have tried below given code with node.js api.I have not received any errors and api call was success. But video title was updated successfully from same api and cards are not visible on video

async function addInfoCardsToVideo(videoId) {
    try {
      // First, retrieve the video's current metadata
      const video = await youtube.videos.list({
        part: 'snippet',
        id: 'myexistingvideoid', // This is my existing Youtube video id
      });

      // Next, construct the new metadata object with the info card data
      const infoCard = {
        kind: 'youtube#video',
        videoId: videoId,
        card: {
          teaser: {
            startTimeMs: 10000, // The time in milliseconds where the teaser begins
            endTimeMs: 30000, // The time in milliseconds where the teaser ends
          },
          cards: [
            {
              teaserTitle: 'Info Card Title',
              teaserDurationMs: 5000, // The duration of the teaser in milliseconds
              teaserStartTimeMs: 20000, // The time in milliseconds where the teaser should be displayed
              type: 'video',
              videoId: 'othervideoid', // The video ID for the video you want to link to
            },
          ],
        },
      };

      // Update the video's metadata to add the info card
      const update = await youtube.videos.update({
        part: 'snippet',
        resource: {
          id: videoId,
          snippet: {
            ...video.data.items[0].snippet,
            localized: {
              ...video.data.items[0].snippet.localized,
            },
            cards: infoCard,
            title:'updated video title'
          },
        },
      });

      console.log(`Successfully updated video: ${videoId}`);
    } catch (err) {
      console.error(`Error updating video: ${err}`);
    }
  }
addInfoCardsToVideo('myexistingvideoid') //passing my existing Youtube video id ]

Kindly help

0

There are 0 best solutions below