javascriptnode.jsexpressnpm

How to get YouTube transcript from any video


I'm trying to get any YouTube transcript from a given URL.

I'm using runkit npm to try : https://npm.runkit.com/youtube-transcript using the npm YouTube transcript https://www.npmjs.com/package/youtube-transcript. So my code on runkit is:

var youtubeTranscript = require("youtube-transcript")
youtubeTranscript.fetchTranscript('_cY5ZD9yh2I').then(console.log);

and I have the error :

TypeError: youtubeTranscript.fetchTranscript is not a function

Can someone explain to me what am I doing wrong ?


Solution

  • Will you try this?

    const youtubeTranscript = require('youtube-transcript');
    youtubeTranscript.default.fetchTranscript('_cY5ZD9yh2I').then(console.log);